Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
code.vt.edu will be down for maintenance from 0530-0630 EDT Wednesday, March 26th
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
28d5458a
Commit
28d5458a
authored
5 years ago
by
hunytalk
Browse files
Options
Downloads
Patches
Plain Diff
Custom management command for data migration in Schedule
parent
2eab2a3a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openedx/core/djangoapps/schedules/management/commands/schedules_data_migration.py
+30
-0
30 additions, 0 deletions
...schedules/management/commands/schedules_data_migration.py
with
30 additions
and
0 deletions
openedx/core/djangoapps/schedules/management/commands/schedules_data_migration.py
0 → 100644
+
30
−
0
View file @
28d5458a
"""
Management command to perform data migration for copying values between date fields of Schedule Model
"""
import
time
from
django.core.management.base
import
BaseCommand
from
django.db
import
transaction
from
openedx.core.djangoapps.schedules.models
import
Schedule
class
Command
(
BaseCommand
):
"""
Command to perform data migration for Schedule Model
"""
help
=
'
Copy values from start to start_date in Schedule model
'
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'
--delay
'
,
type
=
float
,
default
=
0.2
,
help
=
'
Time delay in each iteration
'
)
parser
.
add_argument
(
'
--size
'
,
type
=
int
,
default
=
1000
,
help
=
'
Batch size for atomic migration
'
)
def
handle
(
self
,
*
args
,
**
kwargs
):
delay
=
kwargs
[
'
delay
'
]
size
=
kwargs
[
'
size
'
]
while
Schedule
.
objects
.
filter
(
start_date__isnull
=
True
).
exists
():
time
.
sleep
(
delay
)
with
transaction
.
atomic
():
for
row
in
Schedule
.
objects
.
filter
(
start_date__isnull
=
True
)[:
size
]:
time
.
sleep
(
delay
)
row
.
start_date
=
row
.
start
row
.
save
()
This diff is collapsed.
Click to expand it.
Preview
0%
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