From b37de7785c4447def9c6d5d0e07b9871485679dc Mon Sep 17 00:00:00 2001 From: Rebecca Law Date: Thu, 15 Aug 2019 15:17:53 +0100 Subject: [PATCH] Remove the organisation_to_service table. This table is no longer used or referenced in the code. We can remove this mapping table now that the organisation to service relationship is handled by the foreign key in Services. --- app/__init__.py | 2 +- app/models.py | 9 ------ .../versions/0304_remove_org_to_service.py | 29 +++++++++++++++++++ 3 files changed, 30 insertions(+), 10 deletions(-) create mode 100644 migrations/versions/0304_remove_org_to_service.py diff --git a/app/__init__.py b/app/__init__.py index a52c5a35a..a6f01aa4a 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -70,7 +70,7 @@ def create_app(application): application.config.from_object(configs[notify_environment]) application.config['NOTIFY_APP_NAME'] = application.name - + print(application.config['SQLALCHEMY_DATABASE_URI']) init_app(application) request_helper.init_app(application) db.init_app(application) diff --git a/app/models.py b/app/models.py index 1879d5827..60b57aefa 100644 --- a/app/models.py +++ b/app/models.py @@ -311,15 +311,6 @@ class ServicePermissionTypes(db.Model): name = db.Column(db.String(255), primary_key=True) -organisation_to_service = db.Table( - 'organisation_to_service', - db.Model.metadata, - # service_id is a primary key as you can only have one organisation per service - db.Column('service_id', UUID(as_uuid=True), db.ForeignKey('services.id'), primary_key=True, nullable=False), - db.Column('organisation_id', UUID(as_uuid=True), db.ForeignKey('organisation.id'), nullable=False), -) - - class Domain(db.Model): __tablename__ = "domain" domain = db.Column(db.String(255), primary_key=True) diff --git a/migrations/versions/0304_remove_org_to_service.py b/migrations/versions/0304_remove_org_to_service.py new file mode 100644 index 000000000..b95167023 --- /dev/null +++ b/migrations/versions/0304_remove_org_to_service.py @@ -0,0 +1,29 @@ +""" + +Revision ID: 0304_remove_org_to_service +Revises: 0303_populate_services_org_id +Create Date: 2019-08-15 14:49:00.754390 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +revision = '0304_remove_org_to_service' +down_revision = '0303_populate_services_org_id' + + +def upgrade(): + op.drop_table('organisation_to_service') + + +def downgrade(): + op.create_table('organisation_to_service', + sa.Column('service_id', postgresql.UUID(), autoincrement=False, nullable=False), + sa.Column('organisation_id', postgresql.UUID(), autoincrement=False, nullable=False), + sa.ForeignKeyConstraint(['organisation_id'], ['organisation.id'], + name='organisation_to_service_organisation_id_fkey'), + sa.ForeignKeyConstraint(['service_id'], ['services.id'], + name='organisation_to_service_service_id_fkey'), + sa.PrimaryKeyConstraint('service_id', name='organisation_to_service_pkey') + )