feat(omg): backfill omg_entries from all projects with job_number
All CC Dashboard projects that have a non-empty job_number now appear in the OMG list automatically. Existing entries are preserved (INSERT only where no entry with that job_number exists for the user). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e0f541b082
commit
f568814be5
1 changed files with 39 additions and 0 deletions
39
alembic/versions/0012_backfill_omg_from_projects.py
Normal file
39
alembic/versions/0012_backfill_omg_from_projects.py
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
"""Backfill omg_entries from all projects that have a job_number
|
||||
|
||||
Revision ID: 0012
|
||||
Revises: 0011
|
||||
Create Date: 2026-05-18
|
||||
"""
|
||||
from alembic import op
|
||||
|
||||
revision = "0012"
|
||||
down_revision = "0011"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.execute(
|
||||
"""
|
||||
INSERT INTO omg_entries (id, user_id, name, client, job_number, notes)
|
||||
SELECT
|
||||
gen_random_uuid()::text,
|
||||
p.user_id,
|
||||
p.display_name,
|
||||
p.client,
|
||||
p.job_number,
|
||||
''
|
||||
FROM projects p
|
||||
WHERE p.job_number IS NOT NULL
|
||||
AND p.job_number != ''
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM omg_entries o
|
||||
WHERE o.user_id = p.user_id
|
||||
AND o.job_number = p.job_number
|
||||
)
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
pass
|
||||
Loading…
Add table
Reference in a new issue