`DISTINCT` cannot be used within `JSON_ARRAYAGG` in MySQL, so it was
removed.
Also, the PostgreSQL query was simplified and now generates JSONB
columns, to be consistent with all the other tables.
* Remove MySQL specific dialect.
* Fix migration `0033` to run on PostgreSQL.
* Correctly concatenate file paths by inserting a slash between path and
file name.
Functions like `JSON_ARRAY` and `JSON_OBJECT` have been introduced in
PostgreSQL 16 [1]. Older PostgreSQL versions were failing to run the
migrations due to the usage of these functions.
This change uses `jsonb_build_array` and `jsonb_build_object` functions
in PostgreSQL, which have been available since PostgreSQL 9.5 [2].
[1]: https://www.postgresql.org/docs/release/16.0/
[2]: https://www.postgresql.org/docs/release/9.5.0/#AEN132010
When a user does not set an email address, we now set it to `NULL` in
the database. That bypasses the unique constraint on the `email` column,
allowing multiple users to have no email address set.
Fixes#1445.
This change introduces PostgreSQL compatibility, by implementing the
following changes:
* Use `JSONB` instead of `JSON` for PostgreSQL databases. This is
achieved by creating a custom `CustomJSON` type that uses `JSONB` on
PostgreSQL and `JSON` on other databases, leveraging the variant
mechanism of SQLAlchemy.
* Add `is_postgresql` function to check if the current database is
PostgreSQL. Commonly used for migrations, but can be used to determine
how to build queries based on the database engine.
* Add `json_array_contains_value` function to check if a JSON array
includes a specific value. This function is needed as it's
engine-specific.
Support for PostgreSQL is on a best-effort basis, and it relies on the
community for continued support and testing. The project's main database
is MariaDB.
Closes#667.
This change only verifies that Alembic can upgrade and downgrade through
all the current migrations. It does not verify that the application
works correctly with PostgreSQL.
Trying to run MySQL as database (instead of MariaDB) was failing due to
incompatible migrations and lack of support for the MySQL driver.
These small changes fix the issue and recover the support for MySQL as
database driver.
Support for MySQL is on a best-effort basis, as the project's main
database is MariaDB.