style: 统一 Ruff 代码格式
This commit is contained in:
@@ -39,7 +39,9 @@ def _add_column_if_missing(bind, table_name: str, column: sa.Column) -> bool:
|
||||
return True
|
||||
|
||||
|
||||
def _create_index_if_missing(bind, name: str, table_name: str, columns: list[str], unique: bool = False) -> None:
|
||||
def _create_index_if_missing(
|
||||
bind, name: str, table_name: str, columns: list[str], unique: bool = False
|
||||
) -> None:
|
||||
if name not in _indexes(bind, table_name):
|
||||
op.create_index(name, table_name, columns, unique=unique)
|
||||
|
||||
@@ -62,8 +64,12 @@ def upgrade() -> None:
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
else:
|
||||
_add_column_if_missing(bind, "users", sa.Column("custom_permissions", sa.JSON(), nullable=True))
|
||||
_create_index_if_missing(bind, "ix_users_username", "users", ["username"], unique=True)
|
||||
_add_column_if_missing(
|
||||
bind, "users", sa.Column("custom_permissions", sa.JSON(), nullable=True)
|
||||
)
|
||||
_create_index_if_missing(
|
||||
bind, "ix_users_username", "users", ["username"], unique=True
|
||||
)
|
||||
|
||||
if not _has_table(bind, "accounts"):
|
||||
op.create_table(
|
||||
@@ -84,8 +90,14 @@ def upgrade() -> None:
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
else:
|
||||
_add_column_if_missing(bind, "accounts", sa.Column("tag", sa.String(length=64), server_default=""))
|
||||
added_ssl = _add_column_if_missing(bind, "accounts", sa.Column("email_imap_ssl", sa.Boolean(), server_default=sa.text("1")))
|
||||
_add_column_if_missing(
|
||||
bind, "accounts", sa.Column("tag", sa.String(length=64), server_default="")
|
||||
)
|
||||
added_ssl = _add_column_if_missing(
|
||||
bind,
|
||||
"accounts",
|
||||
sa.Column("email_imap_ssl", sa.Boolean(), server_default=sa.text("1")),
|
||||
)
|
||||
if added_ssl:
|
||||
op.execute(
|
||||
"UPDATE accounts SET email_imap_port = 143, email_imap_ssl = 0 "
|
||||
@@ -95,7 +107,9 @@ def upgrade() -> None:
|
||||
"UPDATE accounts SET email_imap_port = 143, email_imap_ssl = 0 "
|
||||
"WHERE email_imap_server = 'mail.bdhg.xyz'"
|
||||
)
|
||||
_create_index_if_missing(bind, "ix_accounts_assigned_to", "accounts", ["assigned_to"])
|
||||
_create_index_if_missing(
|
||||
bind, "ix_accounts_assigned_to", "accounts", ["assigned_to"]
|
||||
)
|
||||
|
||||
if not _has_table(bind, "proxy_config"):
|
||||
op.create_table(
|
||||
@@ -127,7 +141,9 @@ def upgrade() -> None:
|
||||
sa.ForeignKeyConstraint(["created_by"], ["users.id"]),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
_create_index_if_missing(bind, "ix_login_tasks_batch_id", "login_tasks", ["batch_id"])
|
||||
_create_index_if_missing(
|
||||
bind, "ix_login_tasks_batch_id", "login_tasks", ["batch_id"]
|
||||
)
|
||||
|
||||
if not _has_table(bind, "audit_logs"):
|
||||
op.create_table(
|
||||
|
||||
@@ -19,16 +19,30 @@ depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
def upgrade() -> None:
|
||||
with op.batch_alter_table("accounts") as batch:
|
||||
batch.alter_column("password", existing_type=sa.String(length=256), type_=sa.Text())
|
||||
batch.alter_column("email", existing_type=sa.String(length=128), type_=sa.Text())
|
||||
batch.alter_column("email_password", existing_type=sa.String(length=256), type_=sa.Text())
|
||||
batch.alter_column(
|
||||
"password", existing_type=sa.String(length=256), type_=sa.Text()
|
||||
)
|
||||
batch.alter_column(
|
||||
"email", existing_type=sa.String(length=128), type_=sa.Text()
|
||||
)
|
||||
batch.alter_column(
|
||||
"email_password", existing_type=sa.String(length=256), type_=sa.Text()
|
||||
)
|
||||
|
||||
with op.batch_alter_table("proxy_config") as batch:
|
||||
batch.alter_column("api_url", existing_type=sa.String(length=512), type_=sa.Text())
|
||||
batch.alter_column(
|
||||
"api_url", existing_type=sa.String(length=512), type_=sa.Text()
|
||||
)
|
||||
batch.alter_column("http", existing_type=sa.String(length=256), type_=sa.Text())
|
||||
batch.alter_column("https", existing_type=sa.String(length=256), type_=sa.Text())
|
||||
batch.alter_column("whitelist_uid", existing_type=sa.String(length=64), type_=sa.Text())
|
||||
batch.alter_column("whitelist_ukey", existing_type=sa.String(length=128), type_=sa.Text())
|
||||
batch.alter_column(
|
||||
"https", existing_type=sa.String(length=256), type_=sa.Text()
|
||||
)
|
||||
batch.alter_column(
|
||||
"whitelist_uid", existing_type=sa.String(length=64), type_=sa.Text()
|
||||
)
|
||||
batch.alter_column(
|
||||
"whitelist_ukey", existing_type=sa.String(length=128), type_=sa.Text()
|
||||
)
|
||||
|
||||
with op.batch_alter_table("login_tasks") as batch:
|
||||
batch.alter_column("cookie", existing_type=sa.Text(), type_=sa.Text())
|
||||
@@ -39,13 +53,27 @@ def downgrade() -> None:
|
||||
batch.alter_column("cookie", existing_type=sa.Text(), type_=sa.Text())
|
||||
|
||||
with op.batch_alter_table("proxy_config") as batch:
|
||||
batch.alter_column("whitelist_ukey", existing_type=sa.Text(), type_=sa.String(length=128))
|
||||
batch.alter_column("whitelist_uid", existing_type=sa.Text(), type_=sa.String(length=64))
|
||||
batch.alter_column("https", existing_type=sa.Text(), type_=sa.String(length=256))
|
||||
batch.alter_column(
|
||||
"whitelist_ukey", existing_type=sa.Text(), type_=sa.String(length=128)
|
||||
)
|
||||
batch.alter_column(
|
||||
"whitelist_uid", existing_type=sa.Text(), type_=sa.String(length=64)
|
||||
)
|
||||
batch.alter_column(
|
||||
"https", existing_type=sa.Text(), type_=sa.String(length=256)
|
||||
)
|
||||
batch.alter_column("http", existing_type=sa.Text(), type_=sa.String(length=256))
|
||||
batch.alter_column("api_url", existing_type=sa.Text(), type_=sa.String(length=512))
|
||||
batch.alter_column(
|
||||
"api_url", existing_type=sa.Text(), type_=sa.String(length=512)
|
||||
)
|
||||
|
||||
with op.batch_alter_table("accounts") as batch:
|
||||
batch.alter_column("email_password", existing_type=sa.Text(), type_=sa.String(length=256))
|
||||
batch.alter_column("email", existing_type=sa.Text(), type_=sa.String(length=128))
|
||||
batch.alter_column("password", existing_type=sa.Text(), type_=sa.String(length=256))
|
||||
batch.alter_column(
|
||||
"email_password", existing_type=sa.Text(), type_=sa.String(length=256)
|
||||
)
|
||||
batch.alter_column(
|
||||
"email", existing_type=sa.Text(), type_=sa.String(length=128)
|
||||
)
|
||||
batch.alter_column(
|
||||
"password", existing_type=sa.Text(), type_=sa.String(length=256)
|
||||
)
|
||||
|
||||
@@ -22,9 +22,7 @@ def upgrade() -> None:
|
||||
batch.add_column(
|
||||
sa.Column("whitelist_platform", sa.String(32), server_default="xiequ")
|
||||
)
|
||||
batch.add_column(
|
||||
sa.Column("whitelist_credentials", sa.JSON(), nullable=True)
|
||||
)
|
||||
batch.add_column(sa.Column("whitelist_credentials", sa.JSON(), nullable=True))
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
|
||||
@@ -27,7 +27,9 @@ def _indexes(bind, table_name: str) -> set[str]:
|
||||
return {index["name"] for index in sa.inspect(bind).get_indexes(table_name)}
|
||||
|
||||
|
||||
def _create_index_if_missing(bind, name: str, table_name: str, columns: list[str], unique: bool = False) -> None:
|
||||
def _create_index_if_missing(
|
||||
bind, name: str, table_name: str, columns: list[str], unique: bool = False
|
||||
) -> None:
|
||||
if name not in _indexes(bind, table_name):
|
||||
op.create_index(name, table_name, columns, unique=unique)
|
||||
|
||||
@@ -59,7 +61,9 @@ def upgrade() -> None:
|
||||
)
|
||||
_create_index_if_missing(bind, "ix_huya_accounts_uid", "huya_accounts", ["uid"])
|
||||
_create_index_if_missing(bind, "ix_huya_accounts_yyuid", "huya_accounts", ["yyuid"])
|
||||
_create_index_if_missing(bind, "ix_huya_accounts_assigned_to", "huya_accounts", ["assigned_to"])
|
||||
_create_index_if_missing(
|
||||
bind, "ix_huya_accounts_assigned_to", "huya_accounts", ["assigned_to"]
|
||||
)
|
||||
|
||||
if not _has_table(bind, "huya_tasks"):
|
||||
op.create_table(
|
||||
@@ -79,7 +83,9 @@ def upgrade() -> None:
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
_create_index_if_missing(bind, "ix_huya_tasks_batch_id", "huya_tasks", ["batch_id"])
|
||||
_create_index_if_missing(bind, "ix_huya_tasks_task_type", "huya_tasks", ["task_type"])
|
||||
_create_index_if_missing(
|
||||
bind, "ix_huya_tasks_task_type", "huya_tasks", ["task_type"]
|
||||
)
|
||||
|
||||
if not _has_table(bind, "huya_config"):
|
||||
op.create_table(
|
||||
@@ -106,13 +112,17 @@ def upgrade() -> None:
|
||||
sa.Column("updated_at", sa.DateTime(), nullable=True),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
_create_index_if_missing(bind, "ix_huya_goods_snapshot_product_id", "huya_goods_snapshot", ["product_id"])
|
||||
_create_index_if_missing(
|
||||
bind, "ix_huya_goods_snapshot_product_id", "huya_goods_snapshot", ["product_id"]
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
if _has_table(bind, "huya_goods_snapshot"):
|
||||
op.drop_index("ix_huya_goods_snapshot_product_id", table_name="huya_goods_snapshot")
|
||||
op.drop_index(
|
||||
"ix_huya_goods_snapshot_product_id", table_name="huya_goods_snapshot"
|
||||
)
|
||||
op.drop_table("huya_goods_snapshot")
|
||||
if _has_table(bind, "huya_config"):
|
||||
op.drop_table("huya_config")
|
||||
|
||||
@@ -27,7 +27,9 @@ def _indexes(bind, table_name: str) -> set[str]:
|
||||
return {index["name"] for index in sa.inspect(bind).get_indexes(table_name)}
|
||||
|
||||
|
||||
def _create_index_if_missing(bind, name: str, table_name: str, columns: list[str], unique: bool = False) -> None:
|
||||
def _create_index_if_missing(
|
||||
bind, name: str, table_name: str, columns: list[str], unique: bool = False
|
||||
) -> None:
|
||||
if name not in _indexes(bind, table_name):
|
||||
op.create_index(name, table_name, columns, unique=unique)
|
||||
|
||||
@@ -71,7 +73,13 @@ def downgrade() -> None:
|
||||
if _has_table(bind, "huya_recharge_goods_snapshot"):
|
||||
indexes = _indexes(bind, "huya_recharge_goods_snapshot")
|
||||
if "ix_huya_recharge_goods_snapshot_sku_id" in indexes:
|
||||
op.drop_index("ix_huya_recharge_goods_snapshot_sku_id", table_name="huya_recharge_goods_snapshot")
|
||||
op.drop_index(
|
||||
"ix_huya_recharge_goods_snapshot_sku_id",
|
||||
table_name="huya_recharge_goods_snapshot",
|
||||
)
|
||||
if "ix_huya_recharge_goods_snapshot_spu_id" in indexes:
|
||||
op.drop_index("ix_huya_recharge_goods_snapshot_spu_id", table_name="huya_recharge_goods_snapshot")
|
||||
op.drop_index(
|
||||
"ix_huya_recharge_goods_snapshot_spu_id",
|
||||
table_name="huya_recharge_goods_snapshot",
|
||||
)
|
||||
op.drop_table("huya_recharge_goods_snapshot")
|
||||
|
||||
@@ -59,9 +59,17 @@ def upgrade() -> None:
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
sa.UniqueConstraint("batch_id"),
|
||||
)
|
||||
op.create_index("ix_huya_register_batches_batch_id", "huya_register_batches", ["batch_id"])
|
||||
op.create_index("ix_huya_register_batches_created_by", "huya_register_batches", ["created_by"])
|
||||
op.create_index("ix_huya_register_batches_status", "huya_register_batches", ["status"])
|
||||
op.create_index(
|
||||
"ix_huya_register_batches_batch_id", "huya_register_batches", ["batch_id"]
|
||||
)
|
||||
op.create_index(
|
||||
"ix_huya_register_batches_created_by",
|
||||
"huya_register_batches",
|
||||
["created_by"],
|
||||
)
|
||||
op.create_index(
|
||||
"ix_huya_register_batches_status", "huya_register_batches", ["status"]
|
||||
)
|
||||
|
||||
if not _has_table(bind, "huya_register_items"):
|
||||
op.create_table(
|
||||
@@ -91,10 +99,18 @@ def upgrade() -> None:
|
||||
sa.ForeignKeyConstraint(["batch_db_id"], ["huya_register_batches.id"]),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.create_index("ix_huya_register_items_batch_db_id", "huya_register_items", ["batch_db_id"])
|
||||
op.create_index("ix_huya_register_items_batch_id", "huya_register_items", ["batch_id"])
|
||||
op.create_index("ix_huya_register_items_phone", "huya_register_items", ["phone"])
|
||||
op.create_index("ix_huya_register_items_status", "huya_register_items", ["status"])
|
||||
op.create_index(
|
||||
"ix_huya_register_items_batch_db_id", "huya_register_items", ["batch_db_id"]
|
||||
)
|
||||
op.create_index(
|
||||
"ix_huya_register_items_batch_id", "huya_register_items", ["batch_id"]
|
||||
)
|
||||
op.create_index(
|
||||
"ix_huya_register_items_phone", "huya_register_items", ["phone"]
|
||||
)
|
||||
op.create_index(
|
||||
"ix_huya_register_items_status", "huya_register_items", ["status"]
|
||||
)
|
||||
|
||||
if not _has_table(bind, "huya_register_success_logs"):
|
||||
op.create_table(
|
||||
@@ -116,10 +132,24 @@ def upgrade() -> None:
|
||||
sa.ForeignKeyConstraint(["created_by"], ["users.id"]),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.create_index("ix_huya_register_success_logs_batch_id", "huya_register_success_logs", ["batch_id"])
|
||||
op.create_index("ix_huya_register_success_logs_phone", "huya_register_success_logs", ["phone"])
|
||||
op.create_index("ix_huya_register_success_logs_tag", "huya_register_success_logs", ["tag"])
|
||||
op.create_index("ix_huya_register_success_logs_created_at", "huya_register_success_logs", ["created_at"])
|
||||
op.create_index(
|
||||
"ix_huya_register_success_logs_batch_id",
|
||||
"huya_register_success_logs",
|
||||
["batch_id"],
|
||||
)
|
||||
op.create_index(
|
||||
"ix_huya_register_success_logs_phone",
|
||||
"huya_register_success_logs",
|
||||
["phone"],
|
||||
)
|
||||
op.create_index(
|
||||
"ix_huya_register_success_logs_tag", "huya_register_success_logs", ["tag"]
|
||||
)
|
||||
op.create_index(
|
||||
"ix_huya_register_success_logs_created_at",
|
||||
"huya_register_success_logs",
|
||||
["created_at"],
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
|
||||
@@ -38,7 +38,9 @@ def _add_column_if_missing(bind, table_name: str, column: sa.Column) -> None:
|
||||
op.add_column(table_name, column)
|
||||
|
||||
|
||||
def _create_index_if_missing(bind, name: str, table_name: str, columns: list[str], unique: bool = False) -> None:
|
||||
def _create_index_if_missing(
|
||||
bind, name: str, table_name: str, columns: list[str], unique: bool = False
|
||||
) -> None:
|
||||
if name not in _indexes(bind, table_name):
|
||||
op.create_index(name, table_name, columns, unique=unique)
|
||||
|
||||
@@ -46,16 +48,40 @@ def _create_index_if_missing(bind, name: str, table_name: str, columns: list[str
|
||||
def upgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
|
||||
_add_column_if_missing(bind, "accounts", sa.Column("uid", sa.String(length=32), nullable=True))
|
||||
_add_column_if_missing(bind, "accounts", sa.Column("nickname", sa.String(length=128), nullable=True))
|
||||
_add_column_if_missing(bind, "accounts", sa.Column("points", sa.Integer(), nullable=True))
|
||||
_add_column_if_missing(bind, "accounts", sa.Column("game_name", sa.String(length=128), nullable=True))
|
||||
_add_column_if_missing(bind, "accounts", sa.Column("game_channel", sa.String(length=128), nullable=True))
|
||||
_add_column_if_missing(bind, "accounts", sa.Column("gold_balance", sa.Integer(), nullable=True))
|
||||
_add_column_if_missing(bind, "accounts", sa.Column("exchange_balance", sa.Integer(), nullable=True))
|
||||
_add_column_if_missing(bind, "accounts", sa.Column("bind_status", sa.String(length=32), nullable=True))
|
||||
_add_column_if_missing(bind, "accounts", sa.Column("change_role_wait_time", sa.Integer(), nullable=True))
|
||||
_add_column_if_missing(bind, "accounts", sa.Column("updated_at", sa.DateTime(), nullable=True))
|
||||
_add_column_if_missing(
|
||||
bind, "accounts", sa.Column("uid", sa.String(length=32), nullable=True)
|
||||
)
|
||||
_add_column_if_missing(
|
||||
bind, "accounts", sa.Column("nickname", sa.String(length=128), nullable=True)
|
||||
)
|
||||
_add_column_if_missing(
|
||||
bind, "accounts", sa.Column("points", sa.Integer(), nullable=True)
|
||||
)
|
||||
_add_column_if_missing(
|
||||
bind, "accounts", sa.Column("game_name", sa.String(length=128), nullable=True)
|
||||
)
|
||||
_add_column_if_missing(
|
||||
bind,
|
||||
"accounts",
|
||||
sa.Column("game_channel", sa.String(length=128), nullable=True),
|
||||
)
|
||||
_add_column_if_missing(
|
||||
bind, "accounts", sa.Column("gold_balance", sa.Integer(), nullable=True)
|
||||
)
|
||||
_add_column_if_missing(
|
||||
bind, "accounts", sa.Column("exchange_balance", sa.Integer(), nullable=True)
|
||||
)
|
||||
_add_column_if_missing(
|
||||
bind, "accounts", sa.Column("bind_status", sa.String(length=32), nullable=True)
|
||||
)
|
||||
_add_column_if_missing(
|
||||
bind,
|
||||
"accounts",
|
||||
sa.Column("change_role_wait_time", sa.Integer(), nullable=True),
|
||||
)
|
||||
_add_column_if_missing(
|
||||
bind, "accounts", sa.Column("updated_at", sa.DateTime(), nullable=True)
|
||||
)
|
||||
_create_index_if_missing(bind, "ix_accounts_uid", "accounts", ["uid"])
|
||||
|
||||
if not _has_table(bind, "douyu_tasks"):
|
||||
@@ -75,8 +101,12 @@ def upgrade() -> None:
|
||||
sa.ForeignKeyConstraint(["created_by"], ["users.id"]),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
_create_index_if_missing(bind, "ix_douyu_tasks_batch_id", "douyu_tasks", ["batch_id"])
|
||||
_create_index_if_missing(bind, "ix_douyu_tasks_task_type", "douyu_tasks", ["task_type"])
|
||||
_create_index_if_missing(
|
||||
bind, "ix_douyu_tasks_batch_id", "douyu_tasks", ["batch_id"]
|
||||
)
|
||||
_create_index_if_missing(
|
||||
bind, "ix_douyu_tasks_task_type", "douyu_tasks", ["task_type"]
|
||||
)
|
||||
|
||||
if not _has_table(bind, "douyu_config"):
|
||||
op.create_table(
|
||||
@@ -121,7 +151,10 @@ def downgrade() -> None:
|
||||
if _has_table(bind, "douyu_goods_snapshot"):
|
||||
indexes = _indexes(bind, "douyu_goods_snapshot")
|
||||
if "ix_douyu_goods_snapshot_commodity_id" in indexes:
|
||||
op.drop_index("ix_douyu_goods_snapshot_commodity_id", table_name="douyu_goods_snapshot")
|
||||
op.drop_index(
|
||||
"ix_douyu_goods_snapshot_commodity_id",
|
||||
table_name="douyu_goods_snapshot",
|
||||
)
|
||||
op.drop_table("douyu_goods_snapshot")
|
||||
if _has_table(bind, "douyu_config"):
|
||||
op.drop_table("douyu_config")
|
||||
|
||||
@@ -27,7 +27,9 @@ def _indexes(bind, table_name: str) -> set[str]:
|
||||
return {index["name"] for index in sa.inspect(bind).get_indexes(table_name)}
|
||||
|
||||
|
||||
def _create_index_if_missing(bind, name: str, table_name: str, columns: list[str]) -> None:
|
||||
def _create_index_if_missing(
|
||||
bind, name: str, table_name: str, columns: list[str]
|
||||
) -> None:
|
||||
if name not in _indexes(bind, table_name):
|
||||
op.create_index(name, table_name, columns)
|
||||
|
||||
@@ -50,8 +52,16 @@ INDEXES = [
|
||||
("ix_huya_tasks_account_id", "huya_tasks", ["account_id", "id"]),
|
||||
("ix_huya_tasks_created_by_id", "huya_tasks", ["created_by", "id"]),
|
||||
("ix_huya_tasks_batch_status_id", "huya_tasks", ["batch_id", "status", "id"]),
|
||||
("ix_huya_register_items_batch_db_line", "huya_register_items", ["batch_db_id", "line"]),
|
||||
("ix_huya_register_success_logs_batch_id_id", "huya_register_success_logs", ["batch_id", "id"]),
|
||||
(
|
||||
"ix_huya_register_items_batch_db_line",
|
||||
"huya_register_items",
|
||||
["batch_db_id", "line"],
|
||||
),
|
||||
(
|
||||
"ix_huya_register_success_logs_batch_id_id",
|
||||
"huya_register_success_logs",
|
||||
["batch_id", "id"],
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,10 @@ def upgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
columns = {column["name"] for column in sa.inspect(bind).get_columns("accounts")}
|
||||
if "esports_can_change_time" not in columns:
|
||||
op.add_column("accounts", sa.Column("esports_can_change_time", sa.Integer(), nullable=True))
|
||||
op.add_column(
|
||||
"accounts",
|
||||
sa.Column("esports_can_change_time", sa.Integer(), nullable=True),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
|
||||
@@ -23,7 +23,9 @@ def upgrade() -> None:
|
||||
return
|
||||
columns = {column["name"] for column in sa.inspect(bind).get_columns("accounts")}
|
||||
if "xpd_fragments" not in columns:
|
||||
op.add_column("accounts", sa.Column("xpd_fragments", sa.Integer(), nullable=True))
|
||||
op.add_column(
|
||||
"accounts", sa.Column("xpd_fragments", sa.Integer(), nullable=True)
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
|
||||
@@ -56,10 +56,8 @@ def upgrade() -> None:
|
||||
return
|
||||
|
||||
for index in range(0, len(delete_ids), 500):
|
||||
chunk = delete_ids[index:index + 500]
|
||||
bind.execute(
|
||||
task_table.delete().where(task_table.c.id.in_(chunk))
|
||||
)
|
||||
chunk = delete_ids[index : index + 500]
|
||||
bind.execute(task_table.delete().where(task_table.c.id.in_(chunk)))
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
|
||||
@@ -18,7 +18,9 @@ def upgrade() -> None:
|
||||
"yyb_recharge_tasks",
|
||||
sa.Column("id", sa.Integer(), primary_key=True, autoincrement=True),
|
||||
sa.Column("task_id", sa.String(64), nullable=False),
|
||||
sa.Column("created_by", sa.Integer(), sa.ForeignKey("users.id"), nullable=False),
|
||||
sa.Column(
|
||||
"created_by", sa.Integer(), sa.ForeignKey("users.id"), nullable=False
|
||||
),
|
||||
sa.Column("worker_job_id", sa.String(64), nullable=False),
|
||||
sa.Column("provider", sa.String(16), nullable=False, server_default=""),
|
||||
sa.Column("platform", sa.String(16), nullable=False, server_default="android"),
|
||||
@@ -37,9 +39,15 @@ def upgrade() -> None:
|
||||
sa.Column("created_at", sa.DateTime(), nullable=True),
|
||||
sa.Column("finished_at", sa.DateTime(), nullable=True),
|
||||
)
|
||||
op.create_index("uq_yyb_recharge_tasks_task_id", "yyb_recharge_tasks", ["task_id"], unique=True)
|
||||
op.create_index("ix_yyb_recharge_tasks_created_by", "yyb_recharge_tasks", ["created_by"])
|
||||
op.create_index("ix_yyb_recharge_tasks_worker_job_id", "yyb_recharge_tasks", ["worker_job_id"])
|
||||
op.create_index(
|
||||
"uq_yyb_recharge_tasks_task_id", "yyb_recharge_tasks", ["task_id"], unique=True
|
||||
)
|
||||
op.create_index(
|
||||
"ix_yyb_recharge_tasks_created_by", "yyb_recharge_tasks", ["created_by"]
|
||||
)
|
||||
op.create_index(
|
||||
"ix_yyb_recharge_tasks_worker_job_id", "yyb_recharge_tasks", ["worker_job_id"]
|
||||
)
|
||||
op.create_index("ix_yyb_recharge_tasks_status", "yyb_recharge_tasks", ["status"])
|
||||
|
||||
|
||||
|
||||
@@ -18,8 +18,12 @@ def _is_mysql() -> bool:
|
||||
|
||||
def upgrade() -> None:
|
||||
if _is_mysql():
|
||||
op.execute("ALTER TABLE yyb_recharge_tasks MODIFY login_qr_data MEDIUMTEXT NULL")
|
||||
op.execute("ALTER TABLE yyb_recharge_tasks MODIFY payment_qr_data MEDIUMTEXT NULL")
|
||||
op.execute(
|
||||
"ALTER TABLE yyb_recharge_tasks MODIFY login_qr_data MEDIUMTEXT NULL"
|
||||
)
|
||||
op.execute(
|
||||
"ALTER TABLE yyb_recharge_tasks MODIFY payment_qr_data MEDIUMTEXT NULL"
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
|
||||
@@ -13,10 +13,21 @@ depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.add_column("yyb_recharge_tasks", sa.Column("price_fen", sa.Integer(), nullable=True))
|
||||
op.add_column("yyb_recharge_tasks", sa.Column("payment_started_at", sa.DateTime(), nullable=True))
|
||||
op.add_column("yyb_recharge_tasks", sa.Column("payment_qr_created_at", sa.DateTime(), nullable=True))
|
||||
op.add_column("yyb_recharge_tasks", sa.Column("payment_last_checked_at", sa.DateTime(), nullable=True))
|
||||
op.add_column(
|
||||
"yyb_recharge_tasks", sa.Column("price_fen", sa.Integer(), nullable=True)
|
||||
)
|
||||
op.add_column(
|
||||
"yyb_recharge_tasks",
|
||||
sa.Column("payment_started_at", sa.DateTime(), nullable=True),
|
||||
)
|
||||
op.add_column(
|
||||
"yyb_recharge_tasks",
|
||||
sa.Column("payment_qr_created_at", sa.DateTime(), nullable=True),
|
||||
)
|
||||
op.add_column(
|
||||
"yyb_recharge_tasks",
|
||||
sa.Column("payment_last_checked_at", sa.DateTime(), nullable=True),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
|
||||
@@ -23,7 +23,9 @@ def upgrade() -> None:
|
||||
op.add_column("users", sa.Column("deleted_at", sa.DateTime(), nullable=True))
|
||||
op.create_index("ix_users_deleted_at", "users", ["deleted_at"])
|
||||
if "deleted_username" not in columns:
|
||||
op.add_column("users", sa.Column("deleted_username", sa.String(length=64), nullable=True))
|
||||
op.add_column(
|
||||
"users", sa.Column("deleted_username", sa.String(length=64), nullable=True)
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
|
||||
@@ -26,35 +26,71 @@ def upgrade() -> None:
|
||||
if "handbook_scope" not in _columns(bind, "douyu_tasks"):
|
||||
op.add_column(
|
||||
"douyu_tasks",
|
||||
sa.Column("handbook_scope", sa.String(length=16), nullable=False, server_default="legacy"),
|
||||
sa.Column(
|
||||
"handbook_scope",
|
||||
sa.String(length=16),
|
||||
nullable=False,
|
||||
server_default="legacy",
|
||||
),
|
||||
)
|
||||
op.create_index(
|
||||
"ix_douyu_tasks_handbook_scope", "douyu_tasks", ["handbook_scope"]
|
||||
)
|
||||
op.create_index("ix_douyu_tasks_handbook_scope", "douyu_tasks", ["handbook_scope"])
|
||||
|
||||
if not sa.inspect(bind).has_table("douyu_workbench_accounts"):
|
||||
op.create_table(
|
||||
"douyu_workbench_accounts",
|
||||
sa.Column("id", sa.Integer(), primary_key=True, autoincrement=True),
|
||||
sa.Column("user_id", sa.Integer(), sa.ForeignKey("users.id"), nullable=False),
|
||||
sa.Column(
|
||||
"user_id", sa.Integer(), sa.ForeignKey("users.id"), nullable=False
|
||||
),
|
||||
sa.Column("handbook_scope", sa.String(length=16), nullable=False),
|
||||
sa.Column("account_id", sa.Integer(), sa.ForeignKey("accounts.id"), nullable=False),
|
||||
sa.Column(
|
||||
"account_id", sa.Integer(), sa.ForeignKey("accounts.id"), nullable=False
|
||||
),
|
||||
sa.Column("created_at", sa.DateTime(), nullable=True),
|
||||
sa.UniqueConstraint("user_id", "handbook_scope", "account_id", name="uq_douyu_workbench_account"),
|
||||
sa.UniqueConstraint(
|
||||
"user_id",
|
||||
"handbook_scope",
|
||||
"account_id",
|
||||
name="uq_douyu_workbench_account",
|
||||
),
|
||||
)
|
||||
op.create_index(
|
||||
"ix_douyu_workbench_accounts_user_id",
|
||||
"douyu_workbench_accounts",
|
||||
["user_id"],
|
||||
)
|
||||
op.create_index(
|
||||
"ix_douyu_workbench_accounts_handbook_scope",
|
||||
"douyu_workbench_accounts",
|
||||
["handbook_scope"],
|
||||
)
|
||||
op.create_index(
|
||||
"ix_douyu_workbench_accounts_account_id",
|
||||
"douyu_workbench_accounts",
|
||||
["account_id"],
|
||||
)
|
||||
op.create_index("ix_douyu_workbench_accounts_user_id", "douyu_workbench_accounts", ["user_id"])
|
||||
op.create_index("ix_douyu_workbench_accounts_handbook_scope", "douyu_workbench_accounts", ["handbook_scope"])
|
||||
op.create_index("ix_douyu_workbench_accounts_account_id", "douyu_workbench_accounts", ["account_id"])
|
||||
|
||||
if not sa.inspect(bind).has_table("douyu_workbenches"):
|
||||
op.create_table(
|
||||
"douyu_workbenches",
|
||||
sa.Column("id", sa.Integer(), primary_key=True, autoincrement=True),
|
||||
sa.Column("user_id", sa.Integer(), sa.ForeignKey("users.id"), nullable=False),
|
||||
sa.Column(
|
||||
"user_id", sa.Integer(), sa.ForeignKey("users.id"), nullable=False
|
||||
),
|
||||
sa.Column("handbook_scope", sa.String(length=16), nullable=False),
|
||||
sa.Column("updated_at", sa.DateTime(), nullable=True),
|
||||
sa.UniqueConstraint("user_id", "handbook_scope", name="uq_douyu_workbench"),
|
||||
)
|
||||
op.create_index("ix_douyu_workbenches_user_id", "douyu_workbenches", ["user_id"])
|
||||
op.create_index("ix_douyu_workbenches_handbook_scope", "douyu_workbenches", ["handbook_scope"])
|
||||
op.create_index(
|
||||
"ix_douyu_workbenches_user_id", "douyu_workbenches", ["user_id"]
|
||||
)
|
||||
op.create_index(
|
||||
"ix_douyu_workbenches_handbook_scope",
|
||||
"douyu_workbenches",
|
||||
["handbook_scope"],
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
|
||||
@@ -30,7 +30,9 @@ def upgrade() -> None:
|
||||
sa.UniqueConstraint("user_id", "handbook_scope", name="uq_douyu_workbench"),
|
||||
)
|
||||
op.create_index("ix_douyu_workbenches_user_id", "douyu_workbenches", ["user_id"])
|
||||
op.create_index("ix_douyu_workbenches_handbook_scope", "douyu_workbenches", ["handbook_scope"])
|
||||
op.create_index(
|
||||
"ix_douyu_workbenches_handbook_scope", "douyu_workbenches", ["handbook_scope"]
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
|
||||
@@ -27,9 +27,33 @@ def upgrade() -> None:
|
||||
return
|
||||
columns = _columns(bind)
|
||||
additions = (
|
||||
("gold_recharge_channel", sa.Column("gold_recharge_channel", sa.String(length=16), nullable=True, server_default="wechat_qr")),
|
||||
("gold_api_product_id", sa.Column("gold_api_product_id", sa.String(length=128), nullable=True, server_default="111570")),
|
||||
("gold_api_account_template_name", sa.Column("gold_api_account_template_name", sa.String(length=64), nullable=True, server_default="斗鱼UID")),
|
||||
(
|
||||
"gold_recharge_channel",
|
||||
sa.Column(
|
||||
"gold_recharge_channel",
|
||||
sa.String(length=16),
|
||||
nullable=True,
|
||||
server_default="wechat_qr",
|
||||
),
|
||||
),
|
||||
(
|
||||
"gold_api_product_id",
|
||||
sa.Column(
|
||||
"gold_api_product_id",
|
||||
sa.String(length=128),
|
||||
nullable=True,
|
||||
server_default="111570",
|
||||
),
|
||||
),
|
||||
(
|
||||
"gold_api_account_template_name",
|
||||
sa.Column(
|
||||
"gold_api_account_template_name",
|
||||
sa.String(length=64),
|
||||
nullable=True,
|
||||
server_default="斗鱼UID",
|
||||
),
|
||||
),
|
||||
)
|
||||
for name, column in additions:
|
||||
if name not in columns:
|
||||
@@ -41,6 +65,10 @@ def downgrade() -> None:
|
||||
if not sa.inspect(bind).has_table("douyu_config"):
|
||||
return
|
||||
columns = _columns(bind)
|
||||
for name in ("gold_api_account_template_name", "gold_api_product_id", "gold_recharge_channel"):
|
||||
for name in (
|
||||
"gold_api_account_template_name",
|
||||
"gold_api_product_id",
|
||||
"gold_recharge_channel",
|
||||
):
|
||||
if name in columns:
|
||||
op.drop_column("douyu_config", name)
|
||||
|
||||
@@ -24,7 +24,10 @@ def upgrade() -> None:
|
||||
return
|
||||
columns = {column["name"] for column in inspector.get_columns("douyu_tasks")}
|
||||
if "supplier_out_order_id" not in columns:
|
||||
op.add_column("douyu_tasks", sa.Column("supplier_out_order_id", sa.String(length=64), nullable=True))
|
||||
op.add_column(
|
||||
"douyu_tasks",
|
||||
sa.Column("supplier_out_order_id", sa.String(length=64), nullable=True),
|
||||
)
|
||||
op.create_index(
|
||||
"ix_douyu_tasks_supplier_out_order_id",
|
||||
"douyu_tasks",
|
||||
|
||||
@@ -25,10 +25,17 @@ def upgrade() -> None:
|
||||
return
|
||||
columns = {column["name"] for column in inspector.get_columns("huya_accounts")}
|
||||
if "login_channel" not in columns:
|
||||
op.add_column("huya_accounts", sa.Column("login_channel", sa.String(16), nullable=False, server_default=""))
|
||||
op.add_column(
|
||||
"huya_accounts",
|
||||
sa.Column(
|
||||
"login_channel", sa.String(16), nullable=False, server_default=""
|
||||
),
|
||||
)
|
||||
indexes = {index["name"] for index in inspector.get_indexes("huya_accounts")}
|
||||
if "ix_huya_accounts_login_channel" not in indexes:
|
||||
op.create_index("ix_huya_accounts_login_channel", "huya_accounts", ["login_channel"])
|
||||
op.create_index(
|
||||
"ix_huya_accounts_login_channel", "huya_accounts", ["login_channel"]
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
|
||||
@@ -27,8 +27,16 @@ INDEXES = (
|
||||
["handbook_scope", "task_type", "id"],
|
||||
),
|
||||
# Supports terminal-task retention and finished-time ordered Cookie views.
|
||||
("ix_douyu_tasks_status_finished_at_id", "douyu_tasks", ["status", "finished_at", "id"]),
|
||||
("ix_login_tasks_status_finished_at_id", "login_tasks", ["status", "finished_at", "id"]),
|
||||
(
|
||||
"ix_douyu_tasks_status_finished_at_id",
|
||||
"douyu_tasks",
|
||||
["status", "finished_at", "id"],
|
||||
),
|
||||
(
|
||||
"ix_login_tasks_status_finished_at_id",
|
||||
"login_tasks",
|
||||
["status", "finished_at", "id"],
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user