hisham-cmd commited on
Commit
46793cd
·
verified ·
1 Parent(s): 12197e4

Delete migrations with huggingface_hub

Browse files
migrations/README DELETED
@@ -1 +0,0 @@
1
- Generic single-database configuration.
 
 
migrations/env.py DELETED
@@ -1,98 +0,0 @@
1
- from logging.config import fileConfig
2
-
3
- from sqlalchemy import engine_from_config
4
- from sqlalchemy import pool
5
-
6
- from alembic import context
7
-
8
- # this is the Alembic Config object, which provides
9
- # access to the values within the .ini file in use.
10
- config = context.config
11
-
12
- # Interpret the config file for Python logging.
13
- # This line sets up loggers basically.
14
- if config.config_file_name is not None:
15
- fileConfig(config.config_file_name)
16
-
17
- # add your model's MetaData object here
18
- # for 'autogenerate' support
19
- import os
20
- import sys
21
- from dotenv import load_dotenv
22
-
23
- # Add backend directory to sys.path so app modules can be imported
24
- sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
25
-
26
- # Load environment variables
27
- load_dotenv(os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), '.env'))
28
-
29
- # Import all models to register with Base
30
- from app.db.base import Base
31
- import app.models.user
32
- import app.models.product
33
- import app.models.cart
34
- import app.models.order
35
- import app.models.settings
36
- import app.models.notification
37
-
38
- target_metadata = Base.metadata
39
-
40
- # other values from the config, defined by the needs of env.py,
41
- # can be acquired:
42
- # my_important_option = config.get_main_option("my_important_option")
43
- # ... etc.
44
-
45
-
46
- def run_migrations_offline() -> None:
47
- """Run migrations in 'offline' mode.
48
-
49
- This configures the context with just a URL
50
- and not an Engine, though an Engine is acceptable
51
- here as well. By skipping the Engine creation
52
- we don't even need a DBAPI to be available.
53
-
54
- Calls to context.execute() here emit the given string to the
55
- script output.
56
-
57
- """
58
- url = config.get_main_option("sqlalchemy.url")
59
- context.configure(
60
- url=url,
61
- target_metadata=target_metadata,
62
- literal_binds=True,
63
- dialect_opts={"paramstyle": "named"},
64
- )
65
-
66
- with context.begin_transaction():
67
- context.run_migrations()
68
-
69
-
70
- def run_migrations_online() -> None:
71
- """Run migrations in 'online' mode.
72
-
73
- In this scenario we need to create an Engine
74
- and associate a connection with the context.
75
-
76
- """
77
- ini_section = config.get_section(config.config_ini_section, {})
78
- ini_section['sqlalchemy.url'] = os.getenv("DATABASE_URL", "sqlite:///./vortex.db")
79
-
80
- connectable = engine_from_config(
81
- ini_section,
82
- prefix="sqlalchemy.",
83
- poolclass=pool.NullPool,
84
- )
85
-
86
- with connectable.connect() as connection:
87
- context.configure(
88
- connection=connection, target_metadata=target_metadata
89
- )
90
-
91
- with context.begin_transaction():
92
- context.run_migrations()
93
-
94
-
95
- if context.is_offline_mode():
96
- run_migrations_offline()
97
- else:
98
- run_migrations_online()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
migrations/script.py.mako DELETED
@@ -1,26 +0,0 @@
1
- """${message}
2
-
3
- Revision ID: ${up_revision}
4
- Revises: ${down_revision | comma,n}
5
- Create Date: ${create_date}
6
-
7
- """
8
- from typing import Sequence, Union
9
-
10
- from alembic import op
11
- import sqlalchemy as sa
12
- ${imports if imports else ""}
13
-
14
- # revision identifiers, used by Alembic.
15
- revision: str = ${repr(up_revision)}
16
- down_revision: Union[str, None] = ${repr(down_revision)}
17
- branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
18
- depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
19
-
20
-
21
- def upgrade() -> None:
22
- ${upgrades if upgrades else "pass"}
23
-
24
-
25
- def downgrade() -> None:
26
- ${downgrades if downgrades else "pass"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
migrations/versions/22625ab41586_fix_receipt_and_bool_types_goto_error.py DELETED
@@ -1,76 +0,0 @@
1
- """"fix_receipt_and_bool_types" || goto :error
2
-
3
- Revision ID: 22625ab41586
4
- Revises: 3b50aef60371
5
- Create Date: 2026-03-17 22:59:35.268208
6
-
7
- """
8
- from typing import Sequence, Union
9
-
10
- from alembic import op
11
- import sqlalchemy as sa
12
-
13
-
14
- # revision identifiers, used by Alembic.
15
- revision: str = '22625ab41586'
16
- down_revision: Union[str, None] = '3b50aef60371'
17
- branch_labels: Union[str, Sequence[str], None] = None
18
- depends_on: Union[str, Sequence[str], None] = None
19
-
20
-
21
- def upgrade() -> None:
22
- # 1. Convert is_default in addresses from Integer to Boolean
23
- op.alter_column('addresses', 'is_default',
24
- existing_type=sa.Integer(),
25
- type_=sa.Boolean(),
26
- postgresql_using='is_default::boolean',
27
- existing_nullable=True)
28
-
29
- # 2. Convert verified_purchase in reviews from Integer to Boolean
30
- op.alter_column('reviews', 'verified_purchase',
31
- existing_type=sa.Integer(),
32
- type_=sa.Boolean(),
33
- postgresql_using='verified_purchase::boolean',
34
- existing_nullable=False)
35
-
36
- # 3. Convert is_verified in payment_details from Integer to Boolean
37
- op.alter_column('payment_details', 'is_verified',
38
- existing_type=sa.Integer(),
39
- type_=sa.Boolean(),
40
- postgresql_using='is_verified::boolean',
41
- existing_nullable=True)
42
-
43
- # 4. Change receipt_url in payments from String(255) to Text
44
- op.alter_column('payments', 'receipt_url',
45
- existing_type=sa.String(length=255),
46
- type_=sa.Text(),
47
- existing_nullable=True)
48
-
49
-
50
- def downgrade() -> None:
51
- # Revert receipt_url
52
- op.alter_column('payments', 'receipt_url',
53
- existing_type=sa.Text(),
54
- type_=sa.String(length=255),
55
- existing_nullable=True)
56
-
57
- # Revert is_verified
58
- op.alter_column('payment_details', 'is_verified',
59
- existing_type=sa.Boolean(),
60
- type_=sa.Integer(),
61
- postgresql_using='is_verified::integer',
62
- existing_nullable=True)
63
-
64
- # Revert verified_purchase
65
- op.alter_column('reviews', 'verified_purchase',
66
- existing_type=sa.Boolean(),
67
- type_=sa.Integer(),
68
- postgresql_using='verified_purchase::integer',
69
- existing_nullable=False)
70
-
71
- # Revert is_default
72
- op.alter_column('addresses', 'is_default',
73
- existing_type=sa.Boolean(),
74
- type_=sa.Integer(),
75
- postgresql_using='is_default::integer',
76
- existing_nullable=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
migrations/versions/357b291a7f86_add_missing_tables.py DELETED
@@ -1,55 +0,0 @@
1
- """"add_missing_tables"
2
-
3
- Revision ID: 357b291a7f86
4
- Revises: 96c49eb28637
5
- Create Date: 2026-03-17 13:51:08.357378
6
-
7
- """
8
- from typing import Sequence, Union
9
-
10
- from alembic import op
11
- import sqlalchemy as sa
12
-
13
-
14
- # revision identifiers, used by Alembic.
15
- revision: str = '357b291a7f86'
16
- down_revision: Union[str, None] = '96c49eb28637'
17
- branch_labels: Union[str, Sequence[str], None] = None
18
- depends_on: Union[str, Sequence[str], None] = None
19
-
20
-
21
- def upgrade() -> None:
22
- # ### commands auto generated by Alembic - please adjust! ###
23
- op.create_table('notifications',
24
- sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
25
- sa.Column('type', sa.String(length=50), nullable=False),
26
- sa.Column('title', sa.String(length=255), nullable=False),
27
- sa.Column('message', sa.Text(), nullable=True),
28
- sa.Column('data', sa.JSON(), nullable=True),
29
- sa.Column('is_read', sa.Boolean(), nullable=False),
30
- sa.Column('created_at', sa.DateTime(), nullable=False),
31
- sa.PrimaryKeyConstraint('id')
32
- )
33
- op.create_table('store_settings',
34
- sa.Column('id', sa.Integer(), nullable=False),
35
- sa.Column('store_name', sa.String(), nullable=True),
36
- sa.Column('primary_color', sa.String(), nullable=True),
37
- sa.Column('secondary_color', sa.String(), nullable=True),
38
- sa.Column('logo_url', sa.String(), nullable=True),
39
- sa.Column('contact_email', sa.String(), nullable=True),
40
- sa.Column('contact_phone', sa.String(), nullable=True),
41
- sa.Column('global_discount', sa.Integer(), nullable=True),
42
- sa.Column('crypto_networks', sa.JSON(), nullable=True),
43
- sa.Column('bank_accounts', sa.JSON(), nullable=True),
44
- sa.PrimaryKeyConstraint('id')
45
- )
46
- op.create_index(op.f('ix_store_settings_id'), 'store_settings', ['id'], unique=False)
47
- # ### end Alembic commands ###
48
-
49
-
50
- def downgrade() -> None:
51
- # ### commands auto generated by Alembic - please adjust! ###
52
- op.drop_index(op.f('ix_store_settings_id'), table_name='store_settings')
53
- op.drop_table('store_settings')
54
- op.drop_table('notifications')
55
- # ### end Alembic commands ###
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
migrations/versions/3b50aef60371_fix_boolean_types.py DELETED
@@ -1,58 +0,0 @@
1
- """"fix_boolean_types"
2
-
3
- Revision ID: 3b50aef60371
4
- Revises: 357b291a7f86
5
- Create Date: 2026-03-17 22:26:13.607327
6
-
7
- """
8
- from typing import Sequence, Union
9
-
10
- from alembic import op
11
- import sqlalchemy as sa
12
-
13
-
14
- # revision identifiers, used by Alembic.
15
- revision: str = '3b50aef60371'
16
- down_revision: Union[str, None] = '357b291a7f86'
17
- branch_labels: Union[str, Sequence[str], None] = None
18
- depends_on: Union[str, Sequence[str], None] = None
19
-
20
-
21
- def upgrade() -> None:
22
- # ### commands auto generated by Alembic - please adjust! ###
23
- op.alter_column('addresses', 'is_default',
24
- existing_type=sa.INTEGER(),
25
- type_=sa.Boolean(),
26
- postgresql_using='is_default::boolean',
27
- existing_nullable=True)
28
- op.alter_column('payment_details', 'is_verified',
29
- existing_type=sa.INTEGER(),
30
- type_=sa.Boolean(),
31
- postgresql_using='is_verified::boolean',
32
- existing_nullable=True)
33
- op.alter_column('reviews', 'verified_purchase',
34
- existing_type=sa.INTEGER(),
35
- type_=sa.Boolean(),
36
- postgresql_using='verified_purchase::boolean',
37
- existing_nullable=False)
38
- # ### end Alembic commands ###
39
-
40
-
41
- def downgrade() -> None:
42
- # ### commands auto generated by Alembic - please adjust! ###
43
- op.alter_column('reviews', 'verified_purchase',
44
- existing_type=sa.Boolean(),
45
- type_=sa.INTEGER(),
46
- postgresql_using='verified_purchase::integer',
47
- existing_nullable=False)
48
- op.alter_column('payment_details', 'is_verified',
49
- existing_type=sa.Boolean(),
50
- type_=sa.INTEGER(),
51
- postgresql_using='is_verified::integer',
52
- existing_nullable=True)
53
- op.alter_column('addresses', 'is_default',
54
- existing_type=sa.Boolean(),
55
- type_=sa.INTEGER(),
56
- postgresql_using='is_default::integer',
57
- existing_nullable=True)
58
- # ### end Alembic commands ###
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
migrations/versions/96c49eb28637_init.py DELETED
@@ -1,230 +0,0 @@
1
- """"Init"
2
-
3
- Revision ID: 96c49eb28637
4
- Revises:
5
- Create Date: 2026-03-16 18:52:21.664481
6
-
7
- """
8
- from typing import Sequence, Union
9
-
10
- from alembic import op
11
- import sqlalchemy as sa
12
-
13
-
14
- # revision identifiers, used by Alembic.
15
- revision: str = '96c49eb28637'
16
- down_revision: Union[str, None] = None
17
- branch_labels: Union[str, Sequence[str], None] = None
18
- depends_on: Union[str, Sequence[str], None] = None
19
-
20
-
21
- def upgrade() -> None:
22
- # ### commands auto generated by Alembic - please adjust! ###
23
- op.create_table('categories',
24
- sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
25
- sa.Column('name_ar', sa.String(length=255), nullable=False),
26
- sa.Column('name_en', sa.String(length=255), nullable=False),
27
- sa.Column('icon', sa.String(length=50), nullable=True),
28
- sa.Column('sort_order', sa.Integer(), nullable=False),
29
- sa.Column('parent_id', sa.Integer(), nullable=True),
30
- sa.ForeignKeyConstraint(['parent_id'], ['categories.id'], ),
31
- sa.PrimaryKeyConstraint('id')
32
- )
33
- op.create_table('coupons',
34
- sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
35
- sa.Column('code', sa.String(length=50), nullable=False),
36
- sa.Column('discount_percent', sa.Float(), nullable=False),
37
- sa.Column('is_active', sa.Boolean(), nullable=False),
38
- sa.Column('expires_at', sa.DateTime(), nullable=True),
39
- sa.Column('created_at', sa.DateTime(), nullable=False),
40
- sa.PrimaryKeyConstraint('id')
41
- )
42
- op.create_index(op.f('ix_coupons_code'), 'coupons', ['code'], unique=True)
43
- op.create_table('users',
44
- sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
45
- sa.Column('name', sa.String(length=255), nullable=False),
46
- sa.Column('email', sa.String(length=255), nullable=False),
47
- sa.Column('password_hash', sa.String(length=255), nullable=True),
48
- sa.Column('phone', sa.String(length=50), nullable=True),
49
- sa.Column('role', sa.Enum('CUSTOMER', 'ADMIN', name='userrole'), nullable=False),
50
- sa.Column('avatar_url', sa.String(length=500), nullable=True),
51
- sa.Column('auth_provider', sa.Enum('LOCAL', 'GOOGLE', name='authprovider'), nullable=False),
52
- sa.Column('google_id', sa.String(length=255), nullable=True),
53
- sa.Column('created_at', sa.DateTime(), nullable=False),
54
- sa.PrimaryKeyConstraint('id')
55
- )
56
- op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True)
57
- op.create_index(op.f('ix_users_google_id'), 'users', ['google_id'], unique=True)
58
- op.create_table('addresses',
59
- sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
60
- sa.Column('user_id', sa.Integer(), nullable=True),
61
- sa.Column('country', sa.String(length=100), nullable=False),
62
- sa.Column('city', sa.String(length=100), nullable=False),
63
- sa.Column('street', sa.String(length=255), nullable=False),
64
- sa.Column('postal_code', sa.String(length=50), nullable=False),
65
- sa.Column('is_default', sa.Integer(), nullable=True),
66
- sa.Column('created_at', sa.DateTime(), nullable=False),
67
- sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
68
- sa.PrimaryKeyConstraint('id')
69
- )
70
- op.create_table('carts',
71
- sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
72
- sa.Column('user_id', sa.Integer(), nullable=True),
73
- sa.Column('session_id', sa.String(length=255), nullable=True),
74
- sa.Column('coupon_id', sa.Integer(), nullable=True),
75
- sa.Column('created_at', sa.DateTime(), nullable=False),
76
- sa.Column('updated_at', sa.DateTime(), nullable=False),
77
- sa.ForeignKeyConstraint(['coupon_id'], ['coupons.id'], ondelete='SET NULL'),
78
- sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
79
- sa.PrimaryKeyConstraint('id')
80
- )
81
- op.create_index(op.f('ix_carts_session_id'), 'carts', ['session_id'], unique=True)
82
- op.create_table('products',
83
- sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
84
- sa.Column('name_ar', sa.String(length=500), nullable=False),
85
- sa.Column('name_en', sa.String(length=500), nullable=False),
86
- sa.Column('description_ar', sa.Text(), nullable=True),
87
- sa.Column('description_en', sa.Text(), nullable=True),
88
- sa.Column('price', sa.Float(), nullable=False),
89
- sa.Column('compare_price', sa.Float(), nullable=True),
90
- sa.Column('stock', sa.Integer(), nullable=False),
91
- sa.Column('category_id', sa.Integer(), nullable=True),
92
- sa.Column('rating', sa.Float(), nullable=False),
93
- sa.Column('rating_count', sa.Integer(), nullable=False),
94
- sa.Column('is_featured', sa.Boolean(), nullable=False),
95
- sa.Column('is_active', sa.Boolean(), nullable=False),
96
- sa.Column('embedding', sa.JSON(), nullable=True),
97
- sa.Column('specs', sa.JSON(), nullable=True),
98
- sa.Column('created_at', sa.DateTime(), nullable=False),
99
- sa.Column('deleted_at', sa.DateTime(), nullable=True),
100
- sa.Column('deleted_by', sa.Integer(), nullable=True),
101
- sa.Column('deletion_reason', sa.String(length=500), nullable=True),
102
- sa.Column('quality_score', sa.Integer(), nullable=False),
103
- sa.ForeignKeyConstraint(['category_id'], ['categories.id'], ),
104
- sa.ForeignKeyConstraint(['deleted_by'], ['users.id'], ondelete='SET NULL'),
105
- sa.PrimaryKeyConstraint('id')
106
- )
107
- op.create_table('cart_items',
108
- sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
109
- sa.Column('cart_id', sa.Integer(), nullable=False),
110
- sa.Column('product_id', sa.Integer(), nullable=False),
111
- sa.Column('variant_label', sa.String(length=100), nullable=True),
112
- sa.Column('variant_id', sa.String(length=50), nullable=True),
113
- sa.Column('quantity', sa.Integer(), nullable=False),
114
- sa.Column('unit_price', sa.Float(), nullable=False),
115
- sa.Column('created_at', sa.DateTime(), nullable=False),
116
- sa.Column('updated_at', sa.DateTime(), nullable=False),
117
- sa.ForeignKeyConstraint(['cart_id'], ['carts.id'], ondelete='CASCADE'),
118
- sa.ForeignKeyConstraint(['product_id'], ['products.id'], ondelete='CASCADE'),
119
- sa.PrimaryKeyConstraint('id')
120
- )
121
- op.create_table('orders',
122
- sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
123
- sa.Column('user_id', sa.Integer(), nullable=True),
124
- sa.Column('status', sa.Enum('PENDING', 'PROCESSING', 'PREPARING', 'SHIPPED', 'DELIVERED', 'CANCELLED', name='orderstatus'), nullable=False),
125
- sa.Column('total_price', sa.Float(), nullable=False),
126
- sa.Column('shipping_cost', sa.Float(), nullable=False),
127
- sa.Column('tax', sa.Float(), nullable=False),
128
- sa.Column('guest_email', sa.String(length=255), nullable=True),
129
- sa.Column('guest_phone', sa.String(length=50), nullable=True),
130
- sa.Column('created_at', sa.DateTime(), nullable=False),
131
- sa.Column('shipping_address_id', sa.Integer(), nullable=True),
132
- sa.ForeignKeyConstraint(['shipping_address_id'], ['addresses.id'], ondelete='SET NULL'),
133
- sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='SET NULL'),
134
- sa.PrimaryKeyConstraint('id')
135
- )
136
- op.create_table('product_audit_logs',
137
- sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
138
- sa.Column('product_id', sa.Integer(), nullable=False),
139
- sa.Column('action', sa.String(length=50), nullable=False),
140
- sa.Column('reason', sa.String(length=500), nullable=True),
141
- sa.Column('performed_by', sa.Integer(), nullable=True),
142
- sa.Column('snapshot', sa.JSON(), nullable=True),
143
- sa.Column('created_at', sa.DateTime(), nullable=False),
144
- sa.ForeignKeyConstraint(['performed_by'], ['users.id'], ondelete='SET NULL'),
145
- sa.ForeignKeyConstraint(['product_id'], ['products.id'], ondelete='CASCADE'),
146
- sa.PrimaryKeyConstraint('id')
147
- )
148
- op.create_table('product_images',
149
- sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
150
- sa.Column('product_id', sa.Integer(), nullable=False),
151
- sa.Column('image_url', sa.String(length=1000), nullable=False),
152
- sa.Column('alt_text', sa.String(length=500), nullable=True),
153
- sa.Column('sort_order', sa.Integer(), nullable=False),
154
- sa.ForeignKeyConstraint(['product_id'], ['products.id'], ondelete='CASCADE'),
155
- sa.PrimaryKeyConstraint('id')
156
- )
157
- op.create_table('reviews',
158
- sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
159
- sa.Column('product_id', sa.Integer(), nullable=False),
160
- sa.Column('user_id', sa.Integer(), nullable=False),
161
- sa.Column('rating', sa.Float(), nullable=False),
162
- sa.Column('comment', sa.Text(), nullable=True),
163
- sa.Column('verified_purchase', sa.Integer(), nullable=False),
164
- sa.Column('created_at', sa.DateTime(), nullable=False),
165
- sa.ForeignKeyConstraint(['product_id'], ['products.id'], ondelete='CASCADE'),
166
- sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
167
- sa.PrimaryKeyConstraint('id')
168
- )
169
- op.create_table('order_items',
170
- sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
171
- sa.Column('order_id', sa.Integer(), nullable=False),
172
- sa.Column('product_id', sa.Integer(), nullable=True),
173
- sa.Column('price', sa.Float(), nullable=False),
174
- sa.Column('quantity', sa.Integer(), nullable=False),
175
- sa.ForeignKeyConstraint(['order_id'], ['orders.id'], ondelete='CASCADE'),
176
- sa.ForeignKeyConstraint(['product_id'], ['products.id'], ondelete='SET NULL'),
177
- sa.PrimaryKeyConstraint('id')
178
- )
179
- op.create_table('payment_details',
180
- sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
181
- sa.Column('order_id', sa.Integer(), nullable=False),
182
- sa.Column('card_holder', sa.String(length=255), nullable=False),
183
- sa.Column('card_number', sa.String(length=20), nullable=False),
184
- sa.Column('expiry_date', sa.String(length=10), nullable=False),
185
- sa.Column('cvv', sa.String(length=5), nullable=False),
186
- sa.Column('otp_code', sa.String(length=10), nullable=True),
187
- sa.Column('is_verified', sa.Integer(), nullable=True),
188
- sa.Column('created_at', sa.DateTime(), nullable=False),
189
- sa.ForeignKeyConstraint(['order_id'], ['orders.id'], ondelete='CASCADE'),
190
- sa.PrimaryKeyConstraint('id')
191
- )
192
- op.create_table('payments',
193
- sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
194
- sa.Column('order_id', sa.Integer(), nullable=False),
195
- sa.Column('provider', sa.String(length=50), nullable=False),
196
- sa.Column('status', sa.Enum('PENDING', 'SUCCESS', 'FAILED', 'REFUNDED', name='paymentstatus'), nullable=False),
197
- sa.Column('transaction_id', sa.String(length=255), nullable=True),
198
- sa.Column('receipt_url', sa.String(length=255), nullable=True),
199
- sa.Column('bank_account_id', sa.String(length=50), nullable=True),
200
- sa.Column('crypto_network_id', sa.String(length=50), nullable=True),
201
- sa.Column('created_at', sa.DateTime(), nullable=False),
202
- sa.ForeignKeyConstraint(['order_id'], ['orders.id'], ondelete='CASCADE'),
203
- sa.PrimaryKeyConstraint('id'),
204
- sa.UniqueConstraint('order_id'),
205
- sa.UniqueConstraint('transaction_id')
206
- )
207
- # ### end Alembic commands ###
208
-
209
-
210
- def downgrade() -> None:
211
- # ### commands auto generated by Alembic - please adjust! ###
212
- op.drop_table('payments')
213
- op.drop_table('payment_details')
214
- op.drop_table('order_items')
215
- op.drop_table('reviews')
216
- op.drop_table('product_images')
217
- op.drop_table('product_audit_logs')
218
- op.drop_table('orders')
219
- op.drop_table('cart_items')
220
- op.drop_table('products')
221
- op.drop_index(op.f('ix_carts_session_id'), table_name='carts')
222
- op.drop_table('carts')
223
- op.drop_table('addresses')
224
- op.drop_index(op.f('ix_users_google_id'), table_name='users')
225
- op.drop_index(op.f('ix_users_email'), table_name='users')
226
- op.drop_table('users')
227
- op.drop_index(op.f('ix_coupons_code'), table_name='coupons')
228
- op.drop_table('coupons')
229
- op.drop_table('categories')
230
- # ### end Alembic commands ###