Compare commits

...

3 Commits

Author SHA1 Message Date
Elizabeth Thompson
51cda4cb4f update contstraint logic and test 2025-04-10 13:29:29 -07:00
Elizabeth Thompson
3162bb3f59 fix typing on python 3.10 2025-04-09 18:02:04 -07:00
Elizabeth Thompson
b7de9ab17f use create table util 2025-04-09 16:58:49 -07:00
40 changed files with 239 additions and 170 deletions

View File

@@ -17,8 +17,7 @@
import logging
import os
from typing import cast, Iterable, Optional
from wsgiref.types import StartResponse, WSGIApplication, WSGIEnvironment
from typing import Any, Callable, cast, Dict, Iterable, Optional
from flask import Flask
from werkzeug.exceptions import NotFound
@@ -79,14 +78,16 @@ class AppRootMiddleware:
def __init__(
self,
wsgi_app: WSGIApplication,
wsgi_app: Any,
app_root: str,
):
self.wsgi_app = wsgi_app
self.app_root = app_root
def __call__(
self, environ: WSGIEnvironment, start_response: StartResponse
self,
environ: Dict[str, Any],
start_response: Callable[[str, Any], Iterable[bytes]],
) -> Iterable[bytes]:
original_path_info = environ.get("PATH_INFO", "")
if original_path_info.startswith(self.app_root):

View File

