Skip to content

Instantly share code, notes, and snippets.

@mintyPT
Last active December 16, 2024 14:35
Show Gist options
  • Select an option

  • Save mintyPT/49f9a3d0fe1ab1f32b219ee41c96c79c to your computer and use it in GitHub Desktop.

Select an option

Save mintyPT/49f9a3d0fe1ab1f32b219ee41c96c79c to your computer and use it in GitHub Desktop.

Revisions

  1. mintyPT revised this gist Dec 16, 2024. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion migration.py
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,8 @@
    # Generate an empty migration:
    # > python manage.py makemigrations --empty <app_name>
    #
    # Migration from `new` to `new_b` (and back if necessary).
    # This will migration the value in the `state` field from `new` to `new_b`
    # (and back if necessary).

    from django.db import migrations

  2. mintyPT revised this gist Dec 16, 2024. 1 changed file with 13 additions and 5 deletions.
    18 changes: 13 additions & 5 deletions migration.py
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,21 @@
    # If you change some field's choice, django will not migrate the value at
    # the database level. You need to do it.
    #
    # Generate an empty migration:
    # > python manage.py makemigrations --empty <app_name>
    #
    # Migration from `new` to `new_b` (and back if necessary).

    from django.db import migrations

    # To get this empty migration:
    # > python manage.py makemigrations --empty app_name


    class Migration(migrations.Migration):
    dependencies = [("app_name", "0001_abc")]
    dependencies = [("<app_name>", "0001_abc")]

    operations = [
    migrations.RunSQL(
    "update pipeline_sipsnapshotstatus set state='new_b' where state='new';",
    "update pipeline_sipsnapshotstatus set state='new' where state='new_b';",
    "update <app_name>_<table> set state='new_b' where state='new';",
    "update <app_name>_<table> set state='new' where state='new_b';",
    )
    ]
  3. mintyPT revised this gist Dec 16, 2024. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions migration.py
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,3 @@
    # Generated by Django 4.2.17 on 2024-12-16 13:48

    from django.db import migrations

    # To get this empty migration:
  4. mintyPT renamed this gist Dec 16, 2024. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. mintyPT created this gist Dec 16, 2024.
    15 changes: 15 additions & 0 deletions python
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    # Generated by Django 4.2.17 on 2024-12-16 13:48

    from django.db import migrations

    # To get this empty migration:
    # > python manage.py makemigrations --empty app_name
    class Migration(migrations.Migration):
    dependencies = [("app_name", "0001_abc")]

    operations = [
    migrations.RunSQL(
    "update pipeline_sipsnapshotstatus set state='new_b' where state='new';",
    "update pipeline_sipsnapshotstatus set state='new' where state='new_b';",
    )
    ]