From 137241f873ca9a57cad006753f6f23d1ec149347 Mon Sep 17 00:00:00 2001 From: SergeantPanda Date: Fri, 22 May 2026 13:53:00 -0500 Subject: [PATCH] Bug Fix: Fix auto sync migration. (Fixes #1259) --- CHANGELOG.md | 1 + apps/channels/migrations/0037_auto_sync_overhaul.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07233ffc..7ae64497 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- **Migration 0037 fails on PostgreSQL when channels have been orphaned from their M3U account.** Channels created by auto-sync retain `auto_created=True` but get `auto_created_by=NULL` when the originating M3U account is deleted (`on_delete=SET_NULL`). The data migration step that re-attributes or demotes those channels updates the FK column via ORM `.save()` calls, which queues deferred constraint trigger events in PostgreSQL. The subsequent `ALTER TABLE ... DROP NOT NULL` on the same table then fails with `ObjectInUse: cannot ALTER TABLE because it has pending trigger events`. Fixed by issuing `SET CONSTRAINTS ALL IMMEDIATE` at the end of the data migration function to flush those pending events before the DDL runs. (Fixes #1259) - **XC stream URLs with no file extension now respect output format defaults.** `stream_xc` previously treated any extension other than `.mp4` as a forced `mpegts` request, including the empty-extension URLs that XC-compatible M3U playlists produce via `get.php`. Requests with no extension now pass `force_format=None` so the standard resolution chain (request param, user default, server default) applies correctly. - **XC M3U stream URLs now carry output profile and output format parameters.** The `get.php` M3U playlist previously emitted bare `/live/user/pass/id` URLs with no query string, causing per-user and server-wide output profile and output format settings to be silently ignored for XC clients. When `output_profile` or `output_format` parameters are present on the playlist request, they are now appended to every stream URL in the playlist so the proxy honours them on playback. diff --git a/apps/channels/migrations/0037_auto_sync_overhaul.py b/apps/channels/migrations/0037_auto_sync_overhaul.py index d93a1789..86f34762 100644 --- a/apps/channels/migrations/0037_auto_sync_overhaul.py +++ b/apps/channels/migrations/0037_auto_sync_overhaul.py @@ -62,6 +62,9 @@ def backfill_auto_created_by_null(apps, schema_editor): f"(ambiguous/no streams): {demoted}" ) + with schema_editor.connection.cursor() as cursor: + cursor.execute("SET CONSTRAINTS ALL IMMEDIATE") + def reverse_auto_created_by_null(apps, schema_editor): # Forward decisions cannot be cleanly reverted (no record of the @@ -101,6 +104,9 @@ def reverse_backfill_channel_number_nulls(apps, schema_editor): ch.save(update_fields=["channel_number"]) next_num += 1.0 + with schema_editor.connection.cursor() as cursor: + cursor.execute("SET CONSTRAINTS ALL IMMEDIATE") + class Migration(migrations.Migration):