Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
36d36818
Kaydet (Commit)
36d36818
authored
May 23, 2016
tarafından
Simon Charette
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #26647 -- Included the state of all applied migrations when migrating forward.
Thanks Jasper Maes for the detailed report.
üst
30d110ef
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
95 additions
and
2 deletions
+95
-2
executor.py
django/db/migrations/executor.py
+3
-2
__init__.py
...igrations/migrations_test_apps/mutate_state_a/__init__.py
+0
-0
0001_initial.py
...tions_test_apps/mutate_state_a/migrations/0001_initial.py
+22
-0
__init__.py
...igrations_test_apps/mutate_state_a/migrations/__init__.py
+0
-0
__init__.py
...igrations/migrations_test_apps/mutate_state_b/__init__.py
+0
-0
0001_initial.py
...tions_test_apps/mutate_state_b/migrations/0001_initial.py
+21
-0
0002_add_field.py
...ons_test_apps/mutate_state_b/migrations/0002_add_field.py
+21
-0
__init__.py
...igrations_test_apps/mutate_state_b/migrations/__init__.py
+0
-0
test_executor.py
tests/migrations/test_executor.py
+28
-0
No files found.
django/db/migrations/executor.py
Dosyayı görüntüle @
36d36818
...
...
@@ -116,8 +116,8 @@ class MigrationExecutor(object):
if
key
in
self
.
loader
.
graph
.
nodes
}
for
migration
,
_
in
full_plan
:
if
not
migrations_to_run
:
# We remove every migration that we applied from th
is set
so
if
not
migrations_to_run
and
not
applied_migrations
:
# We remove every migration that we applied from th
ese sets
so
# that we can bail out once the last migration has been applied
# and don't always run until the very end of the migration
# process.
...
...
@@ -136,6 +136,7 @@ class MigrationExecutor(object):
# to make sure the resulting state doesn't include changes
# from unrelated migrations.
migration
.
mutate_state
(
state
,
preserve
=
False
)
applied_migrations
.
remove
(
migration
)
return
state
...
...
tests/migrations/migrations_test_apps/mutate_state_a/__init__.py
0 → 100644
Dosyayı görüntüle @
36d36818
tests/migrations/migrations_test_apps/mutate_state_a/migrations/0001_initial.py
0 → 100644
Dosyayı görüntüle @
36d36818
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'mutate_state_b'
,
'0001_initial'
),
]
operations
=
[
migrations
.
SeparateDatabaseAndState
([],
[
migrations
.
CreateModel
(
name
=
'A'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
serialize
=
False
,
verbose_name
=
'ID'
,
auto_created
=
True
,
primary_key
=
True
)),
],
),
])
]
tests/migrations/migrations_test_apps/mutate_state_a/migrations/__init__.py
0 → 100644
Dosyayı görüntüle @
36d36818
tests/migrations/migrations_test_apps/mutate_state_b/__init__.py
0 → 100644
Dosyayı görüntüle @
36d36818
tests/migrations/migrations_test_apps/mutate_state_b/migrations/0001_initial.py
0 → 100644
Dosyayı görüntüle @
36d36818
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
]
operations
=
[
migrations
.
SeparateDatabaseAndState
([],
[
migrations
.
CreateModel
(
name
=
'B'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
serialize
=
False
,
verbose_name
=
'ID'
,
auto_created
=
True
,
primary_key
=
True
)),
],
),
])
]
tests/migrations/migrations_test_apps/mutate_state_b/migrations/0002_add_field.py
0 → 100644
Dosyayı görüntüle @
36d36818
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'mutate_state_b'
,
'0001_initial'
),
]
operations
=
[
migrations
.
SeparateDatabaseAndState
([],
[
migrations
.
AddField
(
model_name
=
'B'
,
name
=
'added'
,
field
=
models
.
TextField
(),
),
])
]
tests/migrations/migrations_test_apps/mutate_state_b/migrations/__init__.py
0 → 100644
Dosyayı görüntüle @
36d36818
tests/migrations/test_executor.py
Dosyayı görüntüle @
36d36818
...
...
@@ -477,6 +477,34 @@ class ExecutorTests(MigrationTestBase):
self
.
assertTableNotExists
(
"lookuperror_b_b1"
)
self
.
assertTableNotExists
(
"lookuperror_c_c1"
)
@override_settings
(
INSTALLED_APPS
=
[
'migrations.migrations_test_apps.mutate_state_a'
,
'migrations.migrations_test_apps.mutate_state_b'
,
]
)
def
test_unrelated_applied_migrations_mutate_state
(
self
):
"""
#26647 - Unrelated applied migrations should be part of the final
state in both directions.
"""
executor
=
MigrationExecutor
(
connection
)
executor
.
migrate
([
(
'mutate_state_b'
,
'0002_add_field'
),
])
# Migrate forward.
executor
.
loader
.
build_graph
()
state
=
executor
.
migrate
([
(
'mutate_state_a'
,
'0001_initial'
),
])
self
.
assertIn
(
'added'
,
dict
(
state
.
models
[
'mutate_state_b'
,
'b'
]
.
fields
))
executor
.
loader
.
build_graph
()
# Migrate backward.
state
=
executor
.
migrate
([
(
'mutate_state_a'
,
None
),
])
self
.
assertIn
(
'added'
,
dict
(
state
.
models
[
'mutate_state_b'
,
'b'
]
.
fields
))
@override_settings
(
MIGRATION_MODULES
=
{
"migrations"
:
"migrations.test_migrations"
})
def
test_process_callback
(
self
):
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment