Skip to content

Commit

Permalink
Use server_default
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida committed Jan 21, 2022
1 parent d5cc55a commit d8f6592
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
2 changes: 1 addition & 1 deletion superset/connectors/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def name(self) -> str:
params = Column(String(1000))
perm = Column(String(1000))
schema_perm = Column(String(1000))
is_managed_externally = Column(Boolean, default=False)
is_managed_externally = Column(Boolean, nullable=False, default=False)
external_url = Column(Text, nullable=True)

sql: Optional[str] = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,56 @@
def upgrade():
with op.batch_alter_table("dashboards") as batch_op:
batch_op.add_column(
sa.Column("is_managed_externally", sa.Boolean(), nullable=True)
sa.Column(
"is_managed_externally",
sa.Boolean(),
nullable=False,
server_default=sa.false(),
)
)
batch_op.add_column(sa.Column("external_url", sa.Text(), nullable=True))

with op.batch_alter_table("datasources") as batch_op:
batch_op.add_column(
sa.Column("is_managed_externally", sa.Boolean(), nullable=True)
sa.Column(
"is_managed_externally",
sa.Boolean(),
nullable=False,
server_default=sa.false(),
)
)
batch_op.add_column(sa.Column("external_url", sa.Text(), nullable=True))

with op.batch_alter_table("dbs") as batch_op:
batch_op.add_column(
sa.Column("is_managed_externally", sa.Boolean(), nullable=True)
sa.Column(
"is_managed_externally",
sa.Boolean(),
nullable=False,
server_default=sa.false(),
)
)
batch_op.add_column(sa.Column("external_url", sa.Text(), nullable=True))

with op.batch_alter_table("slices") as batch_op:
batch_op.add_column(
sa.Column("is_managed_externally", sa.Boolean(), nullable=True)
sa.Column(
"is_managed_externally",
sa.Boolean(),
nullable=False,
server_default=sa.false(),
)
)
batch_op.add_column(sa.Column("external_url", sa.Text(), nullable=True))

with op.batch_alter_table("tables") as batch_op:
batch_op.add_column(
sa.Column("is_managed_externally", sa.Boolean(), nullable=True)
sa.Column(
"is_managed_externally",
sa.Boolean(),
nullable=False,
server_default=sa.false(),
)
)
batch_op.add_column(sa.Column("external_url", sa.Text(), nullable=True))

Expand Down
2 changes: 1 addition & 1 deletion superset/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class Database(
encrypted_extra = Column(encrypted_field_factory.create(Text), nullable=True)
impersonate_user = Column(Boolean, default=False)
server_cert = Column(encrypted_field_factory.create(Text), nullable=True)
is_managed_externally = Column(Boolean, default=False)
is_managed_externally = Column(Boolean, nullable=False, default=False)
external_url = Column(Text, nullable=True)

export_fields = [
Expand Down
2 changes: 1 addition & 1 deletion superset/models/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class Dashboard(Model, AuditMixinNullable, ImportExportMixin):
slices = relationship(Slice, secondary=dashboard_slices, backref="dashboards")
owners = relationship(security_manager.user_model, secondary=dashboard_user)
published = Column(Boolean, default=False)
is_managed_externally = Column(Boolean, default=False)
is_managed_externally = Column(Boolean, nullable=False, default=False)
external_url = Column(Text, nullable=True)
roles = relationship(security_manager.role_model, secondary=DashboardRoles)
_filter_sets = relationship(
Expand Down
2 changes: 1 addition & 1 deletion superset/models/slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class Slice( # pylint: disable=too-many-public-methods
last_saved_by_fk = Column(Integer, ForeignKey("ab_user.id"), nullable=True)
certified_by = Column(Text)
certification_details = Column(Text)
is_managed_externally = Column(Boolean, default=False)
is_managed_externally = Column(Boolean, nullable=False, default=False)
external_url = Column(Text, nullable=True)
last_saved_by = relationship(
security_manager.user_model, foreign_keys=[last_saved_by_fk]
Expand Down

0 comments on commit d8f6592

Please sign in to comment.