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
b333de0f
Kaydet (Commit)
b333de0f
authored
Şub 12, 2014
tarafından
Andrew Godwin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add --empty option to makemigrations
üst
7e27885c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
1 deletion
+26
-1
makemigrations.py
django/core/management/commands/makemigrations.py
+26
-1
No files found.
django/core/management/commands/makemigrations.py
Dosyayı görüntüle @
b333de0f
...
@@ -6,6 +6,7 @@ from optparse import make_option
...
@@ -6,6 +6,7 @@ from optparse import make_option
from
django.apps
import
apps
from
django.apps
import
apps
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django.db
import
connections
,
DEFAULT_DB_ALIAS
,
migrations
from
django.db
import
connections
,
DEFAULT_DB_ALIAS
,
migrations
from
django.db.migrations.migration
import
Migration
from
django.db.migrations.loader
import
MigrationLoader
from
django.db.migrations.loader
import
MigrationLoader
from
django.db.migrations.autodetector
import
MigrationAutodetector
from
django.db.migrations.autodetector
import
MigrationAutodetector
from
django.db.migrations.questioner
import
MigrationQuestioner
,
InteractiveMigrationQuestioner
from
django.db.migrations.questioner
import
MigrationQuestioner
,
InteractiveMigrationQuestioner
...
@@ -20,6 +21,8 @@ class Command(BaseCommand):
...
@@ -20,6 +21,8 @@ class Command(BaseCommand):
help
=
"Just show what migrations would be made; don't actually write them."
),
help
=
"Just show what migrations would be made; don't actually write them."
),
make_option
(
'--merge'
,
action
=
'store_true'
,
dest
=
'merge'
,
default
=
False
,
make_option
(
'--merge'
,
action
=
'store_true'
,
dest
=
'merge'
,
default
=
False
,
help
=
"Enable fixing of migration conflicts."
),
help
=
"Enable fixing of migration conflicts."
),
make_option
(
'--empty'
,
action
=
'store_true'
,
dest
=
'empty'
,
default
=
False
,
help
=
"Create an empty migration."
),
)
)
help
=
"Creates new migration(s) for apps."
help
=
"Creates new migration(s) for apps."
...
@@ -31,6 +34,7 @@ class Command(BaseCommand):
...
@@ -31,6 +34,7 @@ class Command(BaseCommand):
self
.
interactive
=
options
.
get
(
'interactive'
)
self
.
interactive
=
options
.
get
(
'interactive'
)
self
.
dry_run
=
options
.
get
(
'dry_run'
,
False
)
self
.
dry_run
=
options
.
get
(
'dry_run'
,
False
)
self
.
merge
=
options
.
get
(
'merge'
,
False
)
self
.
merge
=
options
.
get
(
'merge'
,
False
)
self
.
empty
=
options
.
get
(
'empty'
,
False
)
# Make sure the app they asked for exists
# Make sure the app they asked for exists
app_labels
=
set
(
app_labels
)
app_labels
=
set
(
app_labels
)
...
@@ -71,12 +75,27 @@ class Command(BaseCommand):
...
@@ -71,12 +75,27 @@ class Command(BaseCommand):
if
self
.
merge
and
conflicts
:
if
self
.
merge
and
conflicts
:
return
self
.
handle_merge
(
loader
,
conflicts
)
return
self
.
handle_merge
(
loader
,
conflicts
)
#
Detect changes
#
Set up autodetector
autodetector
=
MigrationAutodetector
(
autodetector
=
MigrationAutodetector
(
loader
.
graph
.
project_state
(),
loader
.
graph
.
project_state
(),
ProjectState
.
from_apps
(
apps
),
ProjectState
.
from_apps
(
apps
),
InteractiveMigrationQuestioner
(
specified_apps
=
app_labels
),
InteractiveMigrationQuestioner
(
specified_apps
=
app_labels
),
)
)
# If they want to make an empty migration, make one for each app
if
self
.
empty
:
if
not
app_labels
:
raise
CommandError
(
"You must supply at least one app label when using --empty."
)
# Make a fake changes() result we can pass to arrange_for_graph
changes
=
dict
(
(
app
,
[
Migration
(
"custom"
,
app
)])
for
app
in
app_labels
)
changes
=
autodetector
.
arrange_for_graph
(
changes
,
loader
.
graph
)
self
.
write_migration_files
(
changes
)
return
# Detect changes
changes
=
autodetector
.
changes
(
graph
=
loader
.
graph
,
trim_to_apps
=
app_labels
or
None
)
changes
=
autodetector
.
changes
(
graph
=
loader
.
graph
,
trim_to_apps
=
app_labels
or
None
)
# No changes? Tell them.
# No changes? Tell them.
...
@@ -89,6 +108,12 @@ class Command(BaseCommand):
...
@@ -89,6 +108,12 @@ class Command(BaseCommand):
self
.
stdout
.
write
(
"No changes detected"
)
self
.
stdout
.
write
(
"No changes detected"
)
return
return
self
.
write_migration_files
(
changes
)
def
write_migration_files
(
self
,
changes
):
"""
Takes a changes dict and writes them out as migration files.
"""
directory_created
=
{}
directory_created
=
{}
for
app_label
,
app_migrations
in
changes
.
items
():
for
app_label
,
app_migrations
in
changes
.
items
():
if
self
.
verbosity
>=
1
:
if
self
.
verbosity
>=
1
:
...
...
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