84 lines
3.0 KiB
Python
84 lines
3.0 KiB
Python
"""Added StorageItem
|
|
|
|
Revision ID: 44255816ff7b
|
|
Revises: 8ac2bed1718e
|
|
Create Date: 2023-05-25 12:29:44.913484
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
import ormar
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = "44255816ff7b"
|
|
down_revision = "8ac2bed1718e"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table(
|
|
"storage_items",
|
|
sa.Column("id", ormar.fields.sqlalchemy_uuid.CHAR(32), nullable=False),
|
|
sa.Column("uploaded_at", sa.DateTime(), nullable=False),
|
|
sa.Column("mime_type", sa.Text(), nullable=False),
|
|
sa.Column("hash", sa.LargeBinary(length=16), nullable=True),
|
|
sa.Column("user", ormar.fields.sqlalchemy_uuid.CHAR(32), nullable=True),
|
|
sa.Column("size", sa.BigInteger(), nullable=False),
|
|
sa.Column("storage_path", sa.Text(), nullable=True),
|
|
sa.Column("deleted_at", sa.DateTime(), nullable=True),
|
|
sa.Column("alt_text", sa.Text(), nullable=True),
|
|
sa.Column("filename", sa.Text(), nullable=True),
|
|
sa.ForeignKeyConstraint(["user"], ["users.id"], name="fk_storage_items_users_id_user"),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_table(
|
|
"storageitems_quizs",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("quiz", ormar.fields.sqlalchemy_uuid.CHAR(32), nullable=True),
|
|
sa.Column("storageitem", ormar.fields.sqlalchemy_uuid.CHAR(32), nullable=True),
|
|
sa.ForeignKeyConstraint(
|
|
["quiz"], ["quiz.id"], name="fk_storageitems_quizs_quiz_quiz_id", onupdate="CASCADE", ondelete="CASCADE"
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["storageitem"],
|
|
["storage_items.id"],
|
|
name="fk_storageitems_quizs_storage_items_storageitem_id",
|
|
onupdate="CASCADE",
|
|
ondelete="CASCADE",
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_table(
|
|
"storageitems_quiztivitys",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("quiztivity", ormar.fields.sqlalchemy_uuid.CHAR(32), nullable=True),
|
|
sa.Column("storageitem", ormar.fields.sqlalchemy_uuid.CHAR(32), nullable=True),
|
|
sa.ForeignKeyConstraint(
|
|
["quiztivity"],
|
|
["quiztivitys.id"],
|
|
name="fk_storageitems_quiztivitys_quiztivitys_quiztivity_id",
|
|
onupdate="CASCADE",
|
|
ondelete="CASCADE",
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["storageitem"],
|
|
["storage_items.id"],
|
|
name="fk_storageitems_quiztivitys_storage_items_storageitem_id",
|
|
onupdate="CASCADE",
|
|
ondelete="CASCADE",
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_table("storageitems_quiztivitys")
|
|
op.drop_table("storageitems_quizs")
|
|
op.drop_table("storage_items")
|
|
# ### end Alembic commands ###
|