feat: add maintenance tree_type with db migration and tests
- Expand ck_trees_tree_type CHECK constraint to include 'maintenance' - Add 'maintenance' to TreeType Literal in schemas - Treat maintenance trees as procedural in can_publish_tree validation - Alembic migration 0f1ca2af3647 drops and recreates the constraint - Two integration tests: create and filter by tree_type=maintenance Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
"""add maintenance tree type
|
||||
|
||||
Revision ID: 0f1ca2af3647
|
||||
Revises: 039
|
||||
Create Date: 2026-02-17 10:25:54.959861
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '0f1ca2af3647'
|
||||
down_revision: Union[str, None] = '039'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.execute("ALTER TABLE trees DROP CONSTRAINT ck_trees_tree_type")
|
||||
op.execute(
|
||||
"ALTER TABLE trees ADD CONSTRAINT ck_trees_tree_type "
|
||||
"CHECK (tree_type IN ('troubleshooting', 'procedural', 'maintenance'))"
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.execute("UPDATE trees SET tree_type = 'procedural' WHERE tree_type = 'maintenance'")
|
||||
op.execute("ALTER TABLE trees DROP CONSTRAINT ck_trees_tree_type")
|
||||
op.execute(
|
||||
"ALTER TABLE trees ADD CONSTRAINT ck_trees_tree_type "
|
||||
"CHECK (tree_type IN ('troubleshooting', 'procedural'))"
|
||||
)
|
||||
Reference in New Issue
Block a user