From 6e0e3e9f08c44e93080b6c4857eb1a02c54d975d Mon Sep 17 00:00:00 2001 From: Ken Tsang Date: Sat, 10 Feb 2018 01:32:14 +0000 Subject: [PATCH] Migration script to add organisation_to_service association table --- .../versions/0164_add_organisation_service.py | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 migrations/versions/0164_add_organisation_service.py diff --git a/migrations/versions/0164_add_organisation_service.py b/migrations/versions/0164_add_organisation_service.py new file mode 100644 index 000000000..6e96ce7b4 --- /dev/null +++ b/migrations/versions/0164_add_organisation_service.py @@ -0,0 +1,31 @@ +""" + +Revision ID: 0164_add_organisation_service +Revises: 0163_add_new_org_model +Create Date: 2018-02-09 17:58:34.617206 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +revision = '0164_add_organisation_to_service' +down_revision = '0163_add_new_org_model' + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('organisation_to_service', + sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=False), + sa.Column('organisation_id', postgresql.UUID(as_uuid=True), nullable=False), + sa.ForeignKeyConstraint(['organisation_id'], ['organisation.id'], ), + sa.ForeignKeyConstraint(['service_id'], ['services.id'], ), + sa.PrimaryKeyConstraint('service_id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('organisation_to_service') + # ### end Alembic commands ###