"""add_persons_tables Revision ID: 20250120_000001 Revises: 5553f8745c6e Create Date: 2025-01-20 00:00:00.000000 """ from alembic import op import sqlalchemy as sa from sqlalchemy.dialects import mysql # revision identifiers, used by Alembic. revision = '20250120_000001' down_revision = '5553f8745c6e' branch_labels = None depends_on = None def upgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### # Create persons table op.create_table('persons', sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('business_id', sa.Integer(), nullable=False, comment='شناسه کسب و کار'), sa.Column('alias_name', sa.String(length=255), nullable=False, comment='نام مستعار (الزامی)'), sa.Column('first_name', sa.String(length=100), nullable=True, comment='نام'), sa.Column('last_name', sa.String(length=100), nullable=True, comment='نام خانوادگی'), sa.Column('person_type', sa.Enum('CUSTOMER', 'MARKETER', 'EMPLOYEE', 'SUPPLIER', 'PARTNER', 'SELLER', name='persontype'), nullable=False, comment='نوع شخص'), sa.Column('company_name', sa.String(length=255), nullable=True, comment='نام شرکت'), sa.Column('payment_id', sa.String(length=100), nullable=True, comment='شناسه پرداخت'), sa.Column('national_id', sa.String(length=20), nullable=True, comment='شناسه ملی'), sa.Column('registration_number', sa.String(length=50), nullable=True, comment='شماره ثبت'), sa.Column('economic_id', sa.String(length=50), nullable=True, comment='شناسه اقتصادی'), sa.Column('country', sa.String(length=100), nullable=True, comment='کشور'), sa.Column('province', sa.String(length=100), nullable=True, comment='استان'), sa.Column('city', sa.String(length=100), nullable=True, comment='شهرستان'), sa.Column('address', sa.Text(), nullable=True, comment='آدرس'), sa.Column('postal_code', sa.String(length=20), nullable=True, comment='کد پستی'), sa.Column('phone', sa.String(length=20), nullable=True, comment='تلفن'), sa.Column('mobile', sa.String(length=20), nullable=True, comment='موبایل'), sa.Column('fax', sa.String(length=20), nullable=True, comment='فکس'), sa.Column('email', sa.String(length=255), nullable=True, comment='پست الکترونیکی'), sa.Column('website', sa.String(length=255), nullable=True, comment='وب‌سایت'), sa.Column('is_active', sa.Boolean(), nullable=False, comment='وضعیت فعال بودن'), sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('updated_at', sa.DateTime(), nullable=False), sa.ForeignKeyConstraint(['business_id'], ['businesses.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_persons_business_id'), 'persons', ['business_id'], unique=False) op.create_index(op.f('ix_persons_alias_name'), 'persons', ['alias_name'], unique=False) op.create_index(op.f('ix_persons_national_id'), 'persons', ['national_id'], unique=False) # Create person_bank_accounts table op.create_table('person_bank_accounts', sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('person_id', sa.Integer(), nullable=False, comment='شناسه شخص'), sa.Column('bank_name', sa.String(length=255), nullable=False, comment='نام بانک'), sa.Column('account_number', sa.String(length=50), nullable=True, comment='شماره حساب'), sa.Column('card_number', sa.String(length=20), nullable=True, comment='شماره کارت'), sa.Column('sheba_number', sa.String(length=30), nullable=True, comment='شماره شبا'), sa.Column('is_active', sa.Boolean(), nullable=False, comment='وضعیت فعال بودن'), sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('updated_at', sa.DateTime(), nullable=False), sa.ForeignKeyConstraint(['person_id'], ['persons.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_person_bank_accounts_person_id'), 'person_bank_accounts', ['person_id'], unique=False) # ### end Alembic commands ### def downgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.drop_index(op.f('ix_person_bank_accounts_person_id'), table_name='person_bank_accounts') op.drop_table('person_bank_accounts') op.drop_index(op.f('ix_persons_national_id'), table_name='persons') op.drop_index(op.f('ix_persons_alias_name'), table_name='persons') op.drop_index(op.f('ix_persons_business_id'), table_name='persons') op.drop_table('persons') # ### end Alembic commands ###