From 983744d5284beda722a7839c13b1f3a201b4b6d5 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Mon, 27 Feb 2017 13:39:02 -0500 Subject: [PATCH 1/4] Remove create db from wsgi.py. --- wsgi.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/wsgi.py b/wsgi.py index d147c76..294e9eb 100644 --- a/wsgi.py +++ b/wsgi.py @@ -9,6 +9,3 @@ env = os.environ['ENVIRONMENT'] # Correctly raise a file not found if the specified environment does not exist. app = create_app('config/{}.py'.format(env)) -with app.app_context(): - # Build the database models. - db.create_all() -- GitLab From de801f98f18a9e449c761f645ba5d6304057eb6f Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Mon, 27 Feb 2017 16:06:36 -0500 Subject: [PATCH 2/4] Add leading schema name to the foreign key in project state change. --- app/models/project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/project.py b/app/models/project.py index a8ed55f..7b71df1 100644 --- a/app/models/project.py +++ b/app/models/project.py @@ -75,7 +75,7 @@ class Project(ProjectSchema, Tracked, SalesForce, db.Model): class ProjectStateChange(ProjectSchema, Tracked, db.Model): """A state change of a project.""" project_id = db.Column( - db.Integer, db.ForeignKey('project.id'), + db.Integer, db.ForeignKey('project_service.project.id'), nullable=False) state = db.Column( db.Enum(*Project.states, name='project_states', inherit_schema=True), -- GitLab From 6fdcf7b21d75a9eee0ad75cee71f181378c77653 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Mon, 27 Feb 2017 16:54:14 -0500 Subject: [PATCH 3/4] Use basemodel in project schema mixin. --- app/models/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/base.py b/app/models/base.py index eb78608..529e2b8 100644 --- a/app/models/base.py +++ b/app/models/base.py @@ -97,7 +97,7 @@ class External(object): columns.GUID(), index=True, nullable=False, default=uuid.uuid4) -class ProjectSchema(object): +class ProjectSchema(BaseModel): """A mixin that changes the schema to project_service""" @declared_attr @@ -107,7 +107,7 @@ class ProjectSchema(object): """ return cls.__name__.lower() - __table_args__= {"schema": "project_service"} + __table_args__ = {"schema": "project_service"} def __str__(self): """Provide a sane default for model string representation.""" -- GitLab From ad59f57c9c016d29ed8b7cbec4250d00afab943c Mon Sep 17 00:00:00 2001 From: Conrad S Date: Tue, 28 Feb 2017 11:46:20 -0500 Subject: [PATCH 4/4] Add project_service schema to document slot model --- app/models/document.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/document.py b/app/models/document.py index 5dba758..b604dc4 100644 --- a/app/models/document.py +++ b/app/models/document.py @@ -9,7 +9,7 @@ class DocumentSlot(ProjectSchema, Tracked, db.Model): the document service). """ project_id = db.Column( - db.Integer, db.ForeignKey('project.id'), nullable=False) + db.Integer, db.ForeignKey('project_service.project.id'), nullable=False) document_key = db.Column(GUID(), nullable=False) # How the document fits into the project. -- GitLab