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
bad9456b
Kaydet (Commit)
bad9456b
authored
Şub 12, 2014
tarafından
Andrew Godwin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix my slightly hasty autodetector changes
üst
80bbe226
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
6 deletions
+7
-6
autodetector.py
django/db/migrations/autodetector.py
+5
-4
test_autodetector.py
tests/migrations/test_autodetector.py
+2
-2
No files found.
django/db/migrations/autodetector.py
Dosyayı görüntüle @
bad9456b
...
...
@@ -31,7 +31,7 @@ class MigrationAutodetector(object):
to try and restrict to (restriction is not guaranteed)
"""
changes
=
self
.
_detect_changes
()
changes
=
self
.
_
arrange_for_graph
(
changes
,
graph
)
changes
=
self
.
arrange_for_graph
(
changes
,
graph
)
if
trim_to_apps
:
changes
=
self
.
_trim_to_apps
(
changes
,
trim_to_apps
)
return
changes
...
...
@@ -299,7 +299,7 @@ class MigrationAutodetector(object):
dependency
=
(
"__setting__"
,
setting_name
)
self
.
migrations
[
app_label
][
-
1
]
.
dependencies
.
append
(
dependency
)
def
_
arrange_for_graph
(
self
,
changes
,
graph
):
def
arrange_for_graph
(
self
,
changes
,
graph
):
"""
Takes in a result from changes() and a MigrationGraph,
and fixes the names and dependencies of the changes so they
...
...
@@ -388,8 +388,9 @@ class MigrationAutodetector(object):
return
"
%
s_
%
s"
%
(
ops
[
0
]
.
model_name
.
lower
(),
ops
[
0
]
.
name
.
lower
())
elif
isinstance
(
ops
[
0
],
operations
.
RemoveField
):
return
"remove_
%
s_
%
s"
%
(
ops
[
0
]
.
model_name
.
lower
(),
ops
[
0
]
.
name
.
lower
())
elif
all
(
isinstance
(
o
,
operations
.
CreateModel
)
for
o
in
ops
):
return
"_"
.
join
(
sorted
(
o
.
name
.
lower
()
for
o
in
ops
))
elif
len
(
ops
)
>
1
:
if
all
(
isinstance
(
o
,
operations
.
CreateModel
)
for
o
in
ops
):
return
"_"
.
join
(
sorted
(
o
.
name
.
lower
()
for
o
in
ops
))
return
"auto_
%
s"
%
datetime
.
datetime
.
now
()
.
strftime
(
"
%
Y
%
m
%
d_
%
H
%
M"
)
@classmethod
...
...
tests/migrations/test_autodetector.py
Dosyayı görüntüle @
bad9456b
...
...
@@ -54,7 +54,7 @@ class AutodetectorTests(TestCase):
autodetector
=
MigrationAutodetector
(
before
,
after
)
changes
=
autodetector
.
_detect_changes
()
# Run through arrange_for_graph
changes
=
autodetector
.
_
arrange_for_graph
(
changes
,
graph
)
changes
=
autodetector
.
arrange_for_graph
(
changes
,
graph
)
# Make sure there's a new name, deps match, etc.
self
.
assertEqual
(
changes
[
"testapp"
][
0
]
.
name
,
"0003_author"
)
self
.
assertEqual
(
changes
[
"testapp"
][
0
]
.
dependencies
,
[(
"testapp"
,
"0002_foobar"
)])
...
...
@@ -70,7 +70,7 @@ class AutodetectorTests(TestCase):
changes
=
autodetector
.
_detect_changes
()
# Run through arrange_for_graph
graph
=
MigrationGraph
()
changes
=
autodetector
.
_
arrange_for_graph
(
changes
,
graph
)
changes
=
autodetector
.
arrange_for_graph
(
changes
,
graph
)
changes
[
"testapp"
][
0
]
.
dependencies
.
append
((
"otherapp"
,
"0001_initial"
))
changes
=
autodetector
.
_trim_to_apps
(
changes
,
set
([
"testapp"
]))
# Make sure there's the right set of migrations
...
...
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