From 5ca62391614fc3b7e155d4ee5e19a5a5505f92a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= Date: Tue, 23 Apr 2024 07:41:23 +0200 Subject: [PATCH] migration --- migrations/versions/51de7be0564a_.py | 46 ++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 migrations/versions/51de7be0564a_.py diff --git a/migrations/versions/51de7be0564a_.py b/migrations/versions/51de7be0564a_.py new file mode 100644 index 00000000..bf5d71b5 --- /dev/null +++ b/migrations/versions/51de7be0564a_.py @@ -0,0 +1,46 @@ +"""empty message + +Revision ID: 51de7be0564a +Revises: 3b95f1f53d17 +Create Date: 2024-04-22 17:26:44.675531 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '51de7be0564a' +down_revision = '3b95f1f53d17' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('praktici_kapacity', schema=None) as batch_op: + batch_op.add_column(sa.Column('aktivni', sa.Boolean(), nullable=True)) + + op.execute("UPDATE praktici_kapacity SET aktivni = coalesce(praktici_kapacity.expirace > now(), true) and pocet_davek > 0") + + with op.batch_alter_table('praktici_kapacity', schema=None) as batch_op: + batch_op.alter_column('aktivni', nullable=False) + + with op.batch_alter_table('praktici_login', schema=None) as batch_op: + batch_op.add_column(sa.Column('neregistrovani', sa.Boolean(), nullable=True)) + + op.execute("UPDATE praktici_login SET neregistrovani = False") + + with op.batch_alter_table('praktici_login', schema=None) as batch_op: + batch_op.alter_column('neregistrovani', nullable=False) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('praktici_login', schema=None) as batch_op: + batch_op.drop_column('neregistrovani') + + with op.batch_alter_table('praktici_kapacity', schema=None) as batch_op: + batch_op.drop_column('aktivni') + # ### end Alembic commands ###