ai insight rework #1
This commit is contained in:
1 parent
0d960c8153
commit
9d76f54d33
13 files changed
+730
-299
No files matched your search
@@ -0,0 +1,30 @@
|
||||
"""Drop orphan schema left by deleted migration 0019_aiinsight_structured_data_and_task.
|
||||
|
||||
0019 was applied to production Postgres (added ai_insight.structured_data NOT NULL +
|
||||
ai_insight_task table) but its file and the corresponding model fields were after-
|
||||
wards removed from the codebase. Django builds schema state from migration files,
|
||||
so INSERTs omit `structured_data` -> every AIInsight save fails with
|
||||
"null value in column structured_data violates not-null constraint".
|
||||
|
||||
Postgres-only: SQLite dev databases never had 0019 applied. Reverse is a no-op.
|
||||
"""
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def drop_orphan_schema(apps, schema_editor):
|
||||
if schema_editor.connection.vendor != "postgresql":
|
||||
return
|
||||
with schema_editor.connection.cursor() as cursor:
|
||||
cursor.execute("ALTER TABLE ai_insight DROP COLUMN IF EXISTS structured_data")
|
||||
cursor.execute("DROP TABLE IF EXISTS ai_insight_task")
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("operations", "0018_remove_aiinsight_source"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(drop_orphan_schema, migrations.RunPython.noop),
|
||||
]
|
||||
Reference in new issue
Block a user