36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
"""add corrections table
|
|
|
|
Revision ID: 0007
|
|
Revises: 0006
|
|
Create Date: 2026-03-29
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
revision = "0007"
|
|
down_revision = "0006"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"corrections",
|
|
sa.Column("id", sa.Integer(), primary_key=True, autoincrement=True),
|
|
sa.Column("spot_id", sa.Integer(), sa.ForeignKey("spots.id"), nullable=False),
|
|
sa.Column("user_id", sa.Integer(), sa.ForeignKey("users.id"), nullable=False),
|
|
sa.Column("field_name", sa.String(50), nullable=False),
|
|
sa.Column("suggested_value", sa.Text(), nullable=False),
|
|
sa.Column("reason", sa.Text(), nullable=True),
|
|
sa.Column("status", sa.String(20), server_default="pending", nullable=False),
|
|
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now()),
|
|
)
|
|
op.create_index("ix_corrections_spot_id", "corrections", ["spot_id"])
|
|
op.create_index("ix_corrections_status", "corrections", ["status"])
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index("ix_corrections_status", "corrections")
|
|
op.drop_index("ix_corrections_spot_id", "corrections")
|
|
op.drop_table("corrections")
|