Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[schema] Adding commits and removing unnecessary foreign-key definitions #7371

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
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
Expand All @@ -43,20 +43,20 @@
}


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():
Expand All @@ -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',
Expand All @@ -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:
Expand Down