@@ -16,6 +16,7 @@
# under the License.
from alembic.operations import Operations
from sqlalchemy.engine.reflection import Inspector
naming_convention = {
"fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
@@ -26,6 +27,18 @@ naming_convention = {
def create_unique_constraint(
op: Operations, index_id: str, table_name: str, uix_columns: list[str]
) -> None:
# Get the database connection and inspector
bind = op.get_bind()
inspector = Inspector.from_engine(bind)
# Check if the unique constraint already exists
existing_constraints = inspector.get_unique_constraints(table_name)
for constraint in existing_constraints:
if constraint["name"] == index_id:
# Constraint already exists, no need to create it
return
# Create the unique constraint if it doesn't exist
with op.batch_alter_table(
table_name, naming_convention=naming_convention
) as batch_op:

View File

@@ -226,24 +226,25 @@ def drop_fks_for_table(
op.drop_constraint(fk_name, table_name, type_="foreignkey")
def create_table(table_name: str, *columns: SchemaItem) -> None:
def create_table(table_name: str, *columns: SchemaItem, **kwargs: Any) -> None:
"""
Creates a database table with the specified name and columns.
This function checks if a table with the given name already exists in the database.
If the table already exists, it logs an informational.
Otherwise, it proceeds to create a new table using the provided name and schema columns.
Otherwise, it proceeds to create a new table using the provided name
and schema columns.
:param table_name: The name of the table to be created.
:param columns: A variable number of arguments representing the schema just like when calling alembic's method create_table()
""" # noqa: E501
:param columns: A variable number of arguments representing the schema
just like when calling alembic's method create_table()
"""
if has_table(table_name=table_name):
logger.info(f"Table {LRED}{table_name}{RESET} already exists. Skipping...")
return
logger.info(f"Creating table {GREEN}{table_name}{RESET}...")
op.create_table(table_name, *columns)
op.create_table(table_name, *columns, **kwargs)
logger.info(f"Table {GREEN}{table_name}{RESET} created.")

View File

@@ -22,17 +22,19 @@ Create Date: 2015-09-21 17:30:38.442998
"""
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import create_table
# revision identifiers, used by Alembic.
revision = "4e6a06bad7a8"
down_revision = None
import sqlalchemy as sa # noqa: E402
from alembic import op # noqa: E402
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_table(
create_table(
"clusters",
sa.Column("created_on", sa.DateTime(), nullable=False),
sa.Column("changed_on", sa.DateTime(), nullable=False),
@@ -54,7 +56,7 @@ def upgrade():
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("cluster_name"),
)
op.create_table(
create_table(
"dashboards",
sa.Column("created_on", sa.DateTime(), nullable=False),
sa.Column("changed_on", sa.DateTime(), nullable=False),
@@ -69,7 +71,7 @@ def upgrade():
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
create_table(
"dbs",
sa.Column("created_on", sa.DateTime(), nullable=False),
sa.Column("changed_on", sa.DateTime(), nullable=False),
@@ -85,7 +87,7 @@ def upgrade():
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("database_name"),
)
op.create_table(
create_table(
"datasources",
sa.Column("created_on", sa.DateTime(), nullable=False),
sa.Column("changed_on", sa.DateTime(), nullable=False),
@@ -111,7 +113,7 @@ def upgrade():
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("datasource_name"),
)
op.create_table(
create_table(
"tables",
sa.Column("created_on", sa.DateTime(), nullable=False),
sa.Column("changed_on", sa.DateTime(), nullable=False),
@@ -129,7 +131,7 @@ def upgrade():
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("table_name"),
)
op.create_table(
create_table(
"columns",
sa.Column("created_on", sa.DateTime(), nullable=False),
sa.Column("changed_on", sa.DateTime(), nullable=False),
@@ -153,7 +155,7 @@ def upgrade():
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
create_table(
"metrics",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("metric_name", sa.String(length=512), nullable=True),
@@ -170,7 +172,7 @@ def upgrade():
sa.ForeignKeyConstraint(["datasource_name"], ["datasources.datasource_name"]),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
create_table(
"slices",
sa.Column("created_on", sa.DateTime(), nullable=False),
sa.Column("changed_on", sa.DateTime(), nullable=False),
@@ -195,7 +197,7 @@ def upgrade():
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
create_table(
"sql_metrics",
sa.Column("created_on", sa.DateTime(), nullable=False),
sa.Column("changed_on", sa.DateTime(), nullable=False),
@@ -214,7 +216,7 @@ def upgrade():
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
create_table(
"table_columns",
sa.Column("created_on", sa.DateTime(), nullable=False),
sa.Column("changed_on", sa.DateTime(), nullable=False),
@@ -239,7 +241,7 @@ def upgrade():
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
create_table(
"dashboard_slices",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column(

View File

@@ -22,16 +22,18 @@ Create Date: 2015-12-04 11:16:58.226984
"""
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import create_table
# revision identifiers, used by Alembic.
revision = "315b3f4da9b0"
down_revision = "1a48a5411020"
import sqlalchemy as sa # noqa: E402
from alembic import op # noqa: E402
def upgrade():
op.create_table(
create_table(
"logs",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("action", sa.String(length=512), nullable=True),

View File

@@ -22,16 +22,18 @@ Create Date: 2016-01-13 20:24:45.256437
"""
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import create_table
# revision identifiers, used by Alembic.
revision = "8e80a26a31db"
down_revision = "2591d77e9831"
import sqlalchemy as sa # noqa: E402
from alembic import op # noqa: E402
def upgrade():
op.create_table(
create_table(
"url",
sa.Column("created_on", sa.DateTime(), nullable=False),
sa.Column("changed_on", sa.DateTime(), nullable=False),

View File

@@ -22,16 +22,18 @@ Create Date: 2016-02-03 17:41:10.944019
"""
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import create_table
# revision identifiers, used by Alembic.
revision = "d827694c7555"
down_revision = "43df8de3a5f4"
import sqlalchemy as sa # noqa: E402
from alembic import op # noqa: E402
def upgrade():
op.create_table(
create_table(
"css_templates",
sa.Column("created_on", sa.DateTime(), nullable=False),
sa.Column("changed_on", sa.DateTime(), nullable=False),

View File

@@ -22,16 +22,18 @@ Create Date: 2016-03-13 09:56:58.329512
"""
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import create_table
# revision identifiers, used by Alembic.
revision = "a2d606a761d9"
down_revision = "18e88e1cc004"
import sqlalchemy as sa # noqa: E402
from alembic import op # noqa: E402
def upgrade():
op.create_table(
create_table(
"favstar",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("user_id", sa.Integer(), nullable=True),

View File

@@ -22,16 +22,18 @@ Create Date: 2016-04-15 17:58:33.842012
"""
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import create_table
# revision identifiers, used by Alembic.
revision = "4fa88fe24e94"
down_revision = "b4456560d4f3"
import sqlalchemy as sa # noqa: E402
from alembic import op # noqa: E402
def upgrade():
op.create_table(
create_table(
"dashboard_user",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("user_id", sa.Integer(), nullable=True),
@@ -40,7 +42,7 @@ def upgrade():
sa.ForeignKeyConstraint(["user_id"], ["ab_user.id"]),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
create_table(
"slice_user",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("user_id", sa.Integer(), nullable=True),

View File

@@ -22,16 +22,18 @@ Create Date: 2016-07-25 17:48:12.771103
"""
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import create_table
# revision identifiers, used by Alembic.
revision = "ad82a75afd82"
down_revision = "f162a1dea4c4"
import sqlalchemy as sa # noqa: E402
from alembic import op # noqa: E402
def upgrade():
op.create_table(
create_table(
"query",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("client_id", sa.String(length=11), nullable=False),

View File

@@ -25,13 +25,15 @@ Create Date: 2016-09-09 17:39:57.846309
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import create_table
# revision identifiers, used by Alembic.
revision = "5e4a03ef0bf0"
down_revision = "b347b202819b"
def upgrade():
op.create_table(
create_table(
"access_request",
sa.Column("created_on", sa.DateTime(), nullable=True),
sa.Column("changed_on", sa.DateTime(), nullable=True),

View File

@@ -22,17 +22,19 @@ Create Date: 2017-01-10 11:47:56.306938
"""
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import create_table
# revision identifiers, used by Alembic.
revision = "bcf3126872fc"
down_revision = "f18570e03440"
import sqlalchemy as sa # noqa: E402
from alembic import op # noqa: E402
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_table(
create_table(
"keyvalue",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("value", sa.Text(), nullable=False),

View File

@@ -25,6 +25,8 @@ Create Date: 2017-09-13 16:36:39.144489
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import create_table
# revision identifiers, used by Alembic.
revision = "ddd6ebdd853b"
down_revision = "ca69c70ec99b"
@@ -32,7 +34,7 @@ down_revision = "ca69c70ec99b"
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
create_table(
"annotation_layer",
sa.Column("created_on", sa.DateTime(), nullable=True),
sa.Column("changed_on", sa.DateTime(), nullable=True),
@@ -45,7 +47,7 @@ def upgrade():
sa.ForeignKeyConstraint(["created_by_fk"], ["ab_user.id"]),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
create_table(
"annotation",
sa.Column("created_on", sa.DateTime(), nullable=True),
sa.Column("changed_on", sa.DateTime(), nullable=True),

View File

@@ -22,17 +22,19 @@ Create Date: 2018-05-15 20:28:51.977572
"""
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import create_table
# revision identifiers, used by Alembic.
revision = "6c7537a6004a"
down_revision = "a61b40f9f57f"
import sqlalchemy as sa # noqa: E402
from alembic import op # noqa: E402
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
create_table(
"dashboard_email_schedules",
sa.Column("created_on", sa.DateTime(), nullable=True),
sa.Column("changed_on", sa.DateTime(), nullable=True),
@@ -62,7 +64,7 @@ def upgrade():
["active"],
unique=False,
)
op.create_table(
create_table(
"slice_email_schedules",
sa.Column("created_on", sa.DateTime(), nullable=True),
sa.Column("changed_on", sa.DateTime(), nullable=True),

View File

@@ -27,6 +27,7 @@ from alembic import op
# revision identifiers, used by Alembic.
from superset import db
from superset.migrations.shared.utils import create_table
from superset.utils.core import generic_find_fk_constraint_name
revision = "3e1b21cd94a4"
@@ -65,7 +66,7 @@ DruidDatasource = sa.Table(
def upgrade():
op.create_table(
create_table(
"sqlatable_user",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("user_id", sa.Integer(), nullable=True),
@@ -74,7 +75,7 @@ def upgrade():
sa.ForeignKeyConstraint(["user_id"], ["ab_user.id"]),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
create_table(
"druiddatasource_user",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("user_id", sa.Integer(), nullable=True),

View File

@@ -22,17 +22,19 @@ Create Date: 2019-11-13 11:05:30.122167
"""
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import create_table
# revision identifiers, used by Alembic.
revision = "db4b49eb0782"
down_revision = "78ee127d0d1d"
import sqlalchemy as sa # noqa: E402
from alembic import op # noqa: E402
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
create_table(
"tab_state",
sa.Column("created_on", sa.DateTime(), nullable=True),
sa.Column("changed_on", sa.DateTime(), nullable=True),
@@ -59,7 +61,7 @@ def upgrade():
sqlite_autoincrement=True,
)
op.create_index(op.f("ix_tab_state_id"), "tab_state", ["id"], unique=True)
op.create_table(
create_table(
"table_schema",
sa.Column("created_on", sa.DateTime(), nullable=True),
sa.Column("changed_on", sa.DateTime(), nullable=True),

View File

@@ -22,16 +22,18 @@ Create Date: 2019-12-04 17:07:54.390805
"""
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import create_table
# revision identifiers, used by Alembic.
revision = "0a6f12f60c73"
down_revision = "3325d4caccc8"
import sqlalchemy as sa # noqa: E402
from alembic import op # noqa: E402
def upgrade():
op.create_table(
create_table(
"row_level_security_filters",
sa.Column("created_on", sa.DateTime(), nullable=True),
sa.Column("changed_on", sa.DateTime(), nullable=True),
@@ -45,7 +47,7 @@ def upgrade():
sa.ForeignKeyConstraint(["table_id"], ["tables.id"]),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
create_table(
"rls_filter_roles",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("role_id", sa.Integer(), nullable=False),

View File

@@ -22,22 +22,23 @@ Create Date: 2020-04-24 10:46:24.119363
"""
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import create_table
from superset.utils.core import generic_find_fk_constraint_name
# revision identifiers, used by Alembic.
revision = "e557699a813e"
down_revision = "743a117f0d98"
import sqlalchemy as sa # noqa: E402
from alembic import op # noqa: E402
from superset.utils.core import generic_find_fk_constraint_name # noqa: E402
def upgrade():
bind = op.get_bind()
metadata = sa.MetaData(bind=bind)
insp = sa.engine.reflection.Inspector.from_engine(bind)
rls_filter_tables = op.create_table(
rls_filter_tables = create_table(
"rls_filter_tables",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("table_id", sa.Integer(), nullable=True),

View File

@@ -22,17 +22,19 @@ Create Date: 2020-05-26 23:21:50.059635
"""
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import create_table
# revision identifiers, used by Alembic.
revision = "2f1d15e8a6af"
down_revision = "a72cb0ebeb22"
import sqlalchemy as sa # noqa: E402
from alembic import op # noqa: E402
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
create_table(
"alerts",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("label", sa.String(length=150), nullable=False),
@@ -59,7 +61,7 @@ def upgrade():
sa.PrimaryKeyConstraint("id"),
)
op.create_index(op.f("ix_alerts_active"), "alerts", ["active"], unique=False)
op.create_table(
create_table(
"alert_logs",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("scheduled_dttm", sa.DateTime(), nullable=True),
@@ -73,7 +75,7 @@ def upgrade():
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
create_table(
"alert_owner",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("user_id", sa.Integer(), nullable=True),

View File

@@ -22,16 +22,18 @@ Create Date: 2020-08-28 17:16:57.379425
"""
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import create_table
# revision identifiers, used by Alembic.
revision = "175ea3592453"
down_revision = "f80a3b88324b"
import sqlalchemy as sa # noqa: E402
from alembic import op # noqa: E402
def upgrade():
op.create_table(
create_table(
"cache_keys",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("cache_key", sa.String(256), nullable=False),

View File

@@ -22,18 +22,20 @@ Create Date: 2020-08-31 20:30:30.781478
"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import mysql
from superset.migrations.shared.utils import create_table
# revision identifiers, used by Alembic.
revision = "2e5a0ee25ed4"
down_revision = "f80a3b88324b"
import sqlalchemy as sa # noqa: E402
from alembic import op # noqa: E402
from sqlalchemy.dialects import mysql # noqa: E402
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
create_table(
"alert_validators",
sa.Column("created_on", sa.DateTime(), nullable=True),
sa.Column("changed_on", sa.DateTime(), nullable=True),
@@ -57,7 +59,7 @@ def upgrade():
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
create_table(
"sql_observers",
sa.Column("created_on", sa.DateTime(), nullable=True),
sa.Column("changed_on", sa.DateTime(), nullable=True),
@@ -85,7 +87,7 @@ def upgrade():
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
create_table(
"sql_observations",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("dttm", sa.DateTime(), nullable=True),

View File

@@ -29,6 +29,7 @@ from sqlalchemy.ext.declarative import declarative_base, declared_attr
from sqlalchemy.orm import backref, relationship, RelationshipProperty
from superset import db
from superset.migrations.shared.utils import create_table
from superset.utils.core import generic_find_fk_constraint_name
revision = "af30ca79208f"
@@ -153,7 +154,7 @@ def upgrade():
# sqlite does not support column and fk deletion
if isinstance(bind.dialect, SQLiteDialect):
op.drop_table("sql_observations")
op.create_table(
create_table(
"sql_observations",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("dttm", sa.DateTime(), nullable=True),
@@ -174,7 +175,7 @@ def downgrade():
bind = op.get_bind()
insp = sa.engine.reflection.Inspector.from_engine(bind)
op.create_table(
create_table(
"sql_observers",
sa.Column("created_on", sa.DateTime(), nullable=True),
sa.Column("changed_on", sa.DateTime(), nullable=True),
@@ -191,7 +192,7 @@ def downgrade():
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
create_table(
"alert_validators",
sa.Column("created_on", sa.DateTime(), nullable=True),
sa.Column("changed_on", sa.DateTime(), nullable=True),
@@ -248,7 +249,7 @@ def downgrade():
),
)
op.drop_table("alerts")
op.create_table(
create_table(
"alerts",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("label", sa.String(length=150), nullable=False),

View File

@@ -22,17 +22,19 @@ Create Date: 2020-11-04 11:06:59.249758
"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.engine.reflection import Inspector
from superset.migrations.shared.utils import create_table
# revision identifiers, used by Alembic.
revision = "49b5a32daba5"
down_revision = "96e99fb176a0"
import sqlalchemy as sa # noqa: E402
from alembic import op # noqa: E402
from sqlalchemy.engine.reflection import Inspector # noqa: E402
def upgrade():
op.create_table(
create_table(
"report_schedule",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("type", sa.String(length=50), nullable=False),
@@ -76,7 +78,7 @@ def upgrade():
op.f("ix_report_schedule_active"), "report_schedule", ["active"], unique=False
)
op.create_table(
create_table(
"report_execution_log",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("scheduled_dttm", sa.DateTime(), nullable=False),
@@ -91,7 +93,7 @@ def upgrade():
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
create_table(
"report_recipient",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("type", sa.String(length=50), nullable=False),
@@ -108,7 +110,7 @@ def upgrade():
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
create_table(
"report_schedule_user",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("user_id", sa.Integer(), nullable=False),

View File

@@ -21,15 +21,18 @@ Revises: 260bf0649a77
Create Date: 2021-01-14 19:12:43.406230
"""
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import create_table
# revision identifiers, used by Alembic.
revision = "e11ccdd12658"
down_revision = "260bf0649a77"
import sqlalchemy as sa # noqa: E402
from alembic import op # noqa: E402
def upgrade():
op.create_table(
create_table(
"dashboard_roles",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("role_id", sa.Integer(), nullable=False),

View File

@@ -22,16 +22,18 @@ Create Date: 2021-03-29 11:15:48.831225
"""
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import create_table
# revision identifiers, used by Alembic.
revision = "3ebe0993c770"
down_revision = "181091c0ef16"
import sqlalchemy as sa # noqa: E402
from alembic import op # noqa: E402
def upgrade():
op.create_table(
create_table(
"filter_sets",
sa.Column("created_on", sa.DateTime(), nullable=True),
sa.Column("changed_on", sa.DateTime(), nullable=True),

View File

@@ -22,19 +22,21 @@ Create Date: 2022-01-28 16:03:02.944080
"""
from uuid import uuid4
import sqlalchemy as sa
from alembic import op
from sqlalchemy_utils import UUIDType
from superset.migrations.shared.utils import create_table
# revision identifiers, used by Alembic.
revision = "5afbb1a5849b"
down_revision = "5fd49410a97a"
from uuid import uuid4 # noqa: E402
import sqlalchemy as sa # noqa: E402
from alembic import op # noqa: E402
from sqlalchemy_utils import UUIDType # noqa: E402
def upgrade():
op.create_table(
create_table(
"embedded_dashboards",
sa.Column("created_on", sa.DateTime(), nullable=True),
sa.Column("changed_on", sa.DateTime(), nullable=True),

View File

@@ -22,19 +22,21 @@ Create Date: 2022-03-04 09:59:26.922329
"""
from uuid import uuid4
import sqlalchemy as sa
from alembic import op
from sqlalchemy_utils import UUIDType
from superset.migrations.shared.utils import create_table
# revision identifiers, used by Alembic.
revision = "6766938c6065"
down_revision = "7293b0ca7944"
from uuid import uuid4 # noqa: E402
import sqlalchemy as sa # noqa: E402
from alembic import op # noqa: E402
from sqlalchemy_utils import UUIDType # noqa: E402
def upgrade():
op.create_table(
create_table(
"key_value",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("resource", sa.String(32), nullable=False),

View File

@@ -22,24 +22,25 @@ Create Date: 2022-10-20 10:48:08.722861
"""
from uuid import uuid4
import sqlalchemy as sa
from alembic import op
from sqlalchemy_utils import UUIDType
from superset import app
from superset.extensions import encrypted_field_factory
from superset.migrations.shared.utils import create_table
# revision identifiers, used by Alembic.
revision = "f3c2d8ec8595"
down_revision = "4ce1d9b25135"
from uuid import uuid4 # noqa: E402
import sqlalchemy as sa # noqa: E402
from alembic import op # noqa: E402
from sqlalchemy_utils import UUIDType # noqa: E402
from superset import app # noqa: E402
from superset.extensions import encrypted_field_factory # noqa: E402
app_config = app.config
def upgrade():
op.create_table(
create_table(
"ssh_tunnels",
# AuditMixinNullable
sa.Column("created_on", sa.DateTime(), nullable=True),

View File

@@ -22,20 +22,22 @@ Create Date: 2023-06-01 13:13:18.147362
"""
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import create_table
# revision identifiers, used by Alembic.
revision = "83e1abbe777f"
down_revision = "ae58e1e58e5c"
import sqlalchemy as sa # noqa: E402
from alembic import op # noqa: E402
def upgrade():
op.drop_table("access_request")
def downgrade():
op.create_table(
create_table(
"access_request",
sa.Column("created_on", sa.DateTime(), nullable=True),
sa.Column("changed_on", sa.DateTime(), nullable=True),

View File

@@ -22,17 +22,19 @@ Create Date: 2023-07-12 20:34:57.553981
"""
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import create_table
# revision identifiers, used by Alembic.
revision = "e0f6f91c2055"
down_revision = "bf646a0c1501"
import sqlalchemy as sa # noqa: E402
from alembic import op # noqa: E402
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
create_table(
"user_favorite_tag",
sa.Column("user_id", sa.Integer(), nullable=False),
sa.Column("tag_id", sa.Integer(), nullable=False),

View File

@@ -22,19 +22,22 @@ Create Date: 2024-03-20 16:02:58.515915
"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy_utils import EncryptedType
from superset.migrations.shared.utils import (
create_table,
drop_fks_for_table,
)
# revision identifiers, used by Alembic.
revision = "678eefb4ab44"
down_revision = "be1b217cd8cd"
import sqlalchemy as sa # noqa: E402
from alembic import op # noqa: E402
from sqlalchemy_utils import EncryptedType # noqa: E402
from superset.migrations.shared.utils import drop_fks_for_table # noqa: E402
def upgrade():
op.create_table(
create_table(
"database_user_oauth2_tokens",
sa.Column("created_on", sa.DateTime(), nullable=True),
sa.Column("changed_on", sa.DateTime(), nullable=True),

View File

@@ -25,7 +25,7 @@ Create Date: 2024-05-24 11:31:57.115586
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import drop_fks_for_table, has_table
from superset.migrations.shared.utils import create_table, drop_fks_for_table, has_table
# revision identifiers, used by Alembic.
revision = "02f4f7811799"
@@ -41,7 +41,7 @@ def upgrade():
def downgrade():
op.create_table(
create_table(
table_name,
sa.Column("dataset_id", sa.Integer(), nullable=False),
sa.Column("column_id", sa.Integer(), nullable=False),

View File

@@ -25,7 +25,7 @@ Create Date: 2024-08-13 15:17:23.273168
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import drop_fks_for_table, has_table
from superset.migrations.shared.utils import create_table, drop_fks_for_table, has_table
# revision identifiers, used by Alembic.
revision = "39549add7bfc"
@@ -41,7 +41,7 @@ def upgrade():
def downgrade():
op.create_table(
create_table(
table_name,
sa.Column("table_id", sa.Integer(), nullable=False),
sa.Column("column_id", sa.Integer(), nullable=False),

View File

@@ -25,7 +25,7 @@ Create Date: 2024-08-13 15:23:28.768963
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import drop_fks_for_table, has_table
from superset.migrations.shared.utils import create_table, drop_fks_for_table, has_table
# revision identifiers, used by Alembic.
revision = "38f4144e8558"
@@ -41,7 +41,7 @@ def upgrade():
def downgrade():
op.create_table(
create_table(
table_name,
sa.Column("dataset_id", sa.Integer(), nullable=False),
sa.Column("table_id", sa.Integer(), nullable=False),

View File

@@ -25,7 +25,7 @@ Create Date: 2024-08-13 15:27:11.589886
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import drop_fks_for_table, has_table
from superset.migrations.shared.utils import create_table, drop_fks_for_table, has_table
# revision identifiers, used by Alembic.
revision = "e53fd48cc078"
@@ -41,7 +41,7 @@ def upgrade():
def downgrade():
op.create_table(
create_table(
table_name,
sa.Column("dataset_id", sa.Integer(), nullable=False),
sa.Column("user_id", sa.Integer(), nullable=False),

View File

@@ -25,7 +25,7 @@ Create Date: 2024-08-13 15:29:33.135672
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import drop_fks_for_table, has_table
from superset.migrations.shared.utils import create_table, drop_fks_for_table, has_table
# revision identifiers, used by Alembic.
revision = "a6b32d2d07b1"
@@ -41,7 +41,7 @@ def upgrade():
def downgrade():
op.create_table(
create_table(
table_name,
sa.Column("uuid", sa.Numeric(precision=16), nullable=True),
sa.Column("created_on", sa.DateTime(), nullable=True),

View File

@@ -25,7 +25,7 @@ Create Date: 2024-08-13 15:31:31.478017
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import drop_fks_for_table, has_table
from superset.migrations.shared.utils import create_table, drop_fks_for_table, has_table
# revision identifiers, used by Alembic.
revision = "007a1abffe7e"
@@ -41,7 +41,7 @@ def upgrade():
def downgrade():
op.create_table(
create_table(
table_name,
sa.Column("uuid", sa.Numeric(precision=16), nullable=True),
sa.Column("created_on", sa.DateTime(), nullable=True),

View File

@@ -25,7 +25,7 @@ Create Date: 2024-08-13 15:33:14.551012
import sqlalchemy as sa
from alembic import op
from superset.migrations.shared.utils import drop_fks_for_table, has_table
from superset.migrations.shared.utils import create_table, drop_fks_for_table, has_table
# revision identifiers, used by Alembic.
revision = "48cbb571fa3a"
@@ -41,7 +41,7 @@ def upgrade():
def downgrade():
op.create_table(
create_table(
table_name,
sa.Column("uuid", sa.Numeric(precision=16), nullable=True),
sa.Column("created_on", sa.DateTime(), nullable=True),

View File

@@ -866,7 +866,7 @@ class TestCore(SupersetTestCase):
self.login(ADMIN_USERNAME)
resp = self.client.get("superset/dashboard/p/123/")
expected_url = "/superset/dashboard/1?permalink_key=123&standalone=3"
expected_url = "/superset/dashboard/1/?permalink_key=123&standalone=3"
assert resp.headers["Location"] == expected_url
assert resp.status_code == 302

View File

@@ -119,7 +119,7 @@ class TestDashboard(SupersetTestCase):
dash_count_after = db.session.query(func.count(Dashboard.id)).first()[0]
assert dash_count_before + 1 == dash_count_after
group = re.match(
r"\/superset\/dashboard\/([0-9]*)\/\?edit=true",
r"\/superset\/dashboard\/([0-9]*)\/\?edit=True",
response.headers["Location"],
)
assert group is not None