Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
problem-builder
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
OpenEdx
problem-builder
Commits
7bb7d2b9
Commit
7bb7d2b9
authored
Apr 23, 2015
by
Braden MacDonald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Data migration
parent
94cc894d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
0 deletions
+46
-0
problem_builder/south_migrations/0002_copy_from_mentoring.py
+46
-0
No files found.
problem_builder/south_migrations/0002_copy_from_mentoring.py
0 → 100644
View file @
7bb7d2b9
# -*- coding: utf-8 -*-
from
django.db.utils
import
DatabaseError
from
south.db
import
db
from
south.v2
import
DataMigration
class
Migration
(
DataMigration
):
def
forwards
(
self
,
orm
):
"""
Copy student data from old table to the new one.
Problem Builder stores student answers in 'problem_builder_answer'.
However earlier versions [may have] used 'mentoring_answer'.
If a 'mentoring' app is currently installed on this instance, copy the student data over
to the new table in case it is being used.
"""
try
:
db
.
execute
(
'INSERT INTO problem_builder_answer ('
'name, student_id, course_id, student_input, created_on, modified_on '
') SELECT '
'name, student_id, course_id, student_input, created_on, modified_on '
'FROM mentoring_answer'
)
except
DatabaseError
:
# Would like to just catch 'Table does not exist' but can't do that in a db-agnostic way
print
(
" - Seems like mentoring_answer does not exist. No data migration needed."
)
def
backwards
(
self
,
orm
):
raise
RuntimeError
(
"Cannot safely reverse this migration."
)
models
=
{
'problem_builder.answer'
:
{
'Meta'
:
{
'unique_together'
:
"(('student_id', 'course_id', 'name'),)"
,
'object_name'
:
'Answer'
},
'course_id'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'50'
,
'db_index'
:
'True'
}),
'created_on'
:
(
'django.db.models.fields.DateTimeField'
,
[],
{
'auto_now_add'
:
'True'
,
'blank'
:
'True'
}),
'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'modified_on'
:
(
'django.db.models.fields.DateTimeField'
,
[],
{
'auto_now'
:
'True'
,
'blank'
:
'True'
}),
'name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'50'
,
'db_index'
:
'True'
}),
'student_id'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'32'
,
'db_index'
:
'True'
}),
'student_input'
:
(
'django.db.models.fields.TextField'
,
[],
{
'default'
:
"''"
,
'blank'
:
'True'
})
}
}
complete_apps
=
[
'problem_builder'
]
symmetrical
=
True
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