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
8e73d3a2
Kaydet (Commit)
8e73d3a2
authored
Mar 25, 2014
tarafından
Loic Bistuer
Kaydeden (comit)
Tim Graham
Mar 31, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
[1.7.x] Fixed #22319 -- Fixed migration external dependencies when there are internal dependencies.
Backport of
0fd51cf0
from master
üst
bdec8480
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
12 deletions
+13
-12
autodetector.py
django/db/migrations/autodetector.py
+12
-11
test_autodetector.py
tests/migrations/test_autodetector.py
+1
-1
No files found.
django/db/migrations/autodetector.py
Dosyayı görüntüle @
8e73d3a2
...
@@ -134,6 +134,7 @@ class MigrationAutodetector(object):
...
@@ -134,6 +134,7 @@ class MigrationAutodetector(object):
bases
=
model_state
.
bases
,
bases
=
model_state
.
bases
,
)
)
)
)
# Phase 2 is progressively adding pending models, splitting up into two
# Phase 2 is progressively adding pending models, splitting up into two
# migrations if required.
# migrations if required.
pending_new_fks
=
[]
pending_new_fks
=
[]
...
@@ -161,14 +162,6 @@ class MigrationAutodetector(object):
...
@@ -161,14 +162,6 @@ class MigrationAutodetector(object):
# migration for safety.
# migration for safety.
new
=
any
((
al
,
mn
)
in
added_phase_2
for
f
,
al
,
mn
in
related_fields
),
new
=
any
((
al
,
mn
)
in
added_phase_2
for
f
,
al
,
mn
in
related_fields
),
)
)
for
field_name
,
other_app_label
,
other_model_name
in
related_fields
:
# If it depends on a swappable something, add a dynamic depend'cy
swappable_setting
=
new_apps
.
get_model
(
app_label
,
model_name
)
.
_meta
.
get_field_by_name
(
field_name
)[
0
]
.
swappable_setting
if
swappable_setting
is
not
None
:
self
.
add_swappable_dependency
(
app_label
,
swappable_setting
)
elif
app_label
!=
other_app_label
:
self
.
add_dependency
(
app_label
,
other_app_label
)
del
pending_add
[
app_label
,
model_name
]
added_phase_2
.
add
((
app_label
,
model_name
))
added_phase_2
.
add
((
app_label
,
model_name
))
# Ah well, we'll need to split one. Pick deterministically.
# Ah well, we'll need to split one. Pick deterministically.
else
:
else
:
...
@@ -194,8 +187,16 @@ class MigrationAutodetector(object):
...
@@ -194,8 +187,16 @@ class MigrationAutodetector(object):
# Add the bad fields to be made in a phase 3
# Add the bad fields to be made in a phase 3
for
field_name
,
(
other_app_label
,
other_model_name
)
in
bad_fields
.
items
():
for
field_name
,
(
other_app_label
,
other_model_name
)
in
bad_fields
.
items
():
pending_new_fks
.
append
((
app_label
,
model_name
,
field_name
,
other_app_label
))
pending_new_fks
.
append
((
app_label
,
model_name
,
field_name
,
other_app_label
))
del
pending_add
[
app_label
,
model_name
]
for
field_name
,
other_app_label
,
other_model_name
in
related_fields
:
# Phase 3 is adding the final set of FKs as separate new migrations
# If it depends on a swappable something, add a dynamic depend'cy
swappable_setting
=
new_apps
.
get_model
(
app_label
,
model_name
)
.
_meta
.
get_field_by_name
(
field_name
)[
0
]
.
swappable_setting
if
swappable_setting
is
not
None
:
self
.
add_swappable_dependency
(
app_label
,
swappable_setting
)
elif
app_label
!=
other_app_label
:
self
.
add_dependency
(
app_label
,
other_app_label
)
del
pending_add
[
app_label
,
model_name
]
# Phase 3 is adding the final set of FKs as separate new migrations.
for
app_label
,
model_name
,
field_name
,
other_app_label
in
pending_new_fks
:
for
app_label
,
model_name
,
field_name
,
other_app_label
in
pending_new_fks
:
model_state
=
self
.
to_state
.
models
[
app_label
,
model_name
]
model_state
=
self
.
to_state
.
models
[
app_label
,
model_name
]
self
.
add_to_migration
(
self
.
add_to_migration
(
...
@@ -370,7 +371,7 @@ class MigrationAutodetector(object):
...
@@ -370,7 +371,7 @@ class MigrationAutodetector(object):
Adds a dependency to app_label's newest migration on
Adds a dependency to app_label's newest migration on
other_app_label's latest migration.
other_app_label's latest migration.
"""
"""
if
self
.
migrations
.
get
(
other_app_label
,
[]
):
if
self
.
migrations
.
get
(
other_app_label
):
dependency
=
(
other_app_label
,
self
.
migrations
[
other_app_label
][
-
1
]
.
name
)
dependency
=
(
other_app_label
,
self
.
migrations
[
other_app_label
][
-
1
]
.
name
)
else
:
else
:
dependency
=
(
other_app_label
,
"__first__"
)
dependency
=
(
other_app_label
,
"__first__"
)
...
...
tests/migrations/test_autodetector.py
Dosyayı görüntüle @
8e73d3a2
...
@@ -343,7 +343,7 @@ class AutodetectorTests(TestCase):
...
@@ -343,7 +343,7 @@ class AutodetectorTests(TestCase):
self
.
assertEqual
(
action
.
name
,
"author"
)
self
.
assertEqual
(
action
.
name
,
"author"
)
# Right dependencies?
# Right dependencies?
self
.
assertEqual
(
migration1
.
dependencies
,
[(
"otherapp"
,
"auto_1"
)])
self
.
assertEqual
(
migration1
.
dependencies
,
[(
"otherapp"
,
"auto_1"
)])
self
.
assertEqual
(
migration2
.
dependencies
,
[])
self
.
assertEqual
(
migration2
.
dependencies
,
[
(
'testapp'
,
'__first__'
)
])
self
.
assertEqual
(
set
(
migration3
.
dependencies
),
set
([(
"otherapp"
,
"auto_1"
),
(
"testapp"
,
"auto_1"
)]))
self
.
assertEqual
(
set
(
migration3
.
dependencies
),
set
([(
"otherapp"
,
"auto_1"
),
(
"testapp"
,
"auto_1"
)]))
def
test_same_app_circular_fk_dependency
(
self
):
def
test_same_app_circular_fk_dependency
(
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