@@ -0,0 +1,1459 @@
+%22%22%22%0A%0ARevision ID: 0136_notification_template_hist%0ARevises: 0135_stats_template_usage%0ACreate Date: 2017-11-08 10:15:07.039227%0A%0A%22%22%22%0Afrom alembic import op%0A%0Arevision = '0136_notification_template_hist'%0Adown_revision = '0135_stats_template_usage'%0A%0A%0Adef upgrade():%0A    op.drop_constraint('notifications_template_id_fkey', 'notifications', type_='foreignkey')%0A    op.execute(%22%22%22%0A        ALTER TABLE notifications ADD CONSTRAINT %22notifications_templates_history_fkey%22%0A        FOREIGN KEY (%22template_id%22, %22template_version%22) REFERENCES %22templates_history%22 (%22id%22, %22version%22)%0A        NOT VALID%0A    %22%22%22)%0A%0A    op.drop_constraint('notification_history_template_id_fkey', 'notification_history', type_='foreignkey')%0A    op.execute(%22%22%22%0A        ALTER TABLE notification_history ADD CONSTRAINT %22notification_history_templates_history_fkey%22%0A        FOREIGN KEY (%22template_id%22, %22template_version%22) REFERENCES %22templates_history%22 (%22id%22, %22version%22)%0A        NOT VALID%0A    %22%22%22)%0A%0A%0Adef downgrade():%0A    op.drop_constraint('notifications_templates_history_fkey', 'notifications', type_='foreignkey')%0A    op.create_foreign_key('notifications_template_id_fkey', 'notifications', 'templates', %5B'template_id'%5D, %5B'id'%5D)%0A%0A    op.drop_constraint('notification_history_templates_history_fkey', 'notification_history', type_='foreignkey')%0A    op.create_foreign_key('notification_history_template_id_fkey', 'notification_history', 'templates',%0A                          %5B'template_id'%5D, %5B'id'%5D)%0A

Add a migration to replace notifications_template foreign key