Spaces:
Sleeping
Sleeping
Delete migrations with huggingface_hub
Browse filesFiles changed (7)
- migrations/READMEDeleted-1
- migrations/env.pyDeleted-98
- migrations/script.py.makoDeleted-26
- migrations/versions/22625ab41586_fix_receipt_and_bool_types_goto_error.pyDeleted-76
- migrations/versions/357b291a7f86_add_missing_tables.pyDeleted-55
- migrations/versions/3b50aef60371_fix_boolean_types.pyDeleted-58
- migrations/versions/96c49eb28637_init.pyDeleted-230
1Generic single-database configuration.1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798from logging.config import fileConfig
from sqlalchemy import engine_from_configfrom sqlalchemy import pool
from alembic import context
# this is the Alembic Config object, which provides# access to the values within the .ini file in use.config = context.config
# Interpret the config file for Python logging.# This line sets up loggers basically.if config.config_file_name is not None: fileConfig(config.config_file_name)
# add your model's MetaData object here# for 'autogenerate' supportimport osimport sysfrom dotenv import load_dotenv
# Add backend directory to sys.path so app modules can be importedsys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
# Load environment variablesload_dotenv(os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), '.env'))
# Import all models to register with Basefrom app.db.base import Baseimport app.models.userimport app.models.productimport app.models.cartimport app.models.orderimport app.models.settingsimport app.models.notification
target_metadata = Base.metadata
# other values from the config, defined by the needs of env.py,# can be acquired:# my_important_option = config.get_main_option("my_important_option")# ... etc.
def run_migrations_offline() -> None: """Run migrations in 'offline' mode.
This configures the context with just a URL and not an Engine, though an Engine is acceptable here as well. By skipping the Engine creation we don't even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the script output.
""" url = config.get_main_option("sqlalchemy.url") context.configure( url=url, target_metadata=target_metadata, literal_binds=True, dialect_opts={"paramstyle": "named"}, )
with context.begin_transaction(): context.run_migrations()
def run_migrations_online() -> None: """Run migrations in 'online' mode.
In this scenario we need to create an Engine and associate a connection with the context.
""" ini_section = config.get_section(config.config_ini_section, {}) ini_section['sqlalchemy.url'] = os.getenv("DATABASE_URL", "sqlite:///./vortex.db")
connectable = engine_from_config( ini_section, prefix="sqlalchemy.", poolclass=pool.NullPool, )
with connectable.connect() as connection: context.configure( connection=connection, target_metadata=target_metadata )
with context.begin_transaction(): context.run_migrations()
if context.is_offline_mode(): run_migrations_offline()else: run_migrations_online()1234567891011121314151617181920212223242526"""${message}
Revision ID: ${up_revision}Revises: ${down_revision | comma,n}Create Date: ${create_date}
"""from typing import Sequence, Union
from alembic import opimport sqlalchemy as sa${imports if imports else ""}
# revision identifiers, used by Alembic.revision: str = ${repr(up_revision)}down_revision: Union[str, None] = ${repr(down_revision)}branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
def upgrade() -> None: ${upgrades if upgrades else "pass"}
def downgrade() -> None: ${downgrades if downgrades else "pass"}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576""""fix_receipt_and_bool_types" || goto :error
Revision ID: 22625ab41586Revises: 3b50aef60371Create Date: 2026-03-17 22:59:35.268208
"""from typing import Sequence, Union
from alembic import opimport sqlalchemy as sa
# revision identifiers, used by Alembic.revision: str = '22625ab41586'down_revision: Union[str, None] = '3b50aef60371'branch_labels: Union[str, Sequence[str], None] = Nonedepends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None: # 1. Convert is_default in addresses from Integer to Boolean op.alter_column('addresses', 'is_default', existing_type=sa.Integer(), type_=sa.Boolean(), postgresql_using='is_default::boolean', existing_nullable=True) # 2. Convert verified_purchase in reviews from Integer to Boolean op.alter_column('reviews', 'verified_purchase', existing_type=sa.Integer(), type_=sa.Boolean(), postgresql_using='verified_purchase::boolean', existing_nullable=False) # 3. Convert is_verified in payment_details from Integer to Boolean op.alter_column('payment_details', 'is_verified', existing_type=sa.Integer(), type_=sa.Boolean(), postgresql_using='is_verified::boolean', existing_nullable=True) # 4. Change receipt_url in payments from String(255) to Text op.alter_column('payments', 'receipt_url', existing_type=sa.String(length=255), type_=sa.Text(), existing_nullable=True)
def downgrade() -> None: # Revert receipt_url op.alter_column('payments', 'receipt_url', existing_type=sa.Text(), type_=sa.String(length=255), existing_nullable=True) # Revert is_verified op.alter_column('payment_details', 'is_verified', existing_type=sa.Boolean(), type_=sa.Integer(), postgresql_using='is_verified::integer', existing_nullable=True) # Revert verified_purchase op.alter_column('reviews', 'verified_purchase', existing_type=sa.Boolean(), type_=sa.Integer(), postgresql_using='verified_purchase::integer', existing_nullable=False) # Revert is_default op.alter_column('addresses', 'is_default', existing_type=sa.Boolean(), type_=sa.Integer(), postgresql_using='is_default::integer', existing_nullable=True)12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455""""add_missing_tables"
Revision ID: 357b291a7f86Revises: 96c49eb28637Create Date: 2026-03-17 13:51:08.357378
"""from typing import Sequence, Union
from alembic import opimport sqlalchemy as sa
# revision identifiers, used by Alembic.revision: str = '357b291a7f86'down_revision: Union[str, None] = '96c49eb28637'branch_labels: Union[str, Sequence[str], None] = Nonedepends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.create_table('notifications', sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('type', sa.String(length=50), nullable=False), sa.Column('title', sa.String(length=255), nullable=False), sa.Column('message', sa.Text(), nullable=True), sa.Column('data', sa.JSON(), nullable=True), sa.Column('is_read', sa.Boolean(), nullable=False), sa.Column('created_at', sa.DateTime(), nullable=False), sa.PrimaryKeyConstraint('id') ) op.create_table('store_settings', sa.Column('id', sa.Integer(), nullable=False), sa.Column('store_name', sa.String(), nullable=True), sa.Column('primary_color', sa.String(), nullable=True), sa.Column('secondary_color', sa.String(), nullable=True), sa.Column('logo_url', sa.String(), nullable=True), sa.Column('contact_email', sa.String(), nullable=True), sa.Column('contact_phone', sa.String(), nullable=True), sa.Column('global_discount', sa.Integer(), nullable=True), sa.Column('crypto_networks', sa.JSON(), nullable=True), sa.Column('bank_accounts', sa.JSON(), nullable=True), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_store_settings_id'), 'store_settings', ['id'], unique=False) # ### end Alembic commands ###
def downgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.drop_index(op.f('ix_store_settings_id'), table_name='store_settings') op.drop_table('store_settings') op.drop_table('notifications') # ### end Alembic commands ###12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758""""fix_boolean_types"
Revision ID: 3b50aef60371Revises: 357b291a7f86Create Date: 2026-03-17 22:26:13.607327
"""from typing import Sequence, Union
from alembic import opimport sqlalchemy as sa
# revision identifiers, used by Alembic.revision: str = '3b50aef60371'down_revision: Union[str, None] = '357b291a7f86'branch_labels: Union[str, Sequence[str], None] = Nonedepends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.alter_column('addresses', 'is_default', existing_type=sa.INTEGER(), type_=sa.Boolean(), postgresql_using='is_default::boolean', existing_nullable=True) op.alter_column('payment_details', 'is_verified', existing_type=sa.INTEGER(), type_=sa.Boolean(), postgresql_using='is_verified::boolean', existing_nullable=True) op.alter_column('reviews', 'verified_purchase', existing_type=sa.INTEGER(), type_=sa.Boolean(), postgresql_using='verified_purchase::boolean', existing_nullable=False) # ### end Alembic commands ###
def downgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.alter_column('reviews', 'verified_purchase', existing_type=sa.Boolean(), type_=sa.INTEGER(), postgresql_using='verified_purchase::integer', existing_nullable=False) op.alter_column('payment_details', 'is_verified', existing_type=sa.Boolean(), type_=sa.INTEGER(), postgresql_using='is_verified::integer', existing_nullable=True) op.alter_column('addresses', 'is_default', existing_type=sa.Boolean(), type_=sa.INTEGER(), postgresql_using='is_default::integer', existing_nullable=True) # ### end Alembic commands ###123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230""""Init"
Revision ID: 96c49eb28637Revises: Create Date: 2026-03-16 18:52:21.664481
"""from typing import Sequence, Union
from alembic import opimport sqlalchemy as sa
# revision identifiers, used by Alembic.revision: str = '96c49eb28637'down_revision: Union[str, None] = Nonebranch_labels: Union[str, Sequence[str], None] = Nonedepends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.create_table('categories', sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('name_ar', sa.String(length=255), nullable=False), sa.Column('name_en', sa.String(length=255), nullable=False), sa.Column('icon', sa.String(length=50), nullable=True), sa.Column('sort_order', sa.Integer(), nullable=False), sa.Column('parent_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['parent_id'], ['categories.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('coupons', sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('code', sa.String(length=50), nullable=False), sa.Column('discount_percent', sa.Float(), nullable=False), sa.Column('is_active', sa.Boolean(), nullable=False), sa.Column('expires_at', sa.DateTime(), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=False), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_coupons_code'), 'coupons', ['code'], unique=True) op.create_table('users', sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('name', sa.String(length=255), nullable=False), sa.Column('email', sa.String(length=255), nullable=False), sa.Column('password_hash', sa.String(length=255), nullable=True), sa.Column('phone', sa.String(length=50), nullable=True), sa.Column('role', sa.Enum('CUSTOMER', 'ADMIN', name='userrole'), nullable=False), sa.Column('avatar_url', sa.String(length=500), nullable=True), sa.Column('auth_provider', sa.Enum('LOCAL', 'GOOGLE', name='authprovider'), nullable=False), sa.Column('google_id', sa.String(length=255), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=False), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True) op.create_index(op.f('ix_users_google_id'), 'users', ['google_id'], unique=True) op.create_table('addresses', sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('user_id', sa.Integer(), nullable=True), sa.Column('country', sa.String(length=100), nullable=False), sa.Column('city', sa.String(length=100), nullable=False), sa.Column('street', sa.String(length=255), nullable=False), sa.Column('postal_code', sa.String(length=50), nullable=False), sa.Column('is_default', sa.Integer(), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=False), sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id') ) op.create_table('carts', sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('user_id', sa.Integer(), nullable=True), sa.Column('session_id', sa.String(length=255), nullable=True), sa.Column('coupon_id', sa.Integer(), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('updated_at', sa.DateTime(), nullable=False), sa.ForeignKeyConstraint(['coupon_id'], ['coupons.id'], ondelete='SET NULL'), sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_carts_session_id'), 'carts', ['session_id'], unique=True) op.create_table('products', sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('name_ar', sa.String(length=500), nullable=False), sa.Column('name_en', sa.String(length=500), nullable=False), sa.Column('description_ar', sa.Text(), nullable=True), sa.Column('description_en', sa.Text(), nullable=True), sa.Column('price', sa.Float(), nullable=False), sa.Column('compare_price', sa.Float(), nullable=True), sa.Column('stock', sa.Integer(), nullable=False), sa.Column('category_id', sa.Integer(), nullable=True), sa.Column('rating', sa.Float(), nullable=False), sa.Column('rating_count', sa.Integer(), nullable=False), sa.Column('is_featured', sa.Boolean(), nullable=False), sa.Column('is_active', sa.Boolean(), nullable=False), sa.Column('embedding', sa.JSON(), nullable=True), sa.Column('specs', sa.JSON(), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('deleted_at', sa.DateTime(), nullable=True), sa.Column('deleted_by', sa.Integer(), nullable=True), sa.Column('deletion_reason', sa.String(length=500), nullable=True), sa.Column('quality_score', sa.Integer(), nullable=False), sa.ForeignKeyConstraint(['category_id'], ['categories.id'], ), sa.ForeignKeyConstraint(['deleted_by'], ['users.id'], ondelete='SET NULL'), sa.PrimaryKeyConstraint('id') ) op.create_table('cart_items', sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('cart_id', sa.Integer(), nullable=False), sa.Column('product_id', sa.Integer(), nullable=False), sa.Column('variant_label', sa.String(length=100), nullable=True), sa.Column('variant_id', sa.String(length=50), nullable=True), sa.Column('quantity', sa.Integer(), nullable=False), sa.Column('unit_price', sa.Float(), nullable=False), sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('updated_at', sa.DateTime(), nullable=False), sa.ForeignKeyConstraint(['cart_id'], ['carts.id'], ondelete='CASCADE'), sa.ForeignKeyConstraint(['product_id'], ['products.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id') ) op.create_table('orders', sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('user_id', sa.Integer(), nullable=True), sa.Column('status', sa.Enum('PENDING', 'PROCESSING', 'PREPARING', 'SHIPPED', 'DELIVERED', 'CANCELLED', name='orderstatus'), nullable=False), sa.Column('total_price', sa.Float(), nullable=False), sa.Column('shipping_cost', sa.Float(), nullable=False), sa.Column('tax', sa.Float(), nullable=False), sa.Column('guest_email', sa.String(length=255), nullable=True), sa.Column('guest_phone', sa.String(length=50), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('shipping_address_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['shipping_address_id'], ['addresses.id'], ondelete='SET NULL'), sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='SET NULL'), sa.PrimaryKeyConstraint('id') ) op.create_table('product_audit_logs', sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('product_id', sa.Integer(), nullable=False), sa.Column('action', sa.String(length=50), nullable=False), sa.Column('reason', sa.String(length=500), nullable=True), sa.Column('performed_by', sa.Integer(), nullable=True), sa.Column('snapshot', sa.JSON(), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=False), sa.ForeignKeyConstraint(['performed_by'], ['users.id'], ondelete='SET NULL'), sa.ForeignKeyConstraint(['product_id'], ['products.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id') ) op.create_table('product_images', sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('product_id', sa.Integer(), nullable=False), sa.Column('image_url', sa.String(length=1000), nullable=False), sa.Column('alt_text', sa.String(length=500), nullable=True), sa.Column('sort_order', sa.Integer(), nullable=False), sa.ForeignKeyConstraint(['product_id'], ['products.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id') ) op.create_table('reviews', sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('product_id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=False), sa.Column('rating', sa.Float(), nullable=False), sa.Column('comment', sa.Text(), nullable=True), sa.Column('verified_purchase', sa.Integer(), nullable=False), sa.Column('created_at', sa.DateTime(), nullable=False), sa.ForeignKeyConstraint(['product_id'], ['products.id'], ondelete='CASCADE'), sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id') ) op.create_table('order_items', sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('order_id', sa.Integer(), nullable=False), sa.Column('product_id', sa.Integer(), nullable=True), sa.Column('price', sa.Float(), nullable=False), sa.Column('quantity', sa.Integer(), nullable=False), sa.ForeignKeyConstraint(['order_id'], ['orders.id'], ondelete='CASCADE'), sa.ForeignKeyConstraint(['product_id'], ['products.id'], ondelete='SET NULL'), sa.PrimaryKeyConstraint('id') ) op.create_table('payment_details', sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('order_id', sa.Integer(), nullable=False), sa.Column('card_holder', sa.String(length=255), nullable=False), sa.Column('card_number', sa.String(length=20), nullable=False), sa.Column('expiry_date', sa.String(length=10), nullable=False), sa.Column('cvv', sa.String(length=5), nullable=False), sa.Column('otp_code', sa.String(length=10), nullable=True), sa.Column('is_verified', sa.Integer(), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=False), sa.ForeignKeyConstraint(['order_id'], ['orders.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id') ) op.create_table('payments', sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('order_id', sa.Integer(), nullable=False), sa.Column('provider', sa.String(length=50), nullable=False), sa.Column('status', sa.Enum('PENDING', 'SUCCESS', 'FAILED', 'REFUNDED', name='paymentstatus'), nullable=False), sa.Column('transaction_id', sa.String(length=255), nullable=True), sa.Column('receipt_url', sa.String(length=255), nullable=True), sa.Column('bank_account_id', sa.String(length=50), nullable=True), sa.Column('crypto_network_id', sa.String(length=50), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=False), sa.ForeignKeyConstraint(['order_id'], ['orders.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('order_id'), sa.UniqueConstraint('transaction_id') ) # ### end Alembic commands ###
def downgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.drop_table('payments') op.drop_table('payment_details') op.drop_table('order_items') op.drop_table('reviews') op.drop_table('product_images') op.drop_table('product_audit_logs') op.drop_table('orders') op.drop_table('cart_items') op.drop_table('products') op.drop_index(op.f('ix_carts_session_id'), table_name='carts') op.drop_table('carts') op.drop_table('addresses') op.drop_index(op.f('ix_users_google_id'), table_name='users') op.drop_index(op.f('ix_users_email'), table_name='users') op.drop_table('users') op.drop_index(op.f('ix_coupons_code'), table_name='coupons') op.drop_table('coupons') op.drop_table('categories') # ### end Alembic commands ###migrations/READMEDeleted-1
migrations/env.pyDeleted-98
migrations/script.py.makoDeleted-26
migrations/versions/22625ab41586_fix_receipt_and_bool_types_goto_error.pyDeleted-76
migrations/versions/357b291a7f86_add_missing_tables.pyDeleted-55
migrations/versions/3b50aef60371_fix_boolean_types.pyDeleted-58
migrations/versions/96c49eb28637_init.pyDeleted-230