Skip to content

Commit

Permalink
Remove MariaDb/MySQL Support (fossasia#190)
Browse files Browse the repository at this point in the history
* remove-mysql/mariadb-support

* quick-fixes-for-configFile
  • Loading branch information
AviGawande authored Sep 5, 2024
1 parent d2a617d commit cb04c71
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 49 deletions.
14 changes: 1 addition & 13 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,9 @@ jobs:
fail-fast: false
matrix:
python-version: [3.11]
database: [sqlite, postgres, mysql]
database: [sqlite, postgres]
steps:
- uses: actions/checkout@v4
- uses: getong/[email protected]
with:
mariadb version: '10.7'
mysql database: 'pretalx'
mysql root password: ''
if: matrix.database == 'mysql'
- uses: harmon758/postgresql-action@v1
with:
postgresql version: '14'
Expand All @@ -56,14 +50,8 @@ jobs:
run: |
sudo apt update
sudo apt install gettext
- name: Install system dependencies for mysql
run: sudo apt update && sudo apt install mariadb-client-10.6
if: matrix.database == 'mysql'
- name: Install Python dependencies
run: python -m pip install -Ue ".[dev]"
- name: Install MySQL dependencies
run: python -m pip install -Ue ".[mysql]"
if: matrix.database == 'mysql'
- name: Install Postgres dependencies
run: python -m pip install -Ue ".[postgres]"
if: matrix.database == 'postgres'
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM python:3.11-bookworm

RUN apt-get update && \
apt-get install -y git gettext libmariadb-dev libpq-dev locales libmemcached-dev build-essential \
apt-get install -y git gettext libpq-dev locales libmemcached-dev build-essential \
supervisor \
sudo \
locales \
Expand All @@ -26,7 +26,7 @@ COPY deployment/docker/pretalx.bash /usr/local/bin/pretalx
COPY deployment/docker/supervisord.conf /etc/supervisord.conf

RUN pip3 install -U pip setuptools wheel typing && \
pip3 install -e /pretalx/[mysql,postgres,redis] && \
pip3 install -e /pretalx/[postgres,redis] && \
pip3 install pylibmc && \
pip3 install gunicorn

Expand Down
4 changes: 1 addition & 3 deletions doc/administrator/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ The database section
+============+======================+=======================+
| PostgresQL | ``postgresql`` | ``pretalx[postgres]`` |
+------------+----------------------+-----------------------+
| MySQL | ``mysql`` | ``pretalx[mysql]`` |
+------------+----------------------+-----------------------+
| SQLite | ``sqlite3`` | ``pretalx`` |
+------------+----------------------+-----------------------+

Expand Down Expand Up @@ -172,7 +170,7 @@ The database section
``host``
~~~~~~~~

- The database host, or the socket location, as needed. You can set this variable to a socket path for MySQL. For local PostgreSQL authentication, you can leave this variable empty.
- The database host, or the socket location, as needed. For local PostgreSQL authentication, you can leave this variable empty.
- **Environment variable:** ``PRETALX_DB_HOST``
- **Default:** ``''``

Expand Down
14 changes: 3 additions & 11 deletions doc/administrator/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ and configuration here, but please have a look at the linked pages.
* **Python 3.11 or newer**
* An SMTP server to send out mails
* An HTTP reverse proxy like `nginx`_ to allow HTTPS connections
* A database server: `MySQL`_ 8+, MariaDB 10.4+ or `PostgreSQL`_ 12+, or SQLite
* * A database server: `PostgreSQL`_ 12+, or SQLite
Note: Support for MySQL and MariaDB has been removed to streamline compatibility and leverage advanced features available in PostgreSQL.
3. Given the choice, we’d recommend to use PostgreSQL.
* A `redis`_ server, if you want to use pretalx with an asynchronous task
runner or improved caching.
Expand Down Expand Up @@ -58,7 +59,7 @@ As we do not want to run pretalx as root, we first create a new unprivileged use
Step 2: Database setup
----------------------

pretalx runs with PostgreSQL, MySQL, MariaDB, or SQLite. If you’re using
pretalx runs with PostgreSQL or SQLite. If you’re using
SQLite, you can skip this step, as there is no need to set up the database.

We recommend using PostgreSQL. This is how you can set up a database for your
Expand All @@ -74,11 +75,6 @@ Make sure that your database encoding is UTF-8. You can check with this command:

.. highlight:: sql

When using MySQL, make sure you set the character set of the database to
``utf8mb4``, e.g. like this::

mysql> CREATE DATABASE pretalx DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;


Step 3: Package dependencies
----------------------------
Expand All @@ -91,7 +87,6 @@ flavours – on Ubuntu-like systems, you will need packages like:
- ``libssl-dev``
- ``python3-dev``
- ``gettext``
- ``libmysqlclient-dev`` if you use MariaDB


Step 4: Configuration
Expand Down Expand Up @@ -145,8 +140,6 @@ Now, upgrade your pip and then install the required Python packages::
+-----------------+------------------------------------------------------------------------+
| PostgreSQL | ``pip install --user --upgrade-strategy eager -U "pretalx[postgres]"`` |
+-----------------+------------------------------------------------------------------------+
| MySQL / MariaDB | ``pip install --user --upgrade-strategy eager -U "pretalx[mysql]"`` |
+-----------------+------------------------------------------------------------------------+

If you intend to run pretalx with asynchronous task runners or with redis as
cache server, you can add ``[redis]`` to the installation command, which will
Expand Down Expand Up @@ -334,7 +327,6 @@ If you want to read about updates, backups, and monitoring, head over to our
.. _Ansible role: https://github.com/pretalx/ansible-pretalx
.. _nginx: https://botleg.com/stories/https-with-lets-encrypt-and-nginx/
.. _Let’s Encrypt: https://letsencrypt.org/
.. _MySQL: https://dev.mysql.com/doc/refman/5.7/en/linux-installation-apt-repo.html
.. _PostgreSQL: https://www.postgresql.org/docs/
.. _redis: https://redis.io/documentation
.. _ufw: https://en.wikipedia.org/wiki/Uncomplicated_Firewall
Expand Down
6 changes: 3 additions & 3 deletions doc/administrator/maintenance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ Backups
There are two things which you should create backups of:

Database
Your SQL database (SQLite, MySQL or PostgreSQL). This is critical and you
Your SQL database (SQLite, PostgreSQL). This is critical and you
must **always always create automatic backups of your database**. There are
tons of tutorials on the internet on how to do this, and the process
depends on the choice of your database. For MySQL, see ``mysqldump`` and
for PostgreSQL, see the ``pg_dump`` tool. For SQLite, it is sufficient to
depends on the choice of your database.
For PostgreSQL, see the ``pg_dump`` tool. For SQLite, it is sufficient to
create a backup of the database file. You should create a cronjob or
timer that does the backups for you on a regular schedule. Do not forget to
add another one to rotate your backups.
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ dev = [
"rich",
"urllib3",
]
mysql = ["mysqlclient"]
postgres = ["psycopg2-binary"]
redis = ["redis~=5.0.0"]

Expand Down
20 changes: 4 additions & 16 deletions src/pretalx/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,9 @@ def merge_csp(*options, config=None):
## DATABASE SETTINGS
db_backend = config.get("database", "backend")
db_name = config.get("database", "name", fallback=str(DATA_DIR / "db.sqlite3"))
if db_backend == "mysql":
db_opts = {
"charset": "utf8mb4",
"use_unicode": True,
"init_command": "SET character_set_connection=utf8mb4,collation_connection=utf8mb4_unicode_ci;",
}
else:
db_opts = {}

db_opts = {}

DATABASES = {
"default": {
"ENGINE": "django.db.backends." + db_backend,
Expand All @@ -212,14 +207,7 @@ def merge_csp(*options, config=None):
"PORT": config.get("database", "port"),
"CONN_MAX_AGE": 0 if db_backend == "sqlite3" or HAS_CELERY else 120,
"OPTIONS": db_opts,
"TEST": (
{
"CHARSET": "utf8mb4",
"COLLATION": "utf8mb4_unicode_ci",
}
if "mysql" in db_backend
else {}
),
"TEST": {},
}
}
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
Expand Down

0 comments on commit cb04c71

Please sign in to comment.