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
d7ab2cef
Kaydet (Commit)
d7ab2cef
authored
Eyl 24, 2014
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Revert "Fixed #23474 -- Prevented migrating backwards from unapplying the wrong migrations."
This reverts commit
abcf28a0
.
üst
a4f23eba
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
5 additions
and
66 deletions
+5
-66
executor.py
django/db/migrations/executor.py
+5
-9
1.7.1.txt
docs/releases/1.7.1.txt
+0
-3
test_executor.py
tests/migrations/test_executor.py
+0
-38
__init__.py
...s/migrations/test_migrations_backwards_deps_1/__init__.py
+0
-0
0001_initial.py
...rations2/test_migrations_backwards_deps_2/0001_initial.py
+0
-16
__init__.py
.../migrations2/test_migrations_backwards_deps_2/__init__.py
+0
-0
No files found.
django/db/migrations/executor.py
Dosyayı görüntüle @
d7ab2cef
...
...
@@ -36,15 +36,11 @@ class MigrationExecutor(object):
# If the migration is already applied, do backwards mode,
# otherwise do forwards mode.
elif
target
in
applied
:
app_label
=
target
[
0
]
next_migration_prefix
=
str
(
int
(
target
[
1
][:
4
])
+
1
)
try
:
next_migration
=
self
.
loader
.
get_migration_by_prefix
(
app_label
,
next_migration_prefix
)
except
KeyError
:
# If `target` is the most recent one in its app, there is nothing to do.
pass
else
:
backwards_plan
=
self
.
loader
.
graph
.
backwards_plan
(
next_migration
)
backwards_plan
=
self
.
loader
.
graph
.
backwards_plan
(
target
)[:
-
1
]
# We only do this if the migration is not the most recent one
# in its app - that is, another migration with the same app
# label is in the backwards plan
if
any
(
node
[
0
]
==
target
[
0
]
for
node
in
backwards_plan
):
for
migration
in
backwards_plan
:
if
migration
in
applied
:
plan
.
append
((
self
.
loader
.
graph
.
nodes
[
migration
],
True
))
...
...
docs/releases/1.7.1.txt
Dosyayı görüntüle @
d7ab2cef
...
...
@@ -47,9 +47,6 @@ Bugfixes
* Allowed migrations to work with ``app_label``\s that have the same last
part (e.g. ``django.contrib.auth`` and ``vendor.auth``) (:ticket:`23483`).
* Fixed bug in migrations that could cause unexpected data loss when executing
a backwards or no-op migration (:ticket:`23474`).
* Restored the ability to deepcopy ``F`` objects (:ticket:`23492`).
* Formats for Welsh (``cy``) and several Chinese locales (``zh_CN``,
...
...
tests/migrations/test_executor.py
Dosyayı görüntüle @
d7ab2cef
...
...
@@ -231,41 +231,3 @@ class ExecutorTests(MigrationTestBase):
executor
.
migrate
([(
"migrations"
,
None
)])
self
.
assertTableNotExists
(
"migrations_author"
)
self
.
assertTableNotExists
(
"migrations_tribble"
)
@override_settings
(
MIGRATION_MODULES
=
{
"migrations"
:
"migrations.test_migrations_backwards_deps_1"
,
"migrations2"
:
"migrations2.test_migrations_backwards_deps_2"
,
},
)
def
test_backwards_deps
(
self
):
"""
#23474 - Migrating backwards shouldn't cause the wrong migrations to be
unapplied.
Migration dependencies (x -> y === y depends on x):
m.0001 -+-> m.0002
+-> m2.0001
1) Migrate m2 to 0001, causing { m.0001, m2.0002 } to be applied.
2) Migrate m to 0001. m.0001 has already been applied, so this should
be a noop.
"""
executor
=
MigrationExecutor
(
connection
)
executor
.
migrate
([(
"migrations2"
,
"0001_initial"
)])
try
:
self
.
assertTableExists
(
"migrations2_example"
)
# Rebuild the graph to reflect the new DB state
executor
.
loader
.
build_graph
()
self
.
assertEqual
(
executor
.
migration_plan
([(
"migrations"
,
"0001_initial"
)]),
[],
)
executor
.
migrate
([(
"migrations"
,
"0001_initial"
)])
self
.
assertTableExists
(
"migrations2_example"
)
finally
:
# And migrate back to clean up the database
executor
.
loader
.
build_graph
()
executor
.
migrate
([(
"migrations"
,
None
)])
self
.
assertTableNotExists
(
"migrations_author"
)
self
.
assertTableNotExists
(
"migrations_tribble"
)
tests/migrations/test_migrations_backwards_deps_1/__init__.py
deleted
100644 → 0
Dosyayı görüntüle @
a4f23eba
tests/migrations2/test_migrations_backwards_deps_2/0001_initial.py
deleted
100644 → 0
Dosyayı görüntüle @
a4f23eba
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[(
'migrations'
,
'0001_initial'
)]
operations
=
[
migrations
.
CreateModel
(
"Example"
,
[
(
"id"
,
models
.
AutoField
(
primary_key
=
True
)),
],
),
]
tests/migrations2/test_migrations_backwards_deps_2/__init__.py
deleted
100644 → 0
Dosyayı görüntüle @
a4f23eba
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