mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
[1.7.x] Implement Migration.run_before
This attribute (used for reverse dependencies) was previously declared and mentioned in the code, but never actually used.
This commit is contained in:
committed by
Andrew Godwin
parent
31fc34e447
commit
9f1c4e4d3f
20
tests/migrations/test_migrations_run_before/0001_initial.py
Normal file
20
tests/migrations/test_migrations_run_before/0001_initial.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
operations = [
|
||||
|
||||
migrations.CreateModel(
|
||||
"Salamander",
|
||||
[
|
||||
("id", models.AutoField(primary_key=True)),
|
||||
("size", models.IntegerField(default=0)),
|
||||
("silly_field", models.BooleanField(default=False)),
|
||||
],
|
||||
),
|
||||
|
||||
]
|
||||
23
tests/migrations/test_migrations_run_before/0002_second.py
Normal file
23
tests/migrations/test_migrations_run_before/0002_second.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("migrations", "0001_initial"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
||||
migrations.CreateModel(
|
||||
"Book",
|
||||
[
|
||||
("id", models.AutoField(primary_key=True)),
|
||||
("author", models.ForeignKey("migrations.Author", null=True)),
|
||||
],
|
||||
)
|
||||
|
||||
]
|
||||
32
tests/migrations/test_migrations_run_before/0003_third.py
Normal file
32
tests/migrations/test_migrations_run_before/0003_third.py
Normal file
@@ -0,0 +1,32 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
"""
|
||||
This is a wee bit crazy, but it's just to show that run_before works.
|
||||
"""
|
||||
|
||||
dependencies = [
|
||||
("migrations", "0001_initial"),
|
||||
]
|
||||
|
||||
run_before = [
|
||||
("migrations", "0002_second"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
||||
migrations.CreateModel(
|
||||
"Author",
|
||||
[
|
||||
("id", models.AutoField(primary_key=True)),
|
||||
("name", models.CharField(max_length=255)),
|
||||
("slug", models.SlugField(null=True)),
|
||||
("age", models.IntegerField(default=0)),
|
||||
],
|
||||
)
|
||||
|
||||
]
|
||||
Reference in New Issue
Block a user