Merge branch 'master' of https://github.com/alphagov/notifications-api into vb-sms-allowance-data-migration

This commit is contained in:
venusbb
2017-11-15 10:54:22 +00:00
20 changed files with 358 additions and 190 deletions

View File

@@ -0,0 +1,36 @@
"""
Revision ID: 0136_notification_template_hist
Revises: 0135_stats_template_usage
Create Date: 2017-11-08 10:15:07.039227
"""
from alembic import op
revision = '0136_notification_template_hist'
down_revision = '0135_stats_template_usage'
def upgrade():
op.drop_constraint('notifications_template_id_fkey', 'notifications', type_='foreignkey')
op.execute("""
ALTER TABLE notifications ADD CONSTRAINT "notifications_templates_history_fkey"
FOREIGN KEY ("template_id", "template_version") REFERENCES "templates_history" ("id", "version")
NOT VALID
""")
op.drop_constraint('notification_history_template_id_fkey', 'notification_history', type_='foreignkey')
op.execute("""
ALTER TABLE notification_history ADD CONSTRAINT "notification_history_templates_history_fkey"
FOREIGN KEY ("template_id", "template_version") REFERENCES "templates_history" ("id", "version")
NOT VALID
""")
def downgrade():
op.drop_constraint('notifications_templates_history_fkey', 'notifications', type_='foreignkey')
op.create_foreign_key('notifications_template_id_fkey', 'notifications', 'templates', ['template_id'], ['id'])
op.drop_constraint('notification_history_templates_history_fkey', 'notification_history', type_='foreignkey')
op.create_foreign_key('notification_history_template_id_fkey', 'notification_history', 'templates',
['template_id'], ['id'])

View File

@@ -0,0 +1,28 @@
"""
Revision ID: 0136_user_mobile_nullable
Revises: 0135_stats_template_usage
Create Date: 2017-11-08 11:49:05.773974
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.sql import column
from sqlalchemy.dialects import postgresql
revision = '0136_user_mobile_nullable'
down_revision = '0135_stats_template_usage'
def upgrade():
op.alter_column('users', 'mobile_number', nullable=True)
op.create_check_constraint(
'ck_users_mobile_or_email_auth',
'users',
"auth_type = 'email_auth' or mobile_number is not null"
)
def downgrade():
op.alter_column('users', 'mobile_number', nullable=False)
op.drop_constraint('ck_users_mobile_or_email_auth', 'users')