tests/migration_test_data_persistence/migrations/0002_add_book.py
raw| 1 | from django.db import migrations |
| 2 | |
| 3 | |
| 4 | def add_book(apps, schema_editor): |
| 5 | apps.get_model("migration_test_data_persistence", "Book").objects.using( |
| 6 | schema_editor.connection.alias, |
| 7 | ).create( |
| 8 | title="I Love Django", |
| 9 | ) |
| 10 | |
| 11 | |
| 12 | class Migration(migrations.Migration): |
| 13 | dependencies = [("migration_test_data_persistence", "0001_initial")] |
| 14 | |
| 15 | operations = [ |
| 16 | migrations.RunPython( |
| 17 | add_book, |
| 18 | ), |
| 19 | ] |