🎨 Models: Trip attachments, Backup

This commit is contained in:
itskovacs 2025-10-15 23:43:00 +02:00
parent 196989248e
commit ea1e21042b
2 changed files with 101 additions and 0 deletions

View File

@ -0,0 +1,54 @@
"""Trip Attachment
Revision ID: 032b5b7de8bd
Revises: 11c969913a7e
Create Date: 2025-10-14 21:28:53.830779
"""
import sqlalchemy as sa
import sqlmodel.sql.sqltypes
from alembic import op
# revision identifiers, used by Alembic.
revision = "032b5b7de8bd"
down_revision = "11c969913a7e"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"tripattachment",
sa.Column("filename", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column("file_size", sa.Integer(), nullable=False),
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("uploaded_at", sa.DateTime(), nullable=False),
sa.Column("uploaded_by", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column("stored_filename", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column("trip_id", sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(
["trip_id"], ["trip.id"], name=op.f("fk_tripattachment_trip_id_trip"), ondelete="CASCADE"
),
sa.ForeignKeyConstraint(
["uploaded_by"],
["user.username"],
name=op.f("fk_tripattachment_uploaded_by_user"),
ondelete="CASCADE",
),
sa.PrimaryKeyConstraint("id", name=op.f("pk_tripattachment")),
)
with op.batch_alter_table("tripattachment", schema=None) as batch_op:
batch_op.create_index(batch_op.f("ix_tripattachment_trip_id"), ["trip_id"], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("tripattachment", schema=None) as batch_op:
batch_op.drop_index(batch_op.f("ix_tripattachment_trip_id"))
op.drop_table("tripattachment")
# ### end Alembic commands ###

View File

@ -0,0 +1,47 @@
"""Backup task feature
Revision ID: b6d707f9c35a
Revises: 032b5b7de8bd
Create Date: 2025-10-15 22:37:46.343276
"""
import sqlalchemy as sa
import sqlmodel.sql.sqltypes
from alembic import op
# revision identifiers, used by Alembic.
revision = "b6d707f9c35a"
down_revision = "032b5b7de8bd"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"backup",
sa.Column("completed_at", sa.DateTime(), nullable=True),
sa.Column("filename", sqlmodel.sql.sqltypes.AutoString(), nullable=True),
sa.Column("error_message", sqlmodel.sql.sqltypes.AutoString(), nullable=True),
sa.Column("file_size", sa.Integer(), nullable=True),
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("user", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column(
"status",
sa.Enum("PENDING", "PROCESSING", "COMPLETED", "FAILED", name="backupstatus"),
nullable=False,
),
sa.Column("created_at", sa.DateTime(), nullable=False),
sa.ForeignKeyConstraint(
["user"], ["user.username"], name=op.f("fk_backup_user_user"), ondelete="CASCADE"
),
sa.PrimaryKeyConstraint("id", name=op.f("pk_backup")),
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("backup")
# ### end Alembic commands ###