Auto-commit local changes before build (2026-01-06 16:23:49)
This commit is contained in:
parent
d0a7452240
commit
dc8e1d093b
@ -1 +1 @@
|
|||||||
v20260106-19-missed-run-detection-threshold
|
v20260106-20-fix-customer-delete-fk
|
||||||
|
|||||||
@ -1226,6 +1226,37 @@ def migrate_object_persistence_tables() -> None:
|
|||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Ensure existing installations also have ON DELETE CASCADE for customer_object_id.
|
||||||
|
# Older schemas may have created the FK without cascade, blocking customer deletes.
|
||||||
|
conn.execute(
|
||||||
|
text(
|
||||||
|
'''
|
||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
IF EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM information_schema.table_constraints tc
|
||||||
|
WHERE tc.table_name = 'job_object_links'
|
||||||
|
AND tc.constraint_type = 'FOREIGN KEY'
|
||||||
|
AND tc.constraint_name = 'job_object_links_customer_object_id_fkey'
|
||||||
|
) THEN
|
||||||
|
ALTER TABLE job_object_links
|
||||||
|
DROP CONSTRAINT job_object_links_customer_object_id_fkey;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
ALTER TABLE job_object_links
|
||||||
|
ADD CONSTRAINT job_object_links_customer_object_id_fkey
|
||||||
|
FOREIGN KEY (customer_object_id)
|
||||||
|
REFERENCES customer_objects(id)
|
||||||
|
ON DELETE CASCADE;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN duplicate_object THEN
|
||||||
|
NULL;
|
||||||
|
END $$;
|
||||||
|
'''
|
||||||
|
)
|
||||||
|
)
|
||||||
conn.execute(
|
conn.execute(
|
||||||
text(
|
text(
|
||||||
'CREATE INDEX IF NOT EXISTS idx_job_object_links_job_id ON job_object_links (job_id)'
|
'CREATE INDEX IF NOT EXISTS idx_job_object_links_job_id ON job_object_links (job_id)'
|
||||||
@ -1253,6 +1284,36 @@ def migrate_object_persistence_tables() -> None:
|
|||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Ensure existing installations also have ON DELETE CASCADE for customer_object_id.
|
||||||
|
conn.execute(
|
||||||
|
text(
|
||||||
|
'''
|
||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
IF EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM information_schema.table_constraints tc
|
||||||
|
WHERE tc.table_name = 'run_object_links'
|
||||||
|
AND tc.constraint_type = 'FOREIGN KEY'
|
||||||
|
AND tc.constraint_name = 'run_object_links_customer_object_id_fkey'
|
||||||
|
) THEN
|
||||||
|
ALTER TABLE run_object_links
|
||||||
|
DROP CONSTRAINT run_object_links_customer_object_id_fkey;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
ALTER TABLE run_object_links
|
||||||
|
ADD CONSTRAINT run_object_links_customer_object_id_fkey
|
||||||
|
FOREIGN KEY (customer_object_id)
|
||||||
|
REFERENCES customer_objects(id)
|
||||||
|
ON DELETE CASCADE;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN duplicate_object THEN
|
||||||
|
NULL;
|
||||||
|
END $$;
|
||||||
|
'''
|
||||||
|
)
|
||||||
|
)
|
||||||
conn.execute(
|
conn.execute(
|
||||||
text(
|
text(
|
||||||
'CREATE INDEX IF NOT EXISTS idx_run_object_links_run_id ON run_object_links (run_id)'
|
'CREATE INDEX IF NOT EXISTS idx_run_object_links_run_id ON run_object_links (run_id)'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user