From 6c3e4d788055af049a30bdb3fc7f901e0bb1b001 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sat, 10 Jan 2026 21:14:27 +0100 Subject: [PATCH] Added documentation about the database conversion command --- docs/installation/choosing_database.md | 24 ++++++++++++++++++++++-- docs/usage/console_commands.md | 1 + 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/docs/installation/choosing_database.md b/docs/installation/choosing_database.md index 8a070120..27d70e54 100644 --- a/docs/installation/choosing_database.md +++ b/docs/installation/choosing_database.md @@ -21,8 +21,8 @@ differences between them, which might be important for you. Therefore the pros a are listed here. {: .important } -You have to choose between the database types before you start using Part-DB and **you can not change it (easily) after -you have started creating data**. So you should choose the database type for your use case (and possible future uses). +While you can change the database platform later (see below), it is still experimental and not recommended. +So you should choose the database type for your use case (and possible future uses). ## Comparison @@ -180,3 +180,23 @@ and it is automatically used if available. For SQLite and MySQL < 10.7 it has to be emulated if wanted, which is pretty slow. Therefore it has to be explicitly enabled by setting the `DATABASE_EMULATE_NATURAL_SORT` environment variable to `1`. If it is 0 the classical binary sorting is used, on these databases. The emulations might have some quirks and issues, so it is recommended to use a database which supports natural sorting natively, if you want to use it. + +## Converting between database platforms + +{: .important } +The database conversion is still experimental. Therefore it is recommended to backup your database before performing a conversion, and check if everything works as expected afterwards. + +If you want to change the database platform of your Part-DB installation (e.g. from SQLite to MySQL/MariaDB or PostgreSQL, or vice versa), there is the `partdb:migrations:convert-db-platform` console command, which can help you with that: + +1. Make a backup of your current database to be safe if something goes wrong (see the backup documentation). +2. Ensure that your database is at the latest schema by running the migrations: `php bin/console doctrine:migrations:migrate` +3. Change the `DATABASE_URL` environment variable to the new database platform and connection information. Copy the old `DATABASE_URL` as you will need it later. +4. Run `php bin/console doctrine:migrations:migrate` again to create the database schema in the new database. You will not need the admin password, that is shown when running the migrations. +5. Run the conversion command, where you have to provide the old `DATABASE_URL` as parameter: `php bin/console partdb:migrations:convert-db-platform ` + Replace `