Skip to content

Commit

Permalink
Merge pull request #830 from jan-stanek/migration
Browse files Browse the repository at this point in the history
Zapomenutá migrace
  • Loading branch information
msusicky authored Apr 23, 2024
2 parents 62be08a + 5ca6239 commit 3dcec9b
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions migrations/versions/51de7be0564a_.py
Original file line number Diff line number Diff line change
@@ -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 ###

0 comments on commit 3dcec9b

Please sign in to comment.