65 lines
2.4 KiB
Python
65 lines
2.4 KiB
Python
"""Add UserHomepageConfig, UserFavoriteAgent, UserDefaultAgent and Update Department
|
|
|
|
Revision ID: f0f24c20e91a
|
|
Revises: 60b4aee3ad2d
|
|
Create Date: 2026-02-23 21:13:19.814958
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = 'f0f24c20e91a'
|
|
down_revision = '60b4aee3ad2d'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('user_default_agents',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
|
sa.Column('agent_id', sa.Integer(), nullable=False),
|
|
sa.Column('sort_order', sa.Integer(), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(), nullable=False),
|
|
sa.ForeignKeyConstraint(['agent_id'], ['agents.id'], ),
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_table('user_favorite_agents',
|
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
|
sa.Column('agent_id', sa.Integer(), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(), nullable=False),
|
|
sa.ForeignKeyConstraint(['agent_id'], ['agents.id'], ),
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
|
sa.PrimaryKeyConstraint('user_id', 'agent_id')
|
|
)
|
|
op.create_table('user_homepage_configs',
|
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
|
sa.Column('layout', sa.JSON(), nullable=False),
|
|
sa.Column('updated_at', sa.DateTime(), nullable=False),
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
|
sa.PrimaryKeyConstraint('user_id')
|
|
)
|
|
with op.batch_alter_table('departments', schema=None) as batch_op:
|
|
batch_op.add_column(sa.Column('code', sa.String(length=50), nullable=True))
|
|
batch_op.add_column(sa.Column('company', sa.String(length=100), nullable=True))
|
|
batch_op.create_unique_constraint(None, ['code'])
|
|
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
with op.batch_alter_table('departments', schema=None) as batch_op:
|
|
batch_op.drop_constraint(None, type_='unique')
|
|
batch_op.drop_column('company')
|
|
batch_op.drop_column('code')
|
|
|
|
op.drop_table('user_homepage_configs')
|
|
op.drop_table('user_favorite_agents')
|
|
op.drop_table('user_default_agents')
|
|
# ### end Alembic commands ###
|