This commit is contained in:
Kenneth Kehl
2023-08-29 14:54:30 -07:00
parent 19dcd7a48b
commit 1ecb747c6d
588 changed files with 34100 additions and 23589 deletions

View File

@@ -7,48 +7,69 @@ Create Date: 2016-05-16 13:55:27.179748
"""
# revision identifiers, used by Alembic.
revision = '0015_fix_template_data'
down_revision = '0014_add_template_version'
revision = "0015_fix_template_data"
down_revision = "0014_add_template_version"
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.get_bind()
query = 'update templates_history set created_by_id = ' \
'(select created_by_id from templates where templates.id = templates_history.id) ' \
'where created_by_id is null'
query = (
"update templates_history set created_by_id = "
"(select created_by_id from templates where templates.id = templates_history.id) "
"where created_by_id is null"
)
op.execute(query)
op.execute('update templates_history set archived = False')
op.alter_column('api_keys_history', 'created_at',
existing_type=postgresql.TIMESTAMP(),
nullable=False)
op.alter_column('api_keys_history', 'created_by_id',
existing_type=postgresql.UUID(),
nullable=False)
op.alter_column('templates_history', 'archived',
existing_type=sa.BOOLEAN(),
nullable=False)
op.alter_column('templates_history', 'created_by_id',
existing_type=postgresql.UUID(),
nullable=False)
op.execute("update templates_history set archived = False")
op.alter_column(
"api_keys_history",
"created_at",
existing_type=postgresql.TIMESTAMP(),
nullable=False,
)
op.alter_column(
"api_keys_history",
"created_by_id",
existing_type=postgresql.UUID(),
nullable=False,
)
op.alter_column(
"templates_history", "archived", existing_type=sa.BOOLEAN(), nullable=False
)
op.alter_column(
"templates_history",
"created_by_id",
existing_type=postgresql.UUID(),
nullable=False,
)
### end Alembic commands ###
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.alter_column('templates_history', 'created_by_id',
existing_type=postgresql.UUID(),
nullable=True)
op.alter_column('templates_history', 'archived',
existing_type=sa.BOOLEAN(),
nullable=True)
op.alter_column('api_keys_history', 'created_by_id',
existing_type=postgresql.UUID(),
nullable=True)
op.alter_column('api_keys_history', 'created_at',
existing_type=postgresql.TIMESTAMP(),
nullable=True)
op.alter_column(
"templates_history",
"created_by_id",
existing_type=postgresql.UUID(),
nullable=True,
)
op.alter_column(
"templates_history", "archived", existing_type=sa.BOOLEAN(), nullable=True
)
op.alter_column(
"api_keys_history",
"created_by_id",
existing_type=postgresql.UUID(),
nullable=True,
)
op.alter_column(
"api_keys_history",
"created_at",
existing_type=postgresql.TIMESTAMP(),
nullable=True,
)
### end Alembic commands ###