Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
beat
beat.web
Commits
53462cf3
Commit
53462cf3
authored
8 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
[backup] Add pk ordering back
parent
05dc15ad
No related branches found
No related tags found
1 merge request
!211
Issue 433
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
beat/web/utils/management/commands/backup.py
+16
-0
16 additions, 0 deletions
beat/web/utils/management/commands/backup.py
beat/web/utils/management/commands/xdumpdata.py
+7
-8
7 additions, 8 deletions
beat/web/utils/management/commands/xdumpdata.py
with
23 additions
and
8 deletions
beat/web/utils/management/commands/backup.py
+
16
−
0
View file @
53462cf3
...
...
@@ -158,6 +158,22 @@ class Command(BaseCommand):
arguments
=
copy
.
deepcopy
(
dump_arguments
)
logger
.
info
(
"
Dumping data for `%s
'
-> `%s
'"
,
app
,
destfile
)
if
app
in
only
:
app
,
model
=
only
[
app
].
split
(
'
.
'
)
model
=
apps
.
get_model
(
app
,
model
)
order
=
(
'
creation_date
'
,)
# This will check and correct objects with weird creation
# dates so that the dump order is consistent
while
True
:
queryset
=
model
.
objects
.
order_by
(
*
order
)
err
=
_check
(
app
,
queryset
)
if
not
err
:
break
arguments
[
'
primary_keys
'
]
=
\
'
,
'
.
join
([
str
(
k
.
id
)
for
k
in
queryset
])
arguments
[
'
output
'
]
=
destfile
#new in Django-1.8.x
call_command
(
'
xdumpdata
'
,
only
.
get
(
app
,
app
),
**
arguments
)
...
...
This diff is collapsed.
Click to expand it.
beat/web/utils/management/commands/xdumpdata.py
+
7
−
8
View file @
53462cf3
...
...
@@ -155,18 +155,17 @@ class Command(BaseCommand):
# ###################################################
queryset
=
objects
.
using
(
using
)
if
primary_keys
:
# in case the user specifies PKs, respect order
for
pk
in
[
int
(
k
)
for
k
in
primary_keys
]:
if
count_only
:
yield
queryset
.
count
()
elif
primary_keys
:
for
pk
in
primary_keys
:
yield
queryset
.
get
(
pk
=
pk
)
elif
count_only
:
# ###################################################
# patch for BEAT ends here
# ###################################################
yield
queryset
.
order_by
().
count
()
else
:
for
obj
in
queryset
.
iterator
():
yield
obj
# ###################################################
# patch for BEAT ends here
# ###################################################
try
:
self
.
stdout
.
ending
=
None
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment