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
ceb0814f
Commit
ceb0814f
authored
Aug 24, 2017
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Force the CourseKey alter tables to be noops from the SQL perspective
parent
0faa6837
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
5 deletions
+33
-5
common/djangoapps/course_modes/migrations/0008_course_key_field_to_foreign_key.py
+11
-1
common/djangoapps/course_modes/models.py
+6
-1
common/djangoapps/student/migrations/0011_course_key_field_to_foreign_key.py
+12
-2
common/djangoapps/student/models.py
+4
-1
No files found.
common/djangoapps/course_modes/migrations/0008_course_key_field_to_foreign_key.py
View file @
ceb0814f
...
...
@@ -5,6 +5,16 @@ from django.db import migrations, models
import
openedx.core.djangoapps.xmodule_django.models
# This should only be used for migrations that have be verified to have a net-neutral sql
# change generated by Django
class
NoSqlAlterField
(
migrations
.
AlterField
):
def
database_forwards
(
self
,
app_label
,
schema_editor
,
from_state
,
to_state
):
return
def
database_backwards
(
self
,
app_label
,
schema_editor
,
from_state
,
to_state
):
return
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
...
...
@@ -32,7 +42,7 @@ class Migration(migrations.Migration):
# name to above).
# We deliberately leave db_constraint set to False because the column
# isn't currently constrained
migrations
.
AlterField
(
NoSql
AlterField
(
model_name
=
'coursemode'
,
name
=
'course'
,
field
=
models
.
ForeignKey
(
related_name
=
'modes'
,
db_constraint
=
False
,
default
=
None
,
to
=
'course_overviews.CourseOverview'
),
...
...
common/djangoapps/course_modes/models.py
View file @
ceb0814f
...
...
@@ -41,7 +41,12 @@ class CourseMode(models.Model):
class
Meta
(
object
):
app_label
=
"course_modes"
course
=
models
.
ForeignKey
(
CourseOverview
,
db_constraint
=
False
,
db_index
=
True
,
related_name
=
'modes'
)
course
=
models
.
ForeignKey
(
CourseOverview
,
db_constraint
=
False
,
db_index
=
True
,
related_name
=
'modes'
,
)
# Django sets the `course_id` property in __init__ with the value from the database
# This pair of properties converts that into a proper CourseKey
...
...
common/djangoapps/student/migrations/0011_course_key_field_to_foreign_key.py
View file @
ceb0814f
...
...
@@ -6,6 +6,16 @@ import django.db.models.deletion
import
openedx.core.djangoapps.xmodule_django.models
# This should only be used for migrations that have be verified to have a net-neutral sql
# change generated by Django
class
NoSqlAlterField
(
migrations
.
AlterField
):
def
database_forwards
(
self
,
app_label
,
schema_editor
,
from_state
,
to_state
):
return
def
database_backwards
(
self
,
app_label
,
schema_editor
,
from_state
,
to_state
):
return
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
...
...
@@ -41,13 +51,13 @@ class Migration(migrations.Migration):
# Alter the fields to make them ForeignKeys (leaving off the db_constraint so
# that we don't create it at migration time). The db_column is left off because
# it defaults to ${field_name}_id, which we pinned it to up above.
migrations
.
AlterField
(
NoSql
AlterField
(
model_name
=
'courseenrollment'
,
name
=
'course'
,
field
=
models
.
ForeignKey
(
db_constraint
=
False
,
to
=
'course_overviews.CourseOverview'
),
preserve_default
=
True
,
),
migrations
.
AlterField
(
NoSql
AlterField
(
model_name
=
'historicalcourseenrollment'
,
name
=
'course'
,
field
=
models
.
ForeignKey
(
related_name
=
'+'
,
on_delete
=
django
.
db
.
models
.
deletion
.
DO_NOTHING
,
db_constraint
=
False
,
blank
=
True
,
to
=
'course_overviews.CourseOverview'
,
null
=
True
),
...
...
common/djangoapps/student/models.py
View file @
ceb0814f
...
...
@@ -996,7 +996,10 @@ class CourseEnrollment(models.Model):
user
=
models
.
ForeignKey
(
User
)
course
=
models
.
ForeignKey
(
CourseOverview
,
db_constraint
=
False
)
course
=
models
.
ForeignKey
(
CourseOverview
,
db_constraint
=
False
,
)
@property
def
course_id
(
self
):
...
...
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