From 37dda1d235017bebb9bb0f6eff150dd12222762f Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Wed, 7 Feb 2018 11:40:26 +0000 Subject: [PATCH] remove organisation from db also make sure email branding is not nullable, because it shouldnt be --- migrations/versions/0162_remove_org.py | 45 ++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 migrations/versions/0162_remove_org.py diff --git a/migrations/versions/0162_remove_org.py b/migrations/versions/0162_remove_org.py new file mode 100644 index 000000000..be0c2e4c4 --- /dev/null +++ b/migrations/versions/0162_remove_org.py @@ -0,0 +1,45 @@ +""" + +Revision ID: 0162_remove_org +Revises: 0161_email_branding +Create Date: 2018-02-06 17:08:11.879844 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +revision = '0162_remove_org' +down_revision = '0161_email_branding' + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('services', 'organisation_id') + op.drop_column('services_history', 'organisation_id') + + op.drop_table('organisation') + + op.alter_column('service_email_branding', 'email_branding_id', nullable=False) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('services_history', sa.Column('organisation_id', postgresql.UUID(), autoincrement=False, nullable=True)) # noqa + op.add_column('services', sa.Column('organisation_id', postgresql.UUID(), autoincrement=False, nullable=True)) + + op.create_table( + 'organisation', + sa.Column('id', postgresql.UUID(), autoincrement=False, nullable=False), + sa.Column('colour', sa.VARCHAR(length=7), autoincrement=False, nullable=True), + sa.Column('logo', sa.VARCHAR(length=255), autoincrement=False, nullable=True), + sa.Column('name', sa.VARCHAR(length=255), autoincrement=False, nullable=True), + sa.PrimaryKeyConstraint('id', name='organisation_pkey') + ) + + op.create_index('ix_services_history_organisation_id', 'services_history', ['organisation_id'], unique=False) + op.create_foreign_key('services_organisation_id_fkey', 'services', 'organisation', ['organisation_id'], ['id']) + op.create_index('ix_services_organisation_id', 'services', ['organisation_id'], unique=False) + + op.alter_column('service_email_branding', 'email_branding_id', nullable=True)