add contacts and address to database
This commit is contained in:
1533
alembic/versions/01691d3fa96a_initial_tables.py
Normal file
1533
alembic/versions/01691d3fa96a_initial_tables.py
Normal file
File diff suppressed because it is too large
Load Diff
60
alembic/versions/c151f5abb66d_add_contacts_and_address.py
Normal file
60
alembic/versions/c151f5abb66d_add_contacts_and_address.py
Normal file
@@ -0,0 +1,60 @@
|
||||
"""add contacts and address
|
||||
|
||||
Revision ID: c151f5abb66d
|
||||
Revises: 01691d3fa96a
|
||||
Create Date: 2025-10-01 18:58:32.345910
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'c151f5abb66d'
|
||||
down_revision: Union[str, Sequence[str], None] = '01691d3fa96a'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('address',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.Column('country', sa.String(), nullable=False),
|
||||
sa.Column('region', sa.String(), nullable=False),
|
||||
sa.Column('locality', sa.String(), nullable=False),
|
||||
sa.Column('street_address', sa.String(), nullable=False),
|
||||
sa.Column('extended_address', sa.String(), nullable=False),
|
||||
sa.Column('postal_code', sa.String(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('contact',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.Column('type', sa.String(), nullable=False),
|
||||
sa.Column('value', sa.String(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.alter_column('user', 'tg_id',
|
||||
existing_type=sa.BIGINT(),
|
||||
nullable=True)
|
||||
op.drop_column('user', 'address')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('user', sa.Column('address', sa.VARCHAR(), autoincrement=False, nullable=True))
|
||||
op.alter_column('user', 'tg_id',
|
||||
existing_type=sa.BIGINT(),
|
||||
nullable=False)
|
||||
op.drop_table('contact')
|
||||
op.drop_table('address')
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user