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
5bc412c3
Kaydet (Commit)
5bc412c3
authored
Haz 12, 2015
tarafından
Markus Holtermann
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Took AlterOrderWithRespectTo into account when optimizing migrations
Thanks Andrew Godwin for the review.
üst
53044945
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
+19
-3
optimizer.py
django/db/migrations/optimizer.py
+6
-0
test_optimizer.py
tests/migrations/test_optimizer.py
+13
-3
No files found.
django/db/migrations/optimizer.py
Dosyayı görüntüle @
5bc412c3
...
...
@@ -21,6 +21,7 @@ class MigrationOptimizer(object):
migrations
.
AlterModelTable
,
migrations
.
AlterUniqueTogether
,
migrations
.
AlterIndexTogether
,
migrations
.
AlterOrderWithRespectTo
,
)
self
.
field_level_operations
=
(
migrations
.
AddField
,
...
...
@@ -47,6 +48,11 @@ class MigrationOptimizer(object):
migrations
.
DeleteModel
,
self
.
reduce_model_alter_delete
,
),
(
migrations
.
AlterOrderWithRespectTo
,
migrations
.
DeleteModel
,
self
.
reduce_model_alter_delete
,
),
(
migrations
.
CreateModel
,
migrations
.
RenameModel
,
...
...
tests/migrations/test_optimizer.py
Dosyayı görüntüle @
5bc412c3
...
...
@@ -93,20 +93,30 @@ class OptimizerTests(SimpleTestCase):
],
)
def
test_create_alter_delete_model
(
self
):
def
_test_create_alter_foo_delete_model
(
self
,
alter_foo
):
"""
CreateModel, AlterModelTable, AlterUniqueTogether, and DeleteModel should collapse into nothing.
CreateModel, AlterModelTable, AlterUniqueTogether/AlterIndexTogether/
AlterOrderWithRespectTo, and DeleteModel should collapse into nothing.
"""
self
.
assertOptimizesTo
(
[
migrations
.
CreateModel
(
"Foo"
,
[(
"name"
,
models
.
CharField
(
max_length
=
255
))]),
migrations
.
AlterModelTable
(
"Foo"
,
"woohoo"
),
migrations
.
AlterUniqueTogether
(
"Foo"
,
[[
"a"
,
"b"
]])
,
alter_foo
,
migrations
.
DeleteModel
(
"Foo"
),
],
[],
)
def
test_create_alter_unique_delete_model
(
self
):
self
.
_test_create_alter_foo_delete_model
(
migrations
.
AlterUniqueTogether
(
"Foo"
,
[[
"a"
,
"b"
]]))
def
test_create_alter_index_delete_model
(
self
):
self
.
_test_create_alter_foo_delete_model
(
migrations
.
AlterIndexTogether
(
"Foo"
,
[[
"a"
,
"b"
]]))
def
test_create_alter_owrt_delete_model
(
self
):
self
.
_test_create_alter_foo_delete_model
(
migrations
.
AlterOrderWithRespectTo
(
"Foo"
,
"a"
))
def
test_optimize_through_create
(
self
):
"""
We should be able to optimize away create/delete through a create or delete
...
...
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