Migration 004: add 'camera' to event_source_type enum so ingester can store camera events
All checks were successful
build-and-deploy / build (push) Successful in 1m57s
All checks were successful
build-and-deploy / build (push) Successful in 1m57s
This commit is contained in:
parent
e6648ec1ed
commit
c1a19ecf06
1 changed files with 36 additions and 0 deletions
36
alembic/versions/004_camera_enum.py
Normal file
36
alembic/versions/004_camera_enum.py
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
"""events.camera source type
|
||||||
|
|
||||||
|
Revision ID: 004_camera_enum
|
||||||
|
Revises: 003_news
|
||||||
|
Create Date: 2026-08-25
|
||||||
|
"""
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
revision = '004_camera_enum'
|
||||||
|
down_revision = '003_news'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
# Postgres enums have no IF NOT EXISTS for values — guard manually so the
|
||||||
|
# migration stays idempotent across restarts.
|
||||||
|
op.execute("""
|
||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
IF NOT EXISTS (
|
||||||
|
SELECT 1 FROM pg_enum e
|
||||||
|
JOIN pg_typname t ON t.oid = e.enumtypid
|
||||||
|
WHERE t.typname = 'event_source_type' AND e.enumlabel = 'camera'
|
||||||
|
) THEN
|
||||||
|
ALTER TYPE event_source_type ADD VALUE 'camera';
|
||||||
|
END IF;
|
||||||
|
END
|
||||||
|
$$;
|
||||||
|
""")
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
# Enum value removal is not supported by Postgres; leave it in place.
|
||||||
|
pass
|
||||||
Loading…
Add table
Reference in a new issue