-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: alter existing delete_at field to allow NULL values
- Loading branch information
1 parent
4e08d08
commit 53be430
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
apps/event_hub/migrations/0007_alter_delete_at_nullable.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
] |