Adding fits
This commit is contained in:
1 parent
8185f1f8b3
commit
ab39191af5
19 files changed
+1253
-1
No files matched your search
@@ -0,0 +1,72 @@
|
||||
"""add_fits_tables
|
||||
|
||||
Revision ID: 1b99be8a9b1e
|
||||
Revises: adf4a5b9493e
|
||||
Create Date: 2026-07-14 15:00:00.000000
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = "1b99be8a9b1e"
|
||||
down_revision: Union[str, None] = "adf4a5b9493e"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.create_table(
|
||||
"fits",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("attachment_point_a_id", sa.Integer(), nullable=False),
|
||||
sa.Column("attachment_point_b_id", sa.Integer(), nullable=False),
|
||||
sa.Column("augmented_part_a_id", sa.Integer(), nullable=False),
|
||||
sa.Column("augmented_part_b_id", sa.Integer(), nullable=False),
|
||||
sa.Column(
|
||||
"label",
|
||||
sa.Enum("possible", "exact", "none", name="fitlabel"),
|
||||
nullable=False,
|
||||
),
|
||||
sa.Column(
|
||||
"created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False
|
||||
),
|
||||
sa.Column(
|
||||
"updated_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["attachment_point_a_id"], ["attachment_points.id"], ondelete="CASCADE"
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["attachment_point_b_id"], ["attachment_points.id"], ondelete="CASCADE"
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["augmented_part_a_id"], ["augmented_parts.id"], ondelete="CASCADE"
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["augmented_part_b_id"], ["augmented_parts.id"], ondelete="CASCADE"
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
sa.UniqueConstraint("attachment_point_a_id", "attachment_point_b_id"),
|
||||
)
|
||||
op.create_table(
|
||||
"fit_notes",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("fit_id", sa.Integer(), nullable=False),
|
||||
sa.Column("user_id", sa.Integer(), nullable=True),
|
||||
sa.Column("username", sa.String(length=255), nullable=False),
|
||||
sa.Column("body", sa.Text(), nullable=False),
|
||||
sa.Column(
|
||||
"created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False
|
||||
),
|
||||
sa.ForeignKeyConstraint(["fit_id"], ["fits.id"], ondelete="CASCADE"),
|
||||
sa.ForeignKeyConstraint(["user_id"], ["users.id"], ondelete="SET NULL"),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_table("fit_notes")
|
||||
op.drop_table("fits")
|
||||
Reference in new issue
Block a user