def upgrade(): # NOTE(rakhmerov): We have to check if the table already # exists and drop it, if needed. This is because the DB # model for scheduled jobs was released w/o a migration # in the first place, so for some users the table was # created automatically at Mistral run based on the model. # But the structure of the table is old so we need to # recreate it anyway in this migration. It's safe to drop # this table because it contains temporary data. inspect = reflection.Inspector.from_engine(op.get_bind()) if 'scheduled_jobs_v2' in inspect.get_table_names(): op.drop_table('scheduled_jobs_v2') op.create_table( 'scheduled_jobs_v2', sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('id', sa.String(length=36), nullable=False), sa.Column('run_after', sa.Integer(), nullable=True), sa.Column( 'target_factory_func_name', sa.String(length=200), nullable=True ), sa.Column('func_name', sa.String(length=80), nullable=True), sa.Column('func_args', st.JsonEncoded(), nullable=True), sa.Column('func_arg_serializers', st.JsonEncoded(), nullable=True), sa.Column('auth_ctx', st.JsonEncoded(), nullable=True), sa.Column('execute_at', sa.DateTime(), nullable=False), sa.Column('captured_at', sa.DateTime(), nullable=True), sa.Column('key', sa.String(length=250), nullable=True), sa.PrimaryKeyConstraint('id'), )
def upgrade(): op.create_table( 'event_triggers_v2', sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('project_id', sa.String(length=80), nullable=True), sa.Column('scope', sa.String(length=80), nullable=True), sa.Column('id', sa.String(length=36), nullable=False), sa.Column('name', sa.String(length=200), nullable=True), sa.Column('workflow_id', sa.String(length=36), nullable=False), sa.Column('exchange', sa.String(length=80), nullable=False), sa.Column('topic', sa.String(length=80), nullable=False), sa.Column('event', sa.String(length=80), nullable=False), sa.Column('workflow_params', st.JsonEncoded(), nullable=True), sa.Column('workflow_input', st.JsonEncoded(), nullable=True), sa.Column('trust_id', sa.String(length=80), nullable=True), sa.ForeignKeyConstraint( ['workflow_id'], ['workflow_definitions_v2.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint( 'exchange', 'topic', 'event', 'workflow_id', 'project_id' ), sa.Index( 'event_triggers_v2_project_id_workflow_id', 'project_id', 'workflow_id' ) )
def upgrade(): op.drop_table('tasks') op.drop_table('workflow_executions') op.drop_table('workbooks') op.drop_table('triggers') op.add_column( 'cron_triggers_v2', sa.Column('workflow_params', st.JsonEncoded(), nullable=True) ) op.add_column( 'cron_triggers_v2', sa.Column('workflow_params_hash', sa.CHAR(length=64), nullable=True) ) op.create_unique_constraint( None, 'cron_triggers_v2', ['workflow_input_hash', 'workflow_name', 'pattern', 'project_id', 'workflow_params_hash'] )
def upgrade(): op.create_table( 'code_sources', sa.Column('id', sa.String(length=36), nullable=False), sa.Column('name', sa.String(length=255), nullable=False), sa.Column('project_id', sa.String(length=80), nullable=True), sa.Column('namespace', sa.String(length=255), nullable=True), sa.Column('content', sa.TEXT, nullable=False), sa.Column('version', sa.Integer, nullable=False), sa.Column('tags', st.JsonEncoded(), nullable=True), sa.Column('scope', sa.String(length=80), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name', 'namespace', 'project_id'), sa.Index('code_sources_project_id', 'project_id'), sa.Index('code_sources_scope', 'scope')) op.create_table( 'dynamic_action_definitions', sa.Column('id', sa.String(length=36), nullable=False), sa.Column('name', sa.String(length=255), nullable=False), sa.Column('class_name', sa.String(length=255), nullable=False), sa.Column('scope', sa.String(length=80), nullable=True), sa.Column('project_id', sa.String(length=80), nullable=True), sa.Column('code_source_id', sa.String(length=36), nullable=False), sa.Column('code_source_name', sa.String(length=255), nullable=False), sa.Column('namespace', sa.String(length=255), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.ForeignKeyConstraint(['code_source_id'], ['code_sources.id'], ondelete='CASCADE'), sa.UniqueConstraint('name', 'namespace', 'project_id'), sa.Index('dynamic_action_definitions_project_id', 'project_id'), sa.Index('dynamic_action_definitions_scope', 'scope'), )
def upgrade(): op.create_table( 'workbooks_v2', sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('scope', sa.String(length=80), nullable=True), sa.Column('project_id', sa.String(length=80), nullable=True), sa.Column('id', sa.String(length=36), nullable=False), sa.Column('name', sa.String(length=80), nullable=True), sa.Column('definition', sa.Text(), nullable=True), sa.Column('spec', st.JsonEncoded(), nullable=True), sa.Column('tags', st.JsonEncoded(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name', 'project_id')) op.create_table( 'tasks', sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('id', sa.String(length=36), nullable=False), sa.Column('name', sa.String(length=80), nullable=True), sa.Column('requires', st.JsonEncoded(), nullable=True), sa.Column('workbook_name', sa.String(length=80), nullable=True), sa.Column('execution_id', sa.String(length=36), nullable=True), sa.Column('description', sa.String(length=200), nullable=True), sa.Column('task_spec', st.JsonEncoded(), nullable=True), sa.Column('action_spec', st.JsonEncoded(), nullable=True), sa.Column('state', sa.String(length=20), nullable=True), sa.Column('tags', st.JsonEncoded(), nullable=True), sa.Column('in_context', st.JsonEncoded(), nullable=True), sa.Column('parameters', st.JsonEncoded(), nullable=True), sa.Column('output', st.JsonEncoded(), nullable=True), sa.Column('task_runtime_context', st.JsonEncoded(), nullable=True), sa.PrimaryKeyConstraint('id')) op.create_table( 'action_definitions_v2', sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('scope', sa.String(length=80), nullable=True), sa.Column('project_id', sa.String(length=80), nullable=True), sa.Column('id', sa.String(length=36), nullable=False), sa.Column('name', sa.String(length=80), nullable=True), sa.Column('definition', sa.Text(), nullable=True), sa.Column('spec', st.JsonEncoded(), nullable=True), sa.Column('tags', st.JsonEncoded(), nullable=True), sa.Column('description', sa.Text(), nullable=True), sa.Column('input', sa.Text(), nullable=True), sa.Column('action_class', sa.String(length=200), nullable=True), sa.Column('attributes', st.JsonEncoded(), nullable=True), sa.Column('is_system', sa.Boolean(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name', 'project_id')) op.create_table( 'workflow_definitions_v2', sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('scope', sa.String(length=80), nullable=True), sa.Column('project_id', sa.String(length=80), nullable=True), sa.Column('id', sa.String(length=36), nullable=False), sa.Column('name', sa.String(length=80), nullable=True), sa.Column('definition', sa.Text(), nullable=True), sa.Column('spec', st.JsonEncoded(), nullable=True), sa.Column('tags', st.JsonEncoded(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name', 'project_id')) op.create_table( 'executions_v2', sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('scope', sa.String(length=80), nullable=True), sa.Column('project_id', sa.String(length=80), nullable=True), sa.Column('type', sa.String(length=50), nullable=True), sa.Column('id', sa.String(length=36), nullable=False), sa.Column('name', sa.String(length=80), nullable=True), sa.Column('workflow_name', sa.String(length=80), nullable=True), sa.Column('spec', st.JsonEncoded(), nullable=True), sa.Column('state', sa.String(length=20), nullable=True), sa.Column('state_info', sa.String(length=1024), nullable=True), sa.Column('tags', st.JsonEncoded(), nullable=True), sa.Column('accepted', sa.Boolean(), nullable=True), sa.Column('input', st.JsonEncoded(), nullable=True), sa.Column('output', st.JsonLongDictType(), nullable=True), sa.Column('params', st.JsonEncoded(), nullable=True), sa.Column('context', st.JsonEncoded(), nullable=True), sa.Column('action_spec', st.JsonEncoded(), nullable=True), sa.Column('processed', sa.BOOLEAN(), nullable=True), sa.Column('in_context', st.JsonLongDictType(), nullable=True), sa.Column('published', st.JsonEncoded(), nullable=True), sa.Column('runtime_context', st.JsonEncoded(), nullable=True), sa.Column('task_execution_id', sa.String(length=36), nullable=True), sa.Column('workflow_execution_id', sa.String(length=36), nullable=True), sa.ForeignKeyConstraint( ['task_execution_id'], ['executions_v2.id'], ), sa.ForeignKeyConstraint( ['workflow_execution_id'], ['executions_v2.id'], ), sa.PrimaryKeyConstraint('id')) op.create_table( 'workbooks', sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('id', sa.String(length=36), nullable=False), sa.Column('name', sa.String(length=80), nullable=False), sa.Column('definition', sa.Text(), nullable=True), sa.Column('description', sa.String(length=200), nullable=True), sa.Column('tags', st.JsonEncoded(), nullable=True), sa.Column('scope', sa.String(length=80), nullable=True), sa.Column('project_id', sa.String(length=80), nullable=True), sa.Column('trust_id', sa.String(length=80), nullable=True), sa.PrimaryKeyConstraint('id', 'name'), sa.UniqueConstraint('name')) op.create_table( 'environments_v2', sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('scope', sa.String(length=80), nullable=True), sa.Column('project_id', sa.String(length=80), nullable=True), sa.Column('id', sa.String(length=36), nullable=False), sa.Column('name', sa.String(length=200), nullable=True), sa.Column('description', sa.Text(), nullable=True), sa.Column('variables', st.JsonEncoded(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name', 'project_id')) op.create_table( 'triggers', sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('id', sa.String(length=36), nullable=False), sa.Column('name', sa.String(length=80), nullable=False), sa.Column('pattern', sa.String(length=20), nullable=False), sa.Column('next_execution_time', sa.DateTime(), nullable=False), sa.Column('workbook_name', sa.String(length=80), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name')) op.create_table( 'delayed_calls_v2', sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('id', sa.String(length=36), nullable=False), sa.Column('factory_method_path', sa.String(length=200), nullable=True), sa.Column('target_method_name', sa.String(length=80), nullable=False), sa.Column('method_arguments', st.JsonEncoded(), nullable=True), sa.Column('serializers', st.JsonEncoded(), nullable=True), sa.Column('auth_context', st.JsonEncoded(), nullable=True), sa.Column('execution_time', sa.DateTime(), nullable=False), sa.PrimaryKeyConstraint('id')) op.create_table( 'workflow_executions', sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('id', sa.String(length=36), nullable=False), sa.Column('workbook_name', sa.String(length=80), nullable=True), sa.Column('task', sa.String(length=80), nullable=True), sa.Column('state', sa.String(length=20), nullable=True), sa.Column('context', st.JsonEncoded(), nullable=True), sa.PrimaryKeyConstraint('id')) op.create_table( 'cron_triggers_v2', sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('scope', sa.String(length=80), nullable=True), sa.Column('project_id', sa.String(length=80), nullable=True), sa.Column('id', sa.String(length=36), nullable=False), sa.Column('name', sa.String(length=200), nullable=True), sa.Column('pattern', sa.String(length=100), nullable=True), sa.Column('next_execution_time', sa.DateTime(), nullable=False), sa.Column('workflow_name', sa.String(length=80), nullable=True), sa.Column('remaining_executions', sa.Integer(), nullable=True), sa.Column('workflow_id', sa.String(length=36), nullable=True), sa.Column('workflow_input', st.JsonEncoded(), nullable=True), sa.Column('workflow_input_hash', sa.CHAR(length=64), nullable=True), sa.Column('trust_id', sa.String(length=80), nullable=True), sa.ForeignKeyConstraint( ['workflow_id'], ['workflow_definitions_v2.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name', 'project_id'), sa.UniqueConstraint('workflow_input_hash', 'workflow_name', 'pattern', 'project_id'))