Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
bcf789bd
Commit
bcf789bd
authored
Nov 11, 2015
by
Ned Batchelder
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10590 from edx/ned/dj18-fixed-data-migrations
More-correct data migrations
parents
8bac42a1
e7fcc743
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
9 deletions
+15
-9
common/djangoapps/dark_lang/migrations/0002_data__enable_on_install.py
+4
-3
common/djangoapps/util/migrations/0002_data__default_rate_limit_config.py
+5
-2
lms/djangoapps/certificates/migrations/0003_data__default_modes.py
+6
-4
No files found.
common/djangoapps/dark_lang/migrations/0002_data__enable_on_install.py
View file @
bcf789bd
...
...
@@ -11,11 +11,12 @@ def create_dark_lang_config(apps, schema_editor):
Enable DarkLang by default when it is installed, to prevent accidental
release of testing languages.
"""
dark_lang_model
=
apps
.
get_model
(
"dark_lang"
,
"DarkLangConfig"
)
DarkLangConfig
=
apps
.
get_model
(
"dark_lang"
,
"DarkLangConfig"
)
db_alias
=
schema_editor
.
connection
.
alias
if
not
dark_lang_model
.
objects
.
using
(
db_alias
)
.
exists
():
dark_lang_model
.
objects
.
using
(
db_alias
)
.
create
(
enabled
=
True
)
objects
=
DarkLangConfig
.
objects
.
using
(
db_alias
)
if
not
objects
.
exists
():
objects
.
create
(
enabled
=
True
)
def
remove_dark_lang_config
(
apps
,
schema_editor
):
"""Write your backwards methods here."""
...
...
common/djangoapps/util/migrations/0002_data__default_rate_limit_config.py
View file @
bcf789bd
...
...
@@ -8,9 +8,12 @@ from django.db import migrations, models
def
forwards
(
apps
,
schema_editor
):
"""Ensure that rate limiting is enabled by default. """
rate_limit_configuration_model
=
apps
.
get_model
(
"util"
,
"RateLimitConfiguration"
)
RateLimitConfiguration
=
apps
.
get_model
(
"util"
,
"RateLimitConfiguration"
)
db_alias
=
schema_editor
.
connection
.
alias
rate_limit_configuration_model
.
objects
.
using
(
db_alias
)
.
get_or_create
(
enabled
=
True
)
objects
=
RateLimitConfiguration
.
objects
.
using
(
db_alias
)
if
not
objects
.
exists
():
objects
.
create
(
enabled
=
True
)
class
Migration
(
migrations
.
Migration
):
...
...
lms/djangoapps/certificates/migrations/0003_data__default_modes.py
View file @
bcf789bd
...
...
@@ -9,11 +9,13 @@ from django.core.files import File
def
forwards
(
apps
,
schema_editor
):
"""Add default modes"""
badge_image_configuration_model
=
apps
.
get_model
(
"certificates"
,
"BadgeImageConfiguration"
)
BadgeImageConfiguration
=
apps
.
get_model
(
"certificates"
,
"BadgeImageConfiguration"
)
db_alias
=
schema_editor
.
connection
.
alias
for
mode
in
[
'honor'
,
'verified'
,
'professional'
]:
conf
,
created
=
badge_image_configuration_model
.
objects
.
get_or_create
(
mode
=
mode
)
if
created
:
objects
=
BadgeImageConfiguration
.
objects
.
using
(
db_alias
)
if
not
objects
.
exists
():
for
mode
in
[
'honor'
,
'verified'
,
'professional'
]:
conf
=
objects
.
create
(
mode
=
mode
)
file_name
=
'{0}{1}'
.
format
(
mode
,
'.png'
)
conf
.
icon
.
save
(
'badges/{}'
.
format
(
file_name
),
...
...
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