2022-09-04 05:52:33 +00:00
|
|
|
"""init
|
|
|
|
|
|
|
|
Revision ID: 9e9a36470cd5
|
|
|
|
Revises:
|
|
|
|
Create Date: 2022-09-01 16:55:20.372560
|
|
|
|
|
|
|
|
"""
|
2024-03-16 10:43:20 +00:00
|
|
|
|
2023-03-14 01:27:22 +00:00
|
|
|
from base64 import b64decode
|
|
|
|
|
2022-09-04 05:52:33 +00:00
|
|
|
import sqlalchemy as sa
|
|
|
|
import sqlmodel
|
2023-03-14 01:27:22 +00:00
|
|
|
from alembic import op
|
2022-09-04 05:52:33 +00:00
|
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
|
|
revision = "9e9a36470cd5"
|
|
|
|
down_revision = None
|
|
|
|
branch_labels = None
|
|
|
|
depends_on = None
|
2023-03-14 01:27:22 +00:00
|
|
|
old_cookies_database_name1 = b64decode("bWlob3lvX2Nvb2tpZXM=").decode()
|
|
|
|
old_cookies_database_name2 = b64decode("aG95b3ZlcnNlX2Nvb2tpZXM=").decode()
|
2022-09-04 05:52:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
def upgrade() -> None:
|
|
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
|
|
op.create_table(
|
|
|
|
"question",
|
|
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
2023-03-14 01:27:22 +00:00
|
|
|
sa.Column("text", sqlmodel.AutoString(), nullable=True),
|
2022-09-04 05:52:33 +00:00
|
|
|
sa.PrimaryKeyConstraint("id"),
|
|
|
|
mysql_charset="utf8mb4",
|
|
|
|
mysql_collate="utf8mb4_general_ci",
|
|
|
|
)
|
|
|
|
op.create_table(
|
|
|
|
"user",
|
|
|
|
sa.Column(
|
|
|
|
"region",
|
|
|
|
sa.Enum("NULL", "HYPERION", "HOYOLAB", name="regionenum"),
|
|
|
|
nullable=True,
|
|
|
|
),
|
|
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
2023-03-14 01:27:22 +00:00
|
|
|
sa.Column("user_id", sa.BigInteger(), nullable=False),
|
2022-09-04 05:52:33 +00:00
|
|
|
sa.Column("yuanshen_uid", sa.Integer(), nullable=True),
|
|
|
|
sa.Column("genshin_uid", sa.Integer(), nullable=True),
|
|
|
|
sa.PrimaryKeyConstraint("id"),
|
|
|
|
sa.UniqueConstraint("user_id"),
|
|
|
|
mysql_charset="utf8mb4",
|
|
|
|
mysql_collate="utf8mb4_general_ci",
|
|
|
|
)
|
|
|
|
op.create_table(
|
|
|
|
"admin",
|
|
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
2023-03-14 01:27:22 +00:00
|
|
|
sa.Column("user_id", sa.BigInteger(), nullable=False),
|
2022-09-04 05:52:33 +00:00
|
|
|
sa.ForeignKeyConstraint(
|
|
|
|
["user_id"],
|
|
|
|
["user.user_id"],
|
|
|
|
),
|
|
|
|
sa.PrimaryKeyConstraint("id"),
|
|
|
|
mysql_charset="utf8mb4",
|
|
|
|
mysql_collate="utf8mb4_general_ci",
|
|
|
|
)
|
|
|
|
op.create_table(
|
|
|
|
"answer",
|
|
|
|
sa.Column("question_id", sa.Integer(), nullable=True),
|
|
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
|
|
sa.Column("is_correct", sa.Boolean(), nullable=True),
|
2023-03-14 01:27:22 +00:00
|
|
|
sa.Column("text", sqlmodel.AutoString(), nullable=True),
|
2022-09-04 05:52:33 +00:00
|
|
|
sa.ForeignKeyConstraint(
|
|
|
|
["question_id"],
|
|
|
|
["question.id"],
|
|
|
|
onupdate="RESTRICT",
|
|
|
|
ondelete="RESTRICT",
|
|
|
|
),
|
|
|
|
sa.PrimaryKeyConstraint("id"),
|
|
|
|
mysql_charset="utf8mb4",
|
|
|
|
mysql_collate="utf8mb4_general_ci",
|
|
|
|
)
|
|
|
|
op.create_table(
|
2023-03-14 01:27:22 +00:00
|
|
|
old_cookies_database_name2,
|
2022-09-04 05:52:33 +00:00
|
|
|
sa.Column("cookies", sa.JSON(), nullable=True),
|
|
|
|
sa.Column(
|
|
|
|
"status",
|
|
|
|
sa.Enum(
|
|
|
|
"STATUS_SUCCESS",
|
|
|
|
"INVALID_COOKIES",
|
|
|
|
"TOO_MANY_REQUESTS",
|
|
|
|
name="cookiesstatusenum",
|
|
|
|
),
|
|
|
|
nullable=True,
|
|
|
|
),
|
|
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
2023-03-14 01:27:22 +00:00
|
|
|
sa.Column("user_id", sa.BigInteger(), nullable=True),
|
2022-09-04 05:52:33 +00:00
|
|
|
sa.ForeignKeyConstraint(
|
|
|
|
["user_id"],
|
|
|
|
["user.user_id"],
|
|
|
|
),
|
|
|
|
sa.PrimaryKeyConstraint("id"),
|
|
|
|
mysql_charset="utf8mb4",
|
|
|
|
mysql_collate="utf8mb4_general_ci",
|
|
|
|
)
|
|
|
|
op.create_table(
|
2023-03-14 01:27:22 +00:00
|
|
|
old_cookies_database_name1,
|
2022-09-04 05:52:33 +00:00
|
|
|
sa.Column("cookies", sa.JSON(), nullable=True),
|
|
|
|
sa.Column(
|
|
|
|
"status",
|
|
|
|
sa.Enum(
|
|
|
|
"STATUS_SUCCESS",
|
|
|
|
"INVALID_COOKIES",
|
|
|
|
"TOO_MANY_REQUESTS",
|
|
|
|
name="cookiesstatusenum",
|
|
|
|
),
|
|
|
|
nullable=True,
|
|
|
|
),
|
|
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
2023-03-14 01:27:22 +00:00
|
|
|
sa.Column("user_id", sa.BigInteger(), nullable=True),
|
2022-09-04 05:52:33 +00:00
|
|
|
sa.ForeignKeyConstraint(
|
|
|
|
["user_id"],
|
|
|
|
["user.user_id"],
|
|
|
|
),
|
|
|
|
sa.PrimaryKeyConstraint("id"),
|
|
|
|
mysql_charset="utf8mb4",
|
|
|
|
mysql_collate="utf8mb4_general_ci",
|
|
|
|
)
|
|
|
|
op.create_table(
|
|
|
|
"sign",
|
2023-03-14 01:27:22 +00:00
|
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
|
|
sa.Column("user_id", sa.BigInteger(), nullable=False),
|
|
|
|
sa.Column("chat_id", sa.BigInteger(), nullable=True),
|
2022-09-04 05:52:33 +00:00
|
|
|
sa.Column(
|
|
|
|
"time_created",
|
|
|
|
sa.DateTime(timezone=True),
|
|
|
|
nullable=True,
|
|
|
|
),
|
|
|
|
sa.Column("time_updated", sa.DateTime(timezone=True), nullable=True),
|
|
|
|
sa.Column(
|
|
|
|
"status",
|
|
|
|
sa.Enum(
|
|
|
|
"STATUS_SUCCESS",
|
|
|
|
"INVALID_COOKIES",
|
|
|
|
"ALREADY_CLAIMED",
|
|
|
|
"GENSHIN_EXCEPTION",
|
|
|
|
"TIMEOUT_ERROR",
|
|
|
|
"BAD_REQUEST",
|
|
|
|
"FORBIDDEN",
|
|
|
|
name="signstatusenum",
|
|
|
|
),
|
|
|
|
nullable=True,
|
|
|
|
),
|
2023-03-25 03:17:38 +00:00
|
|
|
sa.ForeignKeyConstraint(["user_id"], ["user.user_id"], "sign_1"),
|
2023-03-14 01:27:22 +00:00
|
|
|
sa.PrimaryKeyConstraint("id", "user_id"),
|
2022-09-04 05:52:33 +00:00
|
|
|
mysql_charset="utf8mb4",
|
|
|
|
mysql_collate="utf8mb4_general_ci",
|
|
|
|
)
|
|
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
|
|
|
|
|
|
def downgrade() -> None:
|
|
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
|
|
op.drop_table("sign")
|
2023-03-14 01:27:22 +00:00
|
|
|
op.drop_table(old_cookies_database_name1)
|
|
|
|
op.drop_table(old_cookies_database_name2)
|
2022-09-04 05:52:33 +00:00
|
|
|
op.drop_table("answer")
|
|
|
|
op.drop_table("admin")
|
|
|
|
op.drop_table("user")
|
|
|
|
op.drop_table("question")
|
|
|
|
# ### end Alembic commands ###
|