Skip to content

Commit

Permalink
fix: alter existing delete_at field to allow NULL values
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianmcphee committed Nov 26, 2024
1 parent 4e08d08 commit 53be430
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions apps/event_hub/migrations/0007_alter_delete_at_nullable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from django.db import migrations, models
from django.db.utils import ProgrammingError

def make_delete_at_nullable(apps, schema_editor):
# Get the database connection
connection = schema_editor.connection

with connection.cursor() as cursor:
# Alter column to allow NULL
cursor.execute(
"ALTER TABLE event_hub_eventlog ALTER COLUMN delete_at DROP NOT NULL"
)

class Migration(migrations.Migration):
dependencies = [
('event_hub', '0006_make_delete_at_nullable'),
]

operations = [
migrations.RunPython(make_delete_at_nullable, migrations.RunPython.noop),
]

0 comments on commit 53be430

Please sign in to comment.