8 Commits

Author SHA1 Message Date
Muhammad Qasim Gulzar
d847d222b2 fix: migrations to make postgresql compatible. (#35762)
This commit introduces several improvements to database migration
scripts to enhance compatibility between MySQL and PostgreSQL, ensure
case-sensitive behavior where needed, and improve migration safety and
correctness. The changes include dynamic SQL generation based on the
database engine, improved transaction handling, and adjustments to
field types and adapters for better cross-database support.

Database compatibility and case sensitivity improvements:

- Migration scripts in split_modulestore_django and learning_sequences
  now dynamically generate SQL statements for altering column case
  sensitivity and uniqueness based on whether the database is MySQL or
  PostgreSQL, ensuring correct behavior across both backends.
  - common/djangoapps/split_modulestore_django/migrations/0001_initial.py
  - openedx/core/djangoapps/content/learning_sequences/migrations/0001_initial.py

- The courseware.fields module now checks for "postgresql" in the
  database engine string instead of a specific backend name, improving
  compatibility with different PostgreSQL drivers.
  - lms/djangoapps/courseware/fields.py

- The 0011_csm_id_bigint migration in courseware now supports both MySQL
  and PostgreSQL for altering column types, with specific SQL for each
  backend.
  - lms/djangoapps/courseware/migrations/0011_csm_id_bigint.py

- The 0009_readd_facebook_url migration in course_overviews now
  introspects the table structure using backend-specific SQL for MySQL
  and PostgreSQL, ensuring correct detection of existing fields.
  - openedx/core/djangoapps/content/course_overviews/migrations/0009_readd_facebook_url.py

Migration safety and correctness:

- Service user creation and deletion in the commerce app is now wrapped
  in atomic transactions to ensure database consistency.
  - lms/djangoapps/commerce/migrations/0001_data__add_ecommerce_service_user.py

- The move_overrides_to_edx_when migration in courseware now specifies
  a no-op reverse migration, preventing accidental data loss on migration
  rollback.
  - lms/djangoapps/courseware/migrations/0008_move_idde_to_edx_when.py

Adapter registration and code cleanup:

- The common_initialization app now registers custom adapters for
  CourseLocator and related classes in psycopg2 when using PostgreSQL,
  ensuring proper serialization of these types.
  - openedx/core/djangoapps/common_initialization/apps.py

- Minor code cleanup and formatting improvements in migration files,
  including import order and field formatting for readability.
  - lms/djangoapps/grades/migrations/0015_historicalpersistentsubsectiongradeoverride.py
2026-02-12 14:02:46 -05:00
M. Zulqarnain
68bb83e727 pylint amnesty in openedx (#26341) 2021-02-03 14:56:09 +05:00
Feanil Patel
6e3fe00fff Fix all E303 pep8 errors. 2019-12-30 12:25:38 -05:00
Feanil Patel
9cf2f9f298 Run 2to3 -f future . -w
This will remove imports from __future__ that are no longer needed.

https://docs.python.org/3.5/library/2to3.html#2to3fixer-future
2019-12-30 10:35:30 -05:00
Peter Pinch
316fbae265 INCR-119 modernize openedx/core/djangoapps/certificates … (#20418)
* modernize openedx/core/djangoapps/certificates
openedx/core/djangoapps/commerce
openedx/core/djangoapps/common_initialization
openedx/core/djangoapps/config_model_utils

* rewmove unused import
2019-05-06 17:04:30 -04:00
Jeremy Bowman
11e134c552 PLAT-1916 Ignore existing usage of deprecated field_data 2018-02-02 16:12:00 -05:00
John Eskew
0279181624 Remove everything from CMS/LMS startup.py except single monkey-patch.
Move mimetype addition to common initialization.
2017-11-08 11:26:07 -05:00
Troy Sankey
c19eaef075 Move settings validation out of startup.py
This also creates a new app common_initialization in order to provide a
place to run initialization code common to both the LMS and CMS.
2017-11-03 12:23:54 -04:00