From commits-return-2616-archive-asf-public=cust-asf.ponee.io@superset.incubator.apache.org Wed Apr 24 19:33:40 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 3AC1F18076D for ; Wed, 24 Apr 2019 21:33:40 +0200 (CEST) Received: (qmail 72316 invoked by uid 500); 24 Apr 2019 19:33:39 -0000 Mailing-List: contact commits-help@superset.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@superset.incubator.apache.org Delivered-To: mailing list commits@superset.incubator.apache.org Received: (qmail 72301 invoked by uid 99); 24 Apr 2019 19:33:39 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Apr 2019 19:33:39 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id C16848A7E5; Wed, 24 Apr 2019 19:33:38 +0000 (UTC) Date: Wed, 24 Apr 2019 19:33:38 +0000 To: "commits@superset.apache.org" Subject: [incubator-superset] branch master updated: [schema] Adding commits and removing unnecessary foreign-key definitions (#7371) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <155613441826.28023.6315684725644151254@gitbox.apache.org> From: johnbodley@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: incubator-superset X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 7bc8355b75bf490abf17d18f0311202395c6e3e4 X-Git-Newrev: 3a359fd892cf6ad0c22d7376535899aa1743416c X-Git-Rev: 3a359fd892cf6ad0c22d7376535899aa1743416c X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated 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: