142 lines
6.3 KiB
Python
142 lines
6.3 KiB
Python
"""Initial migration.
|
|
|
|
Revision ID: d3026757c7cb
|
|
Revises:
|
|
Create Date: 2021-12-19 20:34:34.122576
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
import flaschengeist
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = "d3026757c7cb"
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table(
|
|
"image",
|
|
sa.Column("id", flaschengeist.models.Serial(), nullable=False),
|
|
sa.Column("filename_", sa.String(length=127), nullable=False),
|
|
sa.Column("mimetype_", sa.String(length=30), nullable=False),
|
|
sa.Column("thumbnail_", sa.String(length=127), nullable=True),
|
|
sa.Column("path_", sa.String(length=127), nullable=True),
|
|
sa.PrimaryKeyConstraint("id", name=op.f("pk_image")),
|
|
)
|
|
op.create_table(
|
|
"permission",
|
|
sa.Column("name", sa.String(length=30), nullable=True),
|
|
sa.Column("id", flaschengeist.models.Serial(), nullable=False),
|
|
sa.PrimaryKeyConstraint("id", name=op.f("pk_permission")),
|
|
sa.UniqueConstraint("name", name=op.f("uq_permission_name")),
|
|
)
|
|
op.create_table(
|
|
"plugin_setting",
|
|
sa.Column("id", flaschengeist.models.Serial(), nullable=False),
|
|
sa.Column("plugin", sa.String(length=30), nullable=True),
|
|
sa.Column("name", sa.String(length=30), nullable=False),
|
|
sa.Column("value", sa.PickleType(), nullable=True),
|
|
sa.PrimaryKeyConstraint("id", name=op.f("pk_plugin_setting")),
|
|
)
|
|
op.create_table(
|
|
"role",
|
|
sa.Column("id", flaschengeist.models.Serial(), nullable=False),
|
|
sa.Column("name", sa.String(length=30), nullable=True),
|
|
sa.PrimaryKeyConstraint("id", name=op.f("pk_role")),
|
|
sa.UniqueConstraint("name", name=op.f("uq_role_name")),
|
|
)
|
|
op.create_table(
|
|
"role_x_permission",
|
|
sa.Column("role_id", flaschengeist.models.Serial(), nullable=True),
|
|
sa.Column("permission_id", flaschengeist.models.Serial(), nullable=True),
|
|
sa.ForeignKeyConstraint(
|
|
["permission_id"], ["permission.id"], name=op.f("fk_role_x_permission_permission_id_permission")
|
|
),
|
|
sa.ForeignKeyConstraint(["role_id"], ["role.id"], name=op.f("fk_role_x_permission_role_id_role")),
|
|
)
|
|
op.create_table(
|
|
"user",
|
|
sa.Column("userid", sa.String(length=30), nullable=False),
|
|
sa.Column("display_name", sa.String(length=30), nullable=True),
|
|
sa.Column("firstname", sa.String(length=50), nullable=False),
|
|
sa.Column("lastname", sa.String(length=50), nullable=False),
|
|
sa.Column("deleted", sa.Boolean(), nullable=True),
|
|
sa.Column("birthday", sa.Date(), nullable=True),
|
|
sa.Column("mail", sa.String(length=60), nullable=True),
|
|
sa.Column("id", flaschengeist.models.Serial(), nullable=False),
|
|
sa.Column("avatar", flaschengeist.models.Serial(), nullable=True),
|
|
sa.ForeignKeyConstraint(["avatar"], ["image.id"], name=op.f("fk_user_avatar_image")),
|
|
sa.PrimaryKeyConstraint("id", name=op.f("pk_user")),
|
|
sa.UniqueConstraint("userid", name=op.f("uq_user_userid")),
|
|
)
|
|
op.create_table(
|
|
"notification",
|
|
sa.Column("id", flaschengeist.models.Serial(), nullable=False),
|
|
sa.Column("plugin", sa.String(length=127), nullable=False),
|
|
sa.Column("text", sa.Text(), nullable=True),
|
|
sa.Column("data", sa.PickleType(), nullable=True),
|
|
sa.Column("time", flaschengeist.models.UtcDateTime(), nullable=False),
|
|
sa.Column("user_id", flaschengeist.models.Serial(), nullable=False),
|
|
sa.ForeignKeyConstraint(["user_id"], ["user.id"], name=op.f("fk_notification_user_id_user")),
|
|
sa.PrimaryKeyConstraint("id", name=op.f("pk_notification")),
|
|
)
|
|
op.create_table(
|
|
"password_reset",
|
|
sa.Column("user", flaschengeist.models.Serial(), nullable=False),
|
|
sa.Column("token", sa.String(length=32), nullable=True),
|
|
sa.Column("expires", flaschengeist.models.UtcDateTime(), nullable=True),
|
|
sa.ForeignKeyConstraint(["user"], ["user.id"], name=op.f("fk_password_reset_user_user")),
|
|
sa.PrimaryKeyConstraint("user", name=op.f("pk_password_reset")),
|
|
)
|
|
op.create_table(
|
|
"session",
|
|
sa.Column("expires", flaschengeist.models.UtcDateTime(), nullable=True),
|
|
sa.Column("token", sa.String(length=32), nullable=True),
|
|
sa.Column("lifetime", sa.Integer(), nullable=True),
|
|
sa.Column("browser", sa.String(length=30), nullable=True),
|
|
sa.Column("platform", sa.String(length=30), nullable=True),
|
|
sa.Column("id", flaschengeist.models.Serial(), nullable=False),
|
|
sa.Column("user_id", flaschengeist.models.Serial(), nullable=True),
|
|
sa.ForeignKeyConstraint(["user_id"], ["user.id"], name=op.f("fk_session_user_id_user")),
|
|
sa.PrimaryKeyConstraint("id", name=op.f("pk_session")),
|
|
sa.UniqueConstraint("token", name=op.f("uq_session_token")),
|
|
)
|
|
op.create_table(
|
|
"user_attribute",
|
|
sa.Column("id", flaschengeist.models.Serial(), nullable=False),
|
|
sa.Column("user", flaschengeist.models.Serial(), nullable=False),
|
|
sa.Column("name", sa.String(length=30), nullable=True),
|
|
sa.Column("value", sa.PickleType(), nullable=True),
|
|
sa.ForeignKeyConstraint(["user"], ["user.id"], name=op.f("fk_user_attribute_user_user")),
|
|
sa.PrimaryKeyConstraint("id", name=op.f("pk_user_attribute")),
|
|
)
|
|
op.create_table(
|
|
"user_x_role",
|
|
sa.Column("user_id", flaschengeist.models.Serial(), nullable=True),
|
|
sa.Column("role_id", flaschengeist.models.Serial(), nullable=True),
|
|
sa.ForeignKeyConstraint(["role_id"], ["role.id"], name=op.f("fk_user_x_role_role_id_role")),
|
|
sa.ForeignKeyConstraint(["user_id"], ["user.id"], name=op.f("fk_user_x_role_user_id_user")),
|
|
)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_table("user_x_role")
|
|
op.drop_table("user_attribute")
|
|
op.drop_table("session")
|
|
op.drop_table("password_reset")
|
|
op.drop_table("notification")
|
|
op.drop_table("user")
|
|
op.drop_table("role_x_permission")
|
|
op.drop_table("role")
|
|
op.drop_table("plugin_setting")
|
|
op.drop_table("permission")
|
|
op.drop_table("image")
|
|
# ### end Alembic commands ###
|