mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2026-05-09 18:27:56 +08:00
🚚 修改 nonebot_bison 项目结构 (#211)
* 🎨 修改 nonebot_bison 目录位置 * auto fix by pre-commit hooks * 🚚 fix frontend build target * 🚚 use soft link * Revert "🚚 use soft link" This reverts commit de21f79d5ae1bd5515b04f42a4138cb25ddf3e62. * 🚚 modify dockerfile --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: felinae98 <731499577@qq.com>
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
"""init db
|
||||
|
||||
Revision ID: 0571870f5222
|
||||
Revises:
|
||||
Create Date: 2022-03-21 19:18:13.762626
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "0571870f5222"
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
"target",
|
||||
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column("platform_name", sa.String(length=20), nullable=False),
|
||||
sa.Column("target", sa.String(length=1024), nullable=False),
|
||||
sa.Column("target_name", sa.String(length=1024), nullable=False),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.create_table(
|
||||
"user",
|
||||
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column("type", sa.String(length=20), nullable=False),
|
||||
sa.Column("uid", sa.Integer(), nullable=False),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.create_table(
|
||||
"subscribe",
|
||||
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column("target_id", sa.Integer(), nullable=True),
|
||||
sa.Column("user_id", sa.Integer(), nullable=True),
|
||||
sa.Column("categories", sa.String(length=1024), nullable=True),
|
||||
sa.Column("tags", sa.String(length=1024), nullable=True),
|
||||
sa.ForeignKeyConstraint(
|
||||
["target_id"],
|
||||
["target.id"],
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["user_id"],
|
||||
["user.id"],
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table("subscribe")
|
||||
op.drop_table("user")
|
||||
op.drop_table("target")
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,55 @@
|
||||
"""alter type
|
||||
|
||||
Revision ID: 4a46ba54a3f3
|
||||
Revises: c97c445e2bdb
|
||||
Create Date: 2022-03-27 21:50:10.911649
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "4a46ba54a3f3"
|
||||
down_revision = "c97c445e2bdb"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table("subscribe", schema=None) as batch_op:
|
||||
batch_op.alter_column(
|
||||
"categories",
|
||||
existing_type=sa.VARCHAR(length=1024),
|
||||
type_=sa.JSON(),
|
||||
existing_nullable=True,
|
||||
postgresql_using="categories::json",
|
||||
)
|
||||
batch_op.alter_column(
|
||||
"tags",
|
||||
existing_type=sa.VARCHAR(length=1024),
|
||||
type_=sa.JSON(),
|
||||
existing_nullable=True,
|
||||
postgresql_using="tags::json",
|
||||
)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table("subscribe", schema=None) as batch_op:
|
||||
batch_op.alter_column(
|
||||
"tags",
|
||||
existing_type=sa.JSON(),
|
||||
type_=sa.VARCHAR(length=1024),
|
||||
existing_nullable=True,
|
||||
)
|
||||
batch_op.alter_column(
|
||||
"categories",
|
||||
existing_type=sa.JSON(),
|
||||
type_=sa.VARCHAR(length=1024),
|
||||
existing_nullable=True,
|
||||
)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,33 @@
|
||||
"""rename tables
|
||||
|
||||
Revision ID: 5da28f6facb3
|
||||
Revises: 5f3370328e44
|
||||
Create Date: 2023-01-15 19:04:54.987491
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "5da28f6facb3"
|
||||
down_revision = "5f3370328e44"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.rename_table("target", "nonebot_bison_target")
|
||||
op.rename_table("user", "nonebot_bison_user")
|
||||
op.rename_table("schedule_time_weight", "nonebot_bison_scheduletimeweight")
|
||||
op.rename_table("subscribe", "nonebot_bison_subscribe")
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.rename_table("nonebot_bison_subscribe", "subscribe")
|
||||
op.rename_table("nonebot_bison_scheduletimeweight", "schedule_time_weight")
|
||||
op.rename_table("nonebot_bison_user", "user")
|
||||
op.rename_table("nonebot_bison_target", "target")
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,51 @@
|
||||
"""add time-weight table
|
||||
|
||||
Revision ID: 5f3370328e44
|
||||
Revises: a333d6224193
|
||||
Create Date: 2022-05-31 22:05:13.235981
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "5f3370328e44"
|
||||
down_revision = "a333d6224193"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
"schedule_time_weight",
|
||||
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column("target_id", sa.Integer(), nullable=True),
|
||||
sa.Column("start_time", sa.Time(), nullable=True),
|
||||
sa.Column("end_time", sa.Time(), nullable=True),
|
||||
sa.Column("weight", sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(
|
||||
["target_id"],
|
||||
["target.id"],
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
with op.batch_alter_table("target", schema=None) as batch_op:
|
||||
batch_op.add_column(
|
||||
sa.Column("default_schedule_weight", sa.Integer(), nullable=True)
|
||||
)
|
||||
batch_op.drop_column("last_schedule_time")
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table("target", schema=None) as batch_op:
|
||||
batch_op.add_column(
|
||||
sa.Column("last_schedule_time", sa.DATETIME(), nullable=True)
|
||||
)
|
||||
batch_op.drop_column("default_schedule_weight")
|
||||
|
||||
op.drop_table("schedule_time_weight")
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,33 @@
|
||||
"""add last scheduled time
|
||||
|
||||
Revision ID: a333d6224193
|
||||
Revises: 4a46ba54a3f3
|
||||
Create Date: 2022-03-29 21:01:38.213153
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "a333d6224193"
|
||||
down_revision = "4a46ba54a3f3"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table("target", schema=None) as batch_op:
|
||||
batch_op.add_column(
|
||||
sa.Column("last_schedule_time", sa.DateTime(timezone=True), nullable=True)
|
||||
)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table("target", schema=None) as batch_op:
|
||||
batch_op.drop_column("last_schedule_time")
|
||||
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,52 @@
|
||||
"""alter_json_not_null
|
||||
|
||||
Revision ID: bd92923c218f
|
||||
Revises: 5da28f6facb3
|
||||
Create Date: 2023-03-02 14:04:16.492133
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.automap import automap_base
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "bd92923c218f"
|
||||
down_revision = "5da28f6facb3"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def set_default_value():
|
||||
Base = automap_base()
|
||||
Base.prepare(autoload_with=op.get_bind())
|
||||
Subscribe = Base.classes.nonebot_bison_subscribe
|
||||
with Session(op.get_bind()) as session:
|
||||
select_statement = select(Subscribe)
|
||||
results = session.scalars(select_statement)
|
||||
for subscribe in results:
|
||||
if subscribe.categories is None:
|
||||
subscribe.categories = []
|
||||
if subscribe.tags is None:
|
||||
subscribe.tags = []
|
||||
session.commit()
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
set_default_value()
|
||||
with op.batch_alter_table("nonebot_bison_subscribe", schema=None) as batch_op:
|
||||
batch_op.alter_column("categories", existing_type=sa.JSON(), nullable=False)
|
||||
batch_op.alter_column("tags", existing_type=sa.JSON(), nullable=False)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table("nonebot_bison_subscribe", schema=None) as batch_op:
|
||||
batch_op.alter_column("tags", existing_type=sa.JSON(), nullable=True)
|
||||
batch_op.alter_column("categories", existing_type=sa.JSON(), nullable=True)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,47 @@
|
||||
"""add constraint
|
||||
|
||||
Revision ID: c97c445e2bdb
|
||||
Revises: 0571870f5222
|
||||
Create Date: 2022-03-26 19:46:50.910721
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "c97c445e2bdb"
|
||||
down_revision = "0571870f5222"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table("subscribe", schema=None) as batch_op:
|
||||
batch_op.create_unique_constraint(
|
||||
"unique-subscribe-constraint", ["target_id", "user_id"]
|
||||
)
|
||||
|
||||
with op.batch_alter_table("target", schema=None) as batch_op:
|
||||
batch_op.create_unique_constraint(
|
||||
"unique-target-constraint", ["target", "platform_name"]
|
||||
)
|
||||
|
||||
with op.batch_alter_table("user", schema=None) as batch_op:
|
||||
batch_op.create_unique_constraint("unique-user-constraint", ["type", "uid"])
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table("user", schema=None) as batch_op:
|
||||
batch_op.drop_constraint("unique-user-constraint", type_="unique")
|
||||
|
||||
with op.batch_alter_table("target", schema=None) as batch_op:
|
||||
batch_op.drop_constraint("unique-target-constraint", type_="unique")
|
||||
|
||||
with op.batch_alter_table("subscribe", schema=None) as batch_op:
|
||||
batch_op.drop_constraint("unique-subscribe-constraint", type_="unique")
|
||||
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user