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
495abe00
Kaydet (Commit)
495abe00
authored
Eyl 19, 2018
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #29198 -- Fixed migrate --plan crash if RunSQL uses a list or tuple.
Also fixed test failures if sqlparse isn't installed.
üst
c99d379f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
20 deletions
+28
-20
migrate.py
django/core/management/commands/migrate.py
+1
-1
test_commands.py
tests/migrations/test_commands.py
+25
-17
0002_second.py
tests/migrations/test_migrations_plan/0002_second.py
+1
-1
0003_third.py
tests/migrations/test_migrations_plan/0003_third.py
+1
-1
No files found.
django/core/management/commands/migrate.py
Dosyayı görüntüle @
495abe00
...
@@ -344,7 +344,7 @@ class Command(BaseCommand):
...
@@ -344,7 +344,7 @@ class Command(BaseCommand):
action
=
'IRREVERSIBLE'
action
=
'IRREVERSIBLE'
is_error
=
True
is_error
=
True
else
:
else
:
action
=
action
.
replace
(
'
\n
'
,
''
)
action
=
str
(
action
)
.
replace
(
'
\n
'
,
''
)
is_error
=
False
is_error
=
False
if
action
:
if
action
:
action
=
' -> '
+
action
action
=
' -> '
+
action
...
...
tests/migrations/test_commands.py
Dosyayı görüntüle @
495abe00
...
@@ -20,6 +20,11 @@ from .models import UnicodeModel, UnserializableModel
...
@@ -20,6 +20,11 @@ from .models import UnicodeModel, UnserializableModel
from
.routers
import
TestRouter
from
.routers
import
TestRouter
from
.test_base
import
MigrationTestBase
from
.test_base
import
MigrationTestBase
try
:
import
sqlparse
except
ImportError
:
sqlparse
=
None
class
MigrateTests
(
MigrationTestBase
):
class
MigrateTests
(
MigrationTestBase
):
"""
"""
...
@@ -311,10 +316,10 @@ class MigrateTests(MigrationTestBase):
...
@@ -311,10 +316,10 @@ class MigrateTests(MigrationTestBase):
' Raw Python operation -> Grow salamander tail.
\n
'
' Raw Python operation -> Grow salamander tail.
\n
'
'migrations.0002_second
\n
'
'migrations.0002_second
\n
'
' Create model Book
\n
'
' Create model Book
\n
'
' Raw SQL operation -> SELECT * FROM migrations_book
\n
'
" Raw SQL operation -> ['SELECT * FROM migrations_book']
\n
"
'migrations.0003_third
\n
'
'migrations.0003_third
\n
'
' Create model Author
\n
'
' Create model Author
\n
'
' Raw SQL operation -> SELECT * FROM migrations_author
\n
'
,
" Raw SQL operation -> ['SELECT * FROM migrations_author']
\n
"
,
out
.
getvalue
()
out
.
getvalue
()
)
)
# Migrate to the third migration.
# Migrate to the third migration.
...
@@ -334,10 +339,10 @@ class MigrateTests(MigrationTestBase):
...
@@ -334,10 +339,10 @@ class MigrateTests(MigrationTestBase):
'Planned operations:
\n
'
'Planned operations:
\n
'
'migrations.0003_third
\n
'
'migrations.0003_third
\n
'
' Undo Create model Author
\n
'
' Undo Create model Author
\n
'
' Raw SQL operation -> SELECT * FROM migrations_book
\n
'
" Raw SQL operation -> ['SELECT * FROM migrations_book']
\n
"
'migrations.0002_second
\n
'
'migrations.0002_second
\n
'
' Undo Create model Book
\n
'
' Undo Create model Book
\n
'
' Raw SQL operation -> SELECT * FROM migrations_salamander
\n
'
,
" Raw SQL operation -> ['SELECT * FROM migrations_salamand…
\n
"
,
out
.
getvalue
()
out
.
getvalue
()
)
)
out
=
io
.
StringIO
()
out
=
io
.
StringIO
()
...
@@ -349,20 +354,23 @@ class MigrateTests(MigrationTestBase):
...
@@ -349,20 +354,23 @@ class MigrateTests(MigrationTestBase):
' Raw SQL operation -> SELECT * FROM migrations_author WHE…
\n
'
,
' Raw SQL operation -> SELECT * FROM migrations_author WHE…
\n
'
,
out
.
getvalue
()
out
.
getvalue
()
)
)
# Migrate to the fourth migration.
call_command
(
'migrate'
,
'migrations'
,
'0004'
,
verbosity
=
0
)
out
=
io
.
StringIO
()
# Show the plan when an operation is irreversible.
# Show the plan when an operation is irreversible.
call_command
(
'migrate'
,
'migrations'
,
'0003'
,
plan
=
True
,
stdout
=
out
,
no_color
=
True
)
# Migration 0004's RunSQL uses a SQL string instead of a list, so
self
.
assertEqual
(
# sqlparse may be required for splitting.
'Planned operations:
\n
'
if
sqlparse
or
not
connection
.
features
.
requires_sqlparse_for_splitting
:
'migrations.0004_fourth
\n
'
# Migrate to the fourth migration.
' Raw SQL operation -> IRREVERSIBLE
\n
'
,
call_command
(
'migrate'
,
'migrations'
,
'0004'
,
verbosity
=
0
)
out
.
getvalue
()
out
=
io
.
StringIO
()
)
call_command
(
'migrate'
,
'migrations'
,
'0003'
,
plan
=
True
,
stdout
=
out
,
no_color
=
True
)
# Cleanup by unmigrating everything: fake the irreversible, then
self
.
assertEqual
(
# migrate all to zero.
'Planned operations:
\n
'
call_command
(
'migrate'
,
'migrations'
,
'0003'
,
fake
=
True
,
verbosity
=
0
)
'migrations.0004_fourth
\n
'
' Raw SQL operation -> IRREVERSIBLE
\n
'
,
out
.
getvalue
()
)
# Cleanup by unmigrating everything: fake the irreversible, then
# migrate all to zero.
call_command
(
'migrate'
,
'migrations'
,
'0003'
,
fake
=
True
,
verbosity
=
0
)
call_command
(
'migrate'
,
'migrations'
,
'zero'
,
verbosity
=
0
)
call_command
(
'migrate'
,
'migrations'
,
'zero'
,
verbosity
=
0
)
@override_settings
(
MIGRATION_MODULES
=
{
"migrations"
:
"migrations.test_migrations_empty"
})
@override_settings
(
MIGRATION_MODULES
=
{
"migrations"
:
"migrations.test_migrations_empty"
})
...
...
tests/migrations/test_migrations_plan/0002_second.py
Dosyayı görüntüle @
495abe00
...
@@ -15,6 +15,6 @@ class Migration(migrations.Migration):
...
@@ -15,6 +15,6 @@ class Migration(migrations.Migration):
(
'id'
,
models
.
AutoField
(
primary_key
=
True
)),
(
'id'
,
models
.
AutoField
(
primary_key
=
True
)),
],
],
),
),
migrations
.
RunSQL
(
'SELECT * FROM migrations_book'
,
'SELECT * FROM migrations_salamander'
)
migrations
.
RunSQL
(
[
'SELECT * FROM migrations_book'
],
[
'SELECT * FROM migrations_salamander'
]
)
]
]
tests/migrations/test_migrations_plan/0003_third.py
Dosyayı görüntüle @
495abe00
...
@@ -15,5 +15,5 @@ class Migration(migrations.Migration):
...
@@ -15,5 +15,5 @@ class Migration(migrations.Migration):
(
'id'
,
models
.
AutoField
(
primary_key
=
True
)),
(
'id'
,
models
.
AutoField
(
primary_key
=
True
)),
],
],
),
),
migrations
.
RunSQL
(
'SELECT * FROM migrations_author'
,
'SELECT * FROM migrations_book'
)
migrations
.
RunSQL
(
[
'SELECT * FROM migrations_author'
],
[
'SELECT * FROM migrations_book'
]
)
]
]
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