|
| 1 | +.. _use postgresql: |
| 2 | + |
| 3 | +Use PostgreSQL as the Relational Database Backend |
| 4 | +################################################# |
| 5 | + |
| 6 | +.. note:: |
| 7 | + |
| 8 | + PostgreSQL support was introduced in the Verawood release. The Tutor plugin |
| 9 | + that enables this feature (`tutor-contrib-postgresql <https://github.com/qasimgulzar/tutor-contrib-postgresql>`_) |
| 10 | + is under active development. Migration from an existing MySQL installation is |
| 11 | + not yet supported. See `Current PostgreSQL Limitations`_ for details. |
| 12 | + |
| 13 | +PostgreSQL is a powerful open source relational database system with a strong |
| 14 | +reputation for reliability, standards compliance, and extensibility. It is a |
| 15 | +common choice for production web applications and is widely supported by |
| 16 | +managed cloud database services such as Amazon RDS, Google Cloud SQL, and |
| 17 | +Azure Database for PostgreSQL. |
| 18 | + |
| 19 | +Historically, the Open edX platform used MySQL as its only supported relational |
| 20 | +database. As of the Verawood release, PostgreSQL is also supported as a |
| 21 | +relational database backend for the Open edX platform, thanks to community |
| 22 | +contributions that updated the platform's Django migrations and field adapters |
| 23 | +to work correctly across both database engines. |
| 24 | + |
| 25 | +Prerequisites |
| 26 | +************* |
| 27 | + |
| 28 | +- A Tutor-based Open edX deployment (local or Kubernetes) |
| 29 | +- Tutor Verawood or later |
| 30 | +- A fresh Open edX installation (see `Current PostgreSQL Limitations`_) |
| 31 | + |
| 32 | +Installation |
| 33 | +************ |
| 34 | + |
| 35 | +PostgreSQL support is provided via the community-maintained Tutor plugin |
| 36 | +``tutor-contrib-postgresql``, authored by `@qasimgulzar |
| 37 | +<https://github.com/qasimgulzar>`_. |
| 38 | + |
| 39 | +.. warning:: |
| 40 | + |
| 41 | + This plugin is under active development and has not yet reached a stable |
| 42 | + release. Use in production environments is at your own risk. Review the |
| 43 | + `plugin repository <https://github.com/qasimgulzar/tutor-contrib-postgresql>`_ |
| 44 | + for the latest status before proceeding. |
| 45 | + |
| 46 | +Step 1: Install the plugin |
| 47 | +========================== |
| 48 | + |
| 49 | +.. code-block:: bash |
| 50 | +
|
| 51 | + pip install git+https://github.com/qasimgulzar/tutor-contrib-postgresql |
| 52 | +
|
| 53 | +Step 2: Enable the plugin |
| 54 | +========================= |
| 55 | + |
| 56 | +.. code-block:: bash |
| 57 | +
|
| 58 | + tutor plugins enable postgresql |
| 59 | +
|
| 60 | +Step 3: Build the Open edX image |
| 61 | +================================= |
| 62 | + |
| 63 | +The Open edX image must be rebuilt to include the necessary PostgreSQL client |
| 64 | +libraries and Python packages (``psycopg2``). |
| 65 | + |
| 66 | +.. code-block:: bash |
| 67 | +
|
| 68 | + tutor images build openedx |
| 69 | +
|
| 70 | +Step 4: Launch the platform |
| 71 | +============================ |
| 72 | + |
| 73 | +.. code-block:: bash |
| 74 | +
|
| 75 | + tutor local launch |
| 76 | +
|
| 77 | +This will initialize a fresh Open edX database in PostgreSQL and run all |
| 78 | +Django migrations against it. |
| 79 | + |
| 80 | +.. _Current PostgreSQL Limitations: |
| 81 | + |
| 82 | +Current Limitations |
| 83 | +******************* |
| 84 | + |
| 85 | +Fresh installations only |
| 86 | +======================== |
| 87 | + |
| 88 | +At this time, PostgreSQL support is available for fresh Open edX installations |
| 89 | +only. There is no supported or documented migration path from an existing MySQL |
| 90 | +database to PostgreSQL. Operators with an existing MySQL-backed deployment who |
| 91 | +wish to switch to PostgreSQL will need to wait for migration tooling and |
| 92 | +documentation to be developed. |
| 93 | + |
| 94 | +If you are interested in contributing to or tracking the development of |
| 95 | +MySQL-to-PostgreSQL migration support, see the `tutor-contrib-postgresql |
| 96 | +repository <https://github.com/qasimgulzar/tutor-contrib-postgresql>`_ and the |
| 97 | +`original platform pull request |
| 98 | +<https://github.com/openedx/openedx-platform/pull/35762>`_. |
| 99 | + |
| 100 | +Known rough edges |
| 101 | +================= |
| 102 | + |
| 103 | +PostgreSQL support was introduced with the following known limitations that may |
| 104 | +be addressed in subsequent releases. |
| 105 | + |
| 106 | +- Opaque key adapter coverage for v2 content libraries (beta libraries in |
| 107 | + Studio) may be incomplete. Runtime errors related to ``LearningContextKey`` |
| 108 | + or ``UsageKey`` serialization, if encountered, should be reported to the |
| 109 | + plugin maintainer. |
| 110 | +- The ``tutor-contrib-postgresql`` plugin does not yet have a stable release. |
| 111 | + Install directly from the GitHub repository as shown above. |
| 112 | + |
| 113 | +Getting Help |
| 114 | +************ |
| 115 | + |
| 116 | +PostgreSQL support for the Open edX platform is a community-driven effort. If |
| 117 | +you encounter issues or have questions: |
| 118 | + |
| 119 | +- Open an issue on the `tutor-contrib-postgresql repository |
| 120 | + <https://github.com/qasimgulzar/tutor-contrib-postgresql/issues>`_ |
| 121 | +- Post on the `Open edX discussion forum <https://discuss.openedx.org>`_ |
| 122 | + |
| 123 | + |
| 124 | +.. seealso:: |
| 125 | + |
| 126 | + :ref:`Open edX Databases` |
| 127 | + |
| 128 | + `Tutor PostgreSQL plugin <https://github.com/qasimgulzar/tutor-contrib-postgresql>`_ |
| 129 | + |
| 130 | + |
| 131 | +**Maintenance chart** |
| 132 | + |
| 133 | ++--------------+-------------------------------+----------------+--------------------------------+ |
| 134 | +| Review Date | Working Group Reviewer | Release |Test situation | |
| 135 | ++--------------+-------------------------------+----------------+--------------------------------+ |
| 136 | +| 2025-04-10 | sarina | Verawood | Pass | |
| 137 | ++--------------+-------------------------------+----------------+--------------------------------+ |
0 commit comments