Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
Hsin-Yu Chien
edx-platform-release
Commits
72b4cf37
Commit
72b4cf37
authored
9 years ago
by
Kevin Falcone
Browse files
Options
Downloads
Patches
Plain Diff
Don't hardcode student_module_history
aws_migrate may be used on boxes where that DB does not yet exist.
parent
447c189d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cms/envs/aws_migrate.py
+22
-13
22 additions, 13 deletions
cms/envs/aws_migrate.py
lms/envs/aws_migrate.py
+4
-2
4 additions, 2 deletions
lms/envs/aws_migrate.py
with
26 additions
and
15 deletions
cms/envs/aws_migrate.py
+
22
−
13
View file @
72b4cf37
...
...
@@ -13,18 +13,27 @@ from .aws import *
import
os
from
django.core.exceptions
import
ImproperlyConfigured
DB_OVERRIDES
=
dict
(
PASSWORD
=
os
.
environ
.
get
(
'
DB_MIGRATION_PASS
'
,
None
),
ENGINE
=
os
.
environ
.
get
(
'
DB_MIGRATION_ENGINE
'
,
DATABASES
[
'
default
'
][
'
ENGINE
'
]),
USER
=
os
.
environ
.
get
(
'
DB_MIGRATION_USER
'
,
DATABASES
[
'
default
'
][
'
USER
'
]),
NAME
=
os
.
environ
.
get
(
'
DB_MIGRATION_NAME
'
,
DATABASES
[
'
default
'
][
'
NAME
'
]),
HOST
=
os
.
environ
.
get
(
'
DB_MIGRATION_HOST
'
,
DATABASES
[
'
default
'
][
'
HOST
'
]),
PORT
=
os
.
environ
.
get
(
'
DB_MIGRATION_PORT
'
,
DATABASES
[
'
default
'
][
'
PORT
'
]),
)
if
DB_OVERRIDES
[
'
PASSWORD
'
]
is
None
:
raise
ImproperlyConfigured
(
"
No database password was provided for running
"
"
migrations. This is fatal.
"
)
def
get_db_overrides
(
db_name
):
"""
Now that we have multiple databases, we want to look up from the environment
for both databases.
"""
db_overrides
=
dict
(
PASSWORD
=
os
.
environ
.
get
(
'
DB_MIGRATION_PASS
'
,
None
),
ENGINE
=
os
.
environ
.
get
(
'
DB_MIGRATION_ENGINE
'
,
DATABASES
[
db_name
][
'
ENGINE
'
]),
USER
=
os
.
environ
.
get
(
'
DB_MIGRATION_USER
'
,
DATABASES
[
db_name
][
'
USER
'
]),
NAME
=
os
.
environ
.
get
(
'
DB_MIGRATION_NAME
'
,
DATABASES
[
db_name
][
'
NAME
'
]),
HOST
=
os
.
environ
.
get
(
'
DB_MIGRATION_HOST
'
,
DATABASES
[
db_name
][
'
HOST
'
]),
PORT
=
os
.
environ
.
get
(
'
DB_MIGRATION_PORT
'
,
DATABASES
[
db_name
][
'
PORT
'
]),
)
DATABASES
[
'
default
'
].
update
(
DB_OVERRIDES
)
DATABASES
[
'
student_module_history
'
].
update
(
DB_OVERRIDES
)
if
db_overrides
[
'
PASSWORD
'
]
is
None
:
raise
ImproperlyConfigured
(
"
No database password was provided for running
"
"
migrations. This is fatal.
"
)
return
db_overrides
for
db
in
DATABASES
:
# You never migrate a read_replica
if
db
!=
'
read_replica
'
:
DATABASES
[
db
].
update
(
get_db_overrides
(
db
))
This diff is collapsed.
Click to expand it.
lms/envs/aws_migrate.py
+
4
−
2
View file @
72b4cf37
...
...
@@ -33,5 +33,7 @@ def get_db_overrides(db_name):
"
migrations. This is fatal.
"
)
return
db_overrides
for
db
in
[
'
default
'
,
'
student_module_history
'
]:
DATABASES
[
db
].
update
(
get_db_overrides
(
db
))
for
db
in
DATABASES
:
# You never migrate a read_replica
if
db
!=
'
read_replica
'
:
DATABASES
[
db
].
update
(
get_db_overrides
(
db
))
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