mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 17:01:35 -05:00
Migration script to add template version to jobs and notifications.
This commit is contained in:
29
migrations/versions/0013_add_template_version.py
Normal file
29
migrations/versions/0013_add_template_version.py
Normal file
@@ -0,0 +1,29 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0013_add_template_version
|
||||
Revises: 0010_events_table
|
||||
Create Date: 2016-05-11 16:00:51.478012
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0013_add_template_version'
|
||||
down_revision = '0010_events_table'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
def upgrade():
|
||||
op.add_column('jobs', sa.Column('template_version', sa.Integer(), nullable=True))
|
||||
op.get_bind()
|
||||
op.execute('update jobs set template_version = (select version from templates where id = template_id)')
|
||||
op.add_column('notifications', sa.Column('template_version', sa.Integer(), nullable=True))
|
||||
op.execute('update notifications set template_version = (select version from templates where id = template_id)')
|
||||
op.alter_column('jobs', 'template_version', nullable=False)
|
||||
op.alter_column('notifications', 'template_version', nullable=False)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('notifications', 'template_version')
|
||||
op.drop_column('jobs', 'template_version')
|
||||
Reference in New Issue
Block a user