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
76ab8851
Kaydet (Commit)
76ab8851
authored
Agu 13, 2016
tarafından
Jim Nicholls
Kaydeden (comit)
Tim Graham
Agu 18, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #27054 -- Fixed makemigrations crash with a read-only database.
üst
97513269
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
4 deletions
+45
-4
loader.py
django/db/migrations/loader.py
+7
-1
1.10.1.txt
docs/releases/1.10.1.txt
+2
-0
test_commands.py
tests/migrations/test_commands.py
+24
-1
test_loader.py
tests/migrations/test_loader.py
+12
-2
No files found.
django/db/migrations/loader.py
Dosyayı görüntüle @
76ab8851
...
...
@@ -6,6 +6,7 @@ from importlib import import_module
from
django.apps
import
apps
from
django.conf
import
settings
from
django.db.migrations.exceptions
import
MigrationSchemaMissing
from
django.db.migrations.graph
import
MigrationGraph
from
django.db.migrations.recorder
import
MigrationRecorder
from
django.utils
import
six
...
...
@@ -273,7 +274,12 @@ class MigrationLoader(object):
unapplied dependencies.
"""
recorder
=
MigrationRecorder
(
connection
)
applied
=
recorder
.
applied_migrations
()
try
:
applied
=
recorder
.
applied_migrations
()
except
MigrationSchemaMissing
:
# Skip check if the django_migrations table is missing and can't be
# created.
return
for
migration
in
applied
:
# If the migration is unknown, skip it.
if
migration
not
in
self
.
graph
.
nodes
:
...
...
docs/releases/1.10.1.txt
Dosyayı görüntüle @
76ab8851
...
...
@@ -54,3 +54,5 @@ Bugfixes
PostGIS (:ticket:`27014`).
* Reallowed the ``{% for %}`` tag to unpack any iterable (:ticket:`27058`).
* Fixed ``makemigrations`` crash if a database is read-only (:ticket:`27054`).
tests/migrations/test_commands.py
Dosyayı görüntüle @
76ab8851
...
...
@@ -12,7 +12,9 @@ from django.core.management import CommandError, call_command
from
django.db
import
(
ConnectionHandler
,
DatabaseError
,
connection
,
connections
,
models
,
)
from
django.db.migrations.exceptions
import
InconsistentMigrationHistory
from
django.db.migrations.exceptions
import
(
InconsistentMigrationHistory
,
MigrationSchemaMissing
,
)
from
django.db.migrations.recorder
import
MigrationRecorder
from
django.test
import
ignore_warnings
,
mock
,
override_settings
from
django.utils
import
six
...
...
@@ -595,6 +597,27 @@ class MakeMigrationsTests(MigrationTestBase):
init_file
=
os
.
path
.
join
(
migration_dir
,
'__init__.py'
)
self
.
assertTrue
(
os
.
path
.
exists
(
init_file
))
def
test_makemigrations_other_datbase_is_readonly
(
self
):
"""
makemigrations ignores the non-default database if it's read-only.
"""
def
patched_ensure_schema
(
migration_recorder
):
from
django.db
import
connections
if
migration_recorder
.
connection
is
connections
[
'other'
]:
raise
MigrationSchemaMissing
()
else
:
return
mock
.
DEFAULT
self
.
assertTableNotExists
(
'migrations_unicodemodel'
)
apps
.
register_model
(
'migrations'
,
UnicodeModel
)
with
mock
.
patch
.
object
(
MigrationRecorder
,
'ensure_schema'
,
autospec
=
True
,
side_effect
=
patched_ensure_schema
):
with
self
.
temporary_migration_module
()
as
migration_dir
:
call_command
(
"makemigrations"
,
"migrations"
,
verbosity
=
0
)
initial_file
=
os
.
path
.
join
(
migration_dir
,
"0001_initial.py"
)
self
.
assertTrue
(
os
.
path
.
exists
(
initial_file
))
def
test_failing_migration
(
self
):
# If a migration fails to serialize, it shouldn't generate an empty file. #21280
apps
.
register_model
(
'migrations'
,
UnserializableModel
)
...
...
tests/migrations/test_loader.py
Dosyayı görüntüle @
76ab8851
...
...
@@ -4,11 +4,12 @@ from unittest import skipIf
from
django.db
import
connection
,
connections
from
django.db.migrations.exceptions
import
(
AmbiguityError
,
InconsistentMigrationHistory
,
NodeNotFoundError
,
AmbiguityError
,
InconsistentMigrationHistory
,
MigrationSchemaMissing
,
NodeNotFoundError
,
)
from
django.db.migrations.loader
import
MigrationLoader
from
django.db.migrations.recorder
import
MigrationRecorder
from
django.test
import
TestCase
,
modify_settings
,
override_settings
from
django.test
import
TestCase
,
mo
ck
,
mo
dify_settings
,
override_settings
from
django.utils
import
six
...
...
@@ -464,3 +465,12 @@ class LoaderTests(TestCase):
(
'app1'
,
'4_auto'
),
}
self
.
assertEqual
(
plan
,
expected_plan
)
def
test_readonly_database
(
self
):
"""
check_consistent_history() ignores read-only databases, possibly
without a django_migrations table.
"""
with
mock
.
patch
.
object
(
MigrationRecorder
,
'ensure_schema'
,
side_effect
=
MigrationSchemaMissing
()):
loader
=
MigrationLoader
(
connection
=
None
)
loader
.
check_consistent_history
(
connection
)
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