51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
"""Add contact fields to User model
|
|
|
|
Revision ID: 43dfd2543fad
|
|
Revises: dbcb5d2d3ed0
|
|
Create Date: 2025-05-23 09:24:23.926302
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from sqlalchemy import inspect
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '43dfd2543fad'
|
|
down_revision = 'dbcb5d2d3ed0'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
conn = op.get_bind()
|
|
inspector = inspect(conn)
|
|
columns = [col['name'] for col in inspector.get_columns('user')]
|
|
|
|
with op.batch_alter_table('user', schema=None) as batch_op:
|
|
if 'phone' not in columns:
|
|
batch_op.add_column(sa.Column('phone', sa.String(length=20), nullable=True))
|
|
if 'company' not in columns:
|
|
batch_op.add_column(sa.Column('company', sa.String(length=100), nullable=True))
|
|
if 'position' not in columns:
|
|
batch_op.add_column(sa.Column('position', sa.String(length=100), nullable=True))
|
|
if 'notes' not in columns:
|
|
batch_op.add_column(sa.Column('notes', sa.Text(), nullable=True))
|
|
if 'is_active' not in columns:
|
|
batch_op.add_column(sa.Column('is_active', sa.Boolean(), nullable=True))
|
|
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
with op.batch_alter_table('user', schema=None) as batch_op:
|
|
batch_op.drop_column('is_active')
|
|
batch_op.drop_column('notes')
|
|
batch_op.drop_column('position')
|
|
batch_op.drop_column('company')
|
|
batch_op.drop_column('phone')
|
|
|
|
# ### end Alembic commands ###
|