mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-03-10 22:18:25 +00:00
Fix migrations
This commit is contained in:
23
assets/migrations/0020_auto_20210302_1201.py
Normal file
23
assets/migrations/0020_auto_20210302_1201.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 3.1.7 on 2021-03-02 12:01
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def postgres_migration_prep(apps, schema_editor):
|
||||
model = apps.get_model("assets", "Supplier")
|
||||
fields = ["address", "email", "notes", "phone"]
|
||||
for field in fields:
|
||||
filter_param = {"{}__isnull".format(field): True}
|
||||
update_param = {field: ""}
|
||||
model.objects.filter(**filter_param).update(**update_param)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('assets', '0019_fix_cabletype'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(postgres_migration_prep, migrations.RunPython.noop)
|
||||
]
|
||||
Reference in New Issue
Block a user