core icon indicating copy to clipboard operation
core copied to clipboard

:card_file_box: Issue #3540 db migration

Open macintoshplus opened this issue 9 months ago • 8 comments

This PR fixes issue #3540 and updates the Doctrine migrations to update MySQL/MariaDB database from Bolt version 4.2, 5.0, and 5.1.

A GitHub Action workflow has been added to check if migration is missing in the future (only for MySQL/MariaDB).

macintoshplus avatar Mar 07 '25 23:03 macintoshplus

This PR is ready to review. Sorry for the noise during the development ;-)

macintoshplus avatar Mar 11 '25 12:03 macintoshplus

Related issue #3021

macintoshplus avatar Mar 16 '25 15:03 macintoshplus

Hii @macintoshplus, the migrations are dropping tables first before re-creating them. What if I have data in those tables that needs to be preserved?

Vondry avatar Mar 17 '25 15:03 Vondry

Hii @macintoshplus, the migrations are dropping tables first before re-creating them. What if I have data in those tables that needs to be preserved?

The migration does not remove existing tables and data. It's the goal to use migrations.

Bolt can used with various DBMSs like SQLite (used in test mainly), MariaDB/MySQL, or Postgres. Generating one migration for 3 DBMSs is so hard. However using migration is necessary to manage changes with data effect.

In this PR, I have added the database dumps for MySQL/MariaDB to enable the migration tests and check if no change has been lost in migrations.

macintoshplus avatar Mar 17 '25 17:03 macintoshplus

Hii @macintoshplus, the migrations are dropping tables first before re-creating them. What if I have data in those tables that needs to be preserved?

The migration does not remove existing tables and data. It's the goal to use migrations.

Bolt can used with various DBMSs like SQLite (used in test mainly), MariaDB/MySQL, or Postgres. Generating one migration for 3 DBMSs is so hard. However using migration is necessary to manage changes with data effect.

In this PR, I have added the database dumps for MySQL/MariaDB to enable the migration tests and check if no change has been lost in migrations.

I am sorry if I misunderstood this PR then. So can I now safely upgrade from Bolt 5.1 to the latest 5.2.2 and run (how please?) DB migrations or should I wait for this PR to be merged?

Vondry avatar Mar 17 '25 18:03 Vondry

Hii @macintoshplus, the migrations are dropping tables first before re-creating them. What if I have data in those tables that needs to be preserved?

The migration does not remove existing tables and data. It's the goal to use migrations. Bolt can used with various DBMSs like SQLite (used in test mainly), MariaDB/MySQL, or Postgres. Generating one migration for 3 DBMSs is so hard. However using migration is necessary to manage changes with data effect. In this PR, I have added the database dumps for MySQL/MariaDB to enable the migration tests and check if no change has been lost in migrations.

I am sorry if I misunderstood this PR then. So can I now safely upgrade from Bolt 5.1 to the latest 5.2.2 and run (how please?) DB migrations or should I wait for this PR to be merged?

You have 2 choices:

  1. Upgrade to Bolt 5.2.2, run the actual migration and generate a new Doctrine migration to complete the migration (and execute it).
  2. Wait this PR was merged and upgrate after the new Bolt version has published.

To execute migration run this command: bin/console doctrine:migration:migrate

macintoshplus avatar Mar 24 '25 22:03 macintoshplus

Hi @macintoshplus and @bobvandevijver. Is there any blocker or can this be merged please?

Vondry avatar May 05 '25 17:05 Vondry

I can't merge without review validation. Please wait.

macintoshplus avatar May 05 '25 19:05 macintoshplus

I'm currently planning on fully removing the supplied migrations from Bolt core in version 6, as migrations heavily depend on the exact database being used. Bolt does offer the entities and will still offer the required schema for the database, it just becomes the developer responsibility to make them. I will look into offering a migration guide to squash your existing migrations, something like described here: https://jolicode.com/blog/a-new-way-to-squash-your-doctrine-migrations.

bobvandevijver avatar Oct 20 '25 09:10 bobvandevijver