refac
This commit is contained in:
1 parent
6b1df94bf9
commit
98d3b23085
2 files changed
+24
-34
No files matched your search
@@ -16,6 +16,11 @@ depends_on = None
|
|||||||
|
|
||||||
|
|
||||||
def upgrade():
|
def upgrade():
|
||||||
|
conn = op.get_bind()
|
||||||
|
inspector = sa.inspect(conn)
|
||||||
|
existing_tables = set(inspector.get_table_names())
|
||||||
|
|
||||||
|
if 'group' not in existing_tables:
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'group',
|
'group',
|
||||||
sa.Column('id', sa.Text(), nullable=False, primary_key=True, unique=True),
|
sa.Column('id', sa.Text(), nullable=False, primary_key=True, unique=True),
|
||||||
@@ -31,55 +36,35 @@ def upgrade():
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Add 'access_control' column to 'model' table
|
# Add 'access_control' column to 'model' table
|
||||||
|
model_cols = {c['name'] for c in inspector.get_columns('model')}
|
||||||
|
if 'access_control' not in model_cols:
|
||||||
|
op.add_column('model', sa.Column('access_control', sa.JSON(), nullable=True))
|
||||||
|
if 'is_active' not in model_cols:
|
||||||
op.add_column(
|
op.add_column(
|
||||||
'model',
|
'model',
|
||||||
sa.Column('access_control', sa.JSON(), nullable=True),
|
sa.Column('is_active', sa.Boolean(), nullable=False, server_default=sa.sql.expression.true()),
|
||||||
)
|
|
||||||
|
|
||||||
# Add 'is_active' column to 'model' table
|
|
||||||
op.add_column(
|
|
||||||
'model',
|
|
||||||
sa.Column(
|
|
||||||
'is_active',
|
|
||||||
sa.Boolean(),
|
|
||||||
nullable=False,
|
|
||||||
server_default=sa.sql.expression.true(),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add 'access_control' column to 'knowledge' table
|
# Add 'access_control' column to 'knowledge' table
|
||||||
op.add_column(
|
knowledge_cols = {c['name'] for c in inspector.get_columns('knowledge')}
|
||||||
'knowledge',
|
if 'access_control' not in knowledge_cols:
|
||||||
sa.Column('access_control', sa.JSON(), nullable=True),
|
op.add_column('knowledge', sa.Column('access_control', sa.JSON(), nullable=True))
|
||||||
)
|
|
||||||
|
|
||||||
# Add 'access_control' column to 'prompt' table
|
# Add 'access_control' column to 'prompt' table
|
||||||
op.add_column(
|
prompt_cols = {c['name'] for c in inspector.get_columns('prompt')}
|
||||||
'prompt',
|
if 'access_control' not in prompt_cols:
|
||||||
sa.Column('access_control', sa.JSON(), nullable=True),
|
op.add_column('prompt', sa.Column('access_control', sa.JSON(), nullable=True))
|
||||||
)
|
|
||||||
|
|
||||||
# Add 'access_control' column to 'tools' table
|
# Add 'access_control' column to 'tools' table
|
||||||
op.add_column(
|
tool_cols = {c['name'] for c in inspector.get_columns('tool')}
|
||||||
'tool',
|
if 'access_control' not in tool_cols:
|
||||||
sa.Column('access_control', sa.JSON(), nullable=True),
|
op.add_column('tool', sa.Column('access_control', sa.JSON(), nullable=True))
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
op.drop_table('group')
|
op.drop_table('group')
|
||||||
|
|
||||||
# Drop 'access_control' column from 'model' table
|
|
||||||
op.drop_column('model', 'access_control')
|
op.drop_column('model', 'access_control')
|
||||||
|
|
||||||
# Drop 'is_active' column from 'model' table
|
|
||||||
op.drop_column('model', 'is_active')
|
op.drop_column('model', 'is_active')
|
||||||
|
|
||||||
# Drop 'access_control' column from 'knowledge' table
|
|
||||||
op.drop_column('knowledge', 'access_control')
|
op.drop_column('knowledge', 'access_control')
|
||||||
|
|
||||||
# Drop 'access_control' column from 'prompt' table
|
|
||||||
op.drop_column('prompt', 'access_control')
|
op.drop_column('prompt', 'access_control')
|
||||||
|
|
||||||
# Drop 'access_control' column from 'tools' table
|
|
||||||
op.drop_column('tool', 'access_control')
|
op.drop_column('tool', 'access_control')
|
||||||
@@ -16,6 +16,11 @@ depends_on = None
|
|||||||
|
|
||||||
|
|
||||||
def upgrade():
|
def upgrade():
|
||||||
|
conn = op.get_bind()
|
||||||
|
inspector = sa.inspect(conn)
|
||||||
|
existing_tables = set(inspector.get_table_names())
|
||||||
|
|
||||||
|
if 'note' not in existing_tables:
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'note',
|
'note',
|
||||||
sa.Column('id', sa.Text(), nullable=False, primary_key=True, unique=True),
|
sa.Column('id', sa.Text(), nullable=False, primary_key=True, unique=True),
|
||||||
|
|||||||
Reference in new issue
Block a user