This is an automated email from the ASF dual-hosted git repository.
johnbodley pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new 3a359fd [schema] Adding commits and removing unnecessary foreign-key definitions
(#7371)
3a359fd is described below
commit 3a359fd892cf6ad0c22d7376535899aa1743416c
Author: John Bodley <4567245+john-bodley@users.noreply.github.com>
AuthorDate: Wed Apr 24 12:33:33 2019 -0700
[schema] Adding commits and removing unnecessary foreign-key definitions (#7371)
---
.../versions/7f2635b51f5d_update_base_columns.py | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/superset/migrations/versions/7f2635b51f5d_update_base_columns.py b/superset/migrations/versions/7f2635b51f5d_update_base_columns.py
index ba5efaf..7087c6a 100644
--- a/superset/migrations/versions/7f2635b51f5d_update_base_columns.py
+++ b/superset/migrations/versions/7f2635b51f5d_update_base_columns.py
@@ -30,7 +30,7 @@ revision = '7f2635b51f5d'
down_revision = '937d04c16b64'
from alembic import op
-from sqlalchemy import Column, engine, ForeignKey, Integer, String
+from sqlalchemy import Column, engine, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from superset import db
@@ -43,20 +43,20 @@ conv = {
}
-class BaseColumnMixin(object):
+class BaseColumnMixin:
id = Column(Integer, primary_key=True)
class DruidColumn(BaseColumnMixin, Base):
__tablename__ = 'columns'
- datasource_id = Column(Integer, ForeignKey('datasources.id'))
+ datasource_id = Column(Integer)
class TableColumn(BaseColumnMixin, Base):
__tablename__ = 'table_columns'
- table_id = Column(Integer, ForeignKey('tables.id'))
+ table_id = Column(Integer)
def upgrade():
@@ -68,7 +68,9 @@ def upgrade():
if record.datasource_id is None:
session.delete(record)
- # Enforce that the columns.column_name be non-nullable.
+ session.commit()
+
+ # Enforce that the columns.column_name column be non-nullable.
with op.batch_alter_table('columns') as batch_op:
batch_op.alter_column(
'column_name',
@@ -81,6 +83,8 @@ def upgrade():
if record.table_id is None:
session.delete(record)
+ session.commit()
+
# Reduce the size of the table_columns.column_name column for constraint
# viability and enforce that it be non-nullable.
with op.batch_alter_table('table_columns') as batch_op:
|