This abstract class contains most of the fields (aside from the id and foreign key to StudentModule that the subclasses need to manage). It also provides a get_history method that abstracts searching across multiple backends. Move router code to openedx/core We need to use it from cms and lms. Ensure aws_migrate can be used for migrating both the lms and cms. Handle queries directed to student_module_history vs default and the extra queries generated by Django 1.8 (SAVEPOINTS, etc). Additionally, flag testing classes as multi_db so that Django will flush the non-default database between unit tests. Further decouple the foreignkey relation between csm and csmhe When calling StudentModule().delete() Django will try to delete CSMHE objects, but naively does so in the database, not by consulting the database router. Instead, we disable django cascading deletes and listen for post_delete signals and clean up CSMHE by hand. Add feature flags for CSMHE One to turn it on/off so we can control the deploy. The other will control whether or not we read from two database tables or one when searching. Update tests to explicitly use this get_history method rather than looking directly into StudentModuleHistory or StudentModuleHistoryExtended. Inform lettuce to avoid the coursewarehistoryextended app Otherwise it fails when it can't find features/ in that app. Add Pg support, this is not tested automatically.
26 lines
1.1 KiB
Python
26 lines
1.1 KiB
Python
"""
|
|
Custom fields for use in the coursewarehistoryextended django app.
|
|
"""
|
|
|
|
from django.db.models.fields import AutoField
|
|
|
|
|
|
class UnsignedBigIntAutoField(AutoField):
|
|
"""
|
|
An unsigned 8-byte integer for auto-incrementing primary keys.
|
|
"""
|
|
def db_type(self, connection):
|
|
if connection.settings_dict['ENGINE'] == 'django.db.backends.mysql':
|
|
return "bigint UNSIGNED AUTO_INCREMENT"
|
|
elif connection.settings_dict['ENGINE'] == 'django.db.backends.sqlite3':
|
|
# Sqlite will only auto-increment the ROWID column. Any INTEGER PRIMARY KEY column
|
|
# is an alias for that (https://www.sqlite.org/autoinc.html). An unsigned integer
|
|
# isn't an alias for ROWID, so we have to give up on the unsigned part.
|
|
return "integer"
|
|
elif connection.settings_dict['ENGINE'] == 'django.db.backends.postgresql_psycopg2':
|
|
# Pg's bigserial is implicitly unsigned (doesn't allow negative numbers) and
|
|
# goes 1-9.2x10^18
|
|
return "BIGSERIAL"
|
|
else:
|
|
return None
|