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
2085f53f
Kaydet (Commit)
2085f53f
authored
Şub 09, 2014
tarafından
Andrew Godwin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #21968: Bad detection of old-style apps to add initial migration
üst
75a96f06
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
23 deletions
+30
-23
makemigrations.py
django/core/management/commands/makemigrations.py
+2
-0
loader.py
django/db/migrations/loader.py
+28
-23
No files found.
django/core/management/commands/makemigrations.py
Dosyayı görüntüle @
2085f53f
...
...
@@ -47,7 +47,9 @@ class Command(BaseCommand):
# Load the current graph state. Takes a connection, but it's not used
# (makemigrations doesn't look at the database state).
# Also make sure the graph is built without unmigrated apps shoehorned in.
loader
=
MigrationLoader
(
connections
[
DEFAULT_DB_ALIAS
])
loader
.
build_graph
(
ignore_unmigrated
=
True
)
# Before anything else, see if there's conflicting apps and drop out
# hard if there are any and they don't want to merge
...
...
django/db/migrations/loader.py
Dosyayı görüntüle @
2085f53f
...
...
@@ -135,7 +135,7 @@ class MigrationLoader(object):
else
:
return
self
.
disk_migrations
[
results
[
0
]]
def
build_graph
(
self
):
def
build_graph
(
self
,
ignore_unmigrated
=
False
):
"""
Builds a migration dependency graph using both the disk and database.
You'll need to rebuild the graph if you apply migrations. This isn't
...
...
@@ -200,33 +200,38 @@ class MigrationLoader(object):
# even have migrations.
if
parent
[
1
]
==
"__first__"
and
parent
not
in
self
.
graph
:
if
parent
[
0
]
in
self
.
unmigrated_apps
:
# This app isn't migrated, but something depends on it.
# We'll add a fake initial migration for it into the
# graph.
app_config
=
apps
.
get_app_config
(
parent
[
0
])
ops
=
[]
for
model
in
app_config
.
get_models
():
model_state
=
ModelState
.
from_model
(
model
)
ops
.
append
(
operations
.
CreateModel
(
name
=
model_state
.
name
,
fields
=
model_state
.
fields
,
options
=
model_state
.
options
,
bases
=
model_state
.
bases
,
if
ignore_unmigrated
:
migration
.
dependencies
.
remove
(
parent
)
parent
=
None
else
:
# This app isn't migrated, but something depends on it.
# We'll add a fake initial migration for it into the
# graph.
app_config
=
apps
.
get_app_config
(
parent
[
0
])
ops
=
[]
for
model
in
app_config
.
get_models
():
model_state
=
ModelState
.
from_model
(
model
)
ops
.
append
(
operations
.
CreateModel
(
name
=
model_state
.
name
,
fields
=
model_state
.
fields
,
options
=
model_state
.
options
,
bases
=
model_state
.
bases
,
)
)
)
new_migration
=
type
(
"FakeInitialMigration"
,
(
Migration
,
),
{
"operations"
:
ops
},
)(
parent
[
1
],
parent
[
0
])
self
.
graph
.
add_node
(
parent
,
new_migration
)
self
.
applied_migrations
.
add
(
parent
)
new_migration
=
type
(
"FakeInitialMigration"
,
(
Migration
,
),
{
"operations"
:
ops
},
)(
parent
[
1
],
parent
[
0
])
self
.
graph
.
add_node
(
parent
,
new_migration
)
self
.
applied_migrations
.
add
(
parent
)
elif
parent
[
0
]
in
self
.
migrated_apps
:
parent
=
list
(
self
.
graph
.
root_nodes
(
parent
[
0
]))[
0
]
else
:
raise
ValueError
(
"Dependency on unknown app
%
s"
%
parent
[
0
])
self
.
graph
.
add_dependency
(
key
,
parent
)
if
parent
is
not
None
:
self
.
graph
.
add_dependency
(
key
,
parent
)
def
detect_conflicts
(
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