movim / movim

Movim - Decentralized social platform
https://movim.eu
GNU Affero General Public License v3.0
1.71k stars 251 forks source link

Migrations failing on fresh install in fresh db in mariaDB Almalinux 9 #1315

Open CarlSinclair opened 2 months ago

CarlSinclair commented 2 months ago
PDOException: SQLSTATE[HY000]: General error: 1833 Cannot change column 'id': used in a foreign key constraint 'movim/caches_user_id_foreign' of table 'movim/caches' in /var/www/html/movim/vendor/illuminate/database/Connection.php:587
Stack trace:
#0 /var/www/html/movim/vendor/illuminate/database/Connection.php(587): PDOStatement->execute()
#1 /var/www/html/movim/vendor/illuminate/database/Connection.php(816): Illuminate\Database\Connection->Illuminate\Database\{closure}()
#2 /var/www/html/movim/vendor/illuminate/database/Connection.php(783): Illuminate\Database\Connection->runQueryCallback()
#3 /var/www/html/movim/vendor/illuminate/database/Connection.php(576): Illuminate\Database\Connection->run()
#4 /var/www/html/movim/vendor/illuminate/database/Schema/Blueprint.php(110): Illuminate\Database\Connection->statement()
#5 /var/www/html/movim/vendor/illuminate/database/Schema/Builder.php(602): Illuminate\Database\Schema\Blueprint->build()
#6 /var/www/html/movim/vendor/illuminate/database/Schema/Builder.php(444): Illuminate\Database\Schema\Builder->build()
#7 /var/www/html/movim/database/migrations/20180510141439_change_length_contacts_id.php(30): Illuminate\Database\Schema\Builder->table()
#8 /var/www/html/movim/vendor/robmorgan/phinx/src/Phinx/Migration/Manager/Environment.php(111): ChangeLengthContactsId->up()
#9 /var/www/html/movim/vendor/robmorgan/phinx/src/Phinx/Migration/Manager.php(388): Phinx\Migration\Manager\Environment->executeMigration()
#10 /var/www/html/movim/vendor/robmorgan/phinx/src/Phinx/Migration/Manager.php(359): Phinx\Migration\Manager->executeMigration()
#11 /var/www/html/movim/vendor/robmorgan/phinx/src/Phinx/Console/Command/Migrate.php(122): Phinx\Migration\Manager->migrate()
#12 /var/www/html/movim/vendor/symfony/console/Command/Command.php(326): Phinx\Console\Command\Migrate->execute()
#13 /var/www/html/movim/vendor/symfony/console/Application.php(1078): Symfony\Component\Console\Command\Command->run()
#14 /var/www/html/movim/vendor/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand()
#15 /var/www/html/movim/vendor/robmorgan/phinx/src/Phinx/Console/PhinxApplication.php(70): Symfony\Component\Console\Application->doRun()
#16 /var/www/html/movim/vendor/symfony/console/Application.php(175): Phinx\Console\PhinxApplication->doRun()
#17 /var/www/html/movim/vendor/robmorgan/phinx/bin/phinx(28): Symfony\Component\Console\Application->run()
#18 /var/www/html/movim/vendor/bin/phinx(119): include('...')
#19 {main}
Next Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1833 Cannot change column 'id': used in a foreign key constraint 'movim/caches_user_id_foreign' of table 'movim/caches' (Connection: default, SQL: ALTER TABLE users CHANGE id id VARCHAR(256) NOT NULL) in /var/www/html/movim/vendor/illuminate/database/Connection.php:829
Stack trace:
#0 /var/www/html/movim/vendor/illuminate/database/Connection.php(783): Illuminate\Database\Connection->runQueryCallback()
#1 /var/www/html/movim/vendor/illuminate/database/Connection.php(576): Illuminate\Database\Connection->run()
#2 /var/www/html/movim/vendor/illuminate/database/Schema/Blueprint.php(110): Illuminate\Database\Connection->statement()
#3 /var/www/html/movim/vendor/illuminate/database/Schema/Builder.php(602): Illuminate\Database\Schema\Blueprint->build()
#4 /var/www/html/movim/vendor/illuminate/database/Schema/Builder.php(444): Illuminate\Database\Schema\Builder->build()
#5 /var/www/html/movim/database/migrations/20180510141439_change_length_contacts_id.php(30): Illuminate\Database\Schema\Builder->table()
#6 /var/www/html/movim/vendor/robmorgan/phinx/src/Phinx/Migration/Manager/Environment.php(111): ChangeLengthContactsId->up()
#7 /var/www/html/movim/vendor/robmorgan/phinx/src/Phinx/Migration/Manager.php(388): Phinx\Migration\Manager\Environment->executeMigration()
#8 /var/www/html/movim/vendor/robmorgan/phinx/src/Phinx/Migration/Manager.php(359): Phinx\Migration\Manager->executeMigration()
#9 /var/www/html/movim/vendor/robmorgan/phinx/src/Phinx/Console/Command/Migrate.php(122): Phinx\Migration\Manager->migrate()
#10 /var/www/html/movim/vendor/symfony/console/Command/Command.php(326): Phinx\Console\Command\Migrate->execute()
#11 /var/www/html/movim/vendor/symfony/console/Application.php(1078): Symfony\Component\Console\Command\Command->run()
#12 /var/www/html/movim/vendor/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand()
#13 /var/www/html/movim/vendor/robmorgan/phinx/src/Phinx/Console/PhinxApplication.php(70): Symfony\Component\Console\Application->doRun()
#14 /var/www/html/movim/vendor/symfony/console/Application.php(175): Phinx\Console\PhinxApplication->doRun()
#15 /var/www/html/movim/vendor/robmorgan/phinx/bin/phinx(28): Symfony\Component\Console\Application->run()
#16 /var/www/html/movim/vendor/bin/phinx(119): include('...')
#17 {main}
Script vendor/bin/phinx migrate --ansi handling the movim:migrate event returned with error code 1
edhelas commented 2 months ago

What is you MariaDB version. Also there is a lot of chances that your distro is enforcing some behavior, I cannot test them against the multiple MySQL/MariaDB flags that exists, do check your error on Stackoverflow and see if there's a specific config on your side to change in your database config.

CarlSinclair commented 2 months ago

Ver 15.1 Distrib 10.11.7-MariaDB, for Linux (x86_64) using EditLine wrapper

Pretty weird that this happened on a fresh install though, following the instructions.

edhelas commented 2 months ago

Hello, got any news regarding that issue ?

CarlSinclair commented 2 months ago

What info do you need? I provided the MariaDB version.

edhelas commented 2 months ago

As I was saying above, I'm not planning to test Movim on the myriad of MySQL/MariaDB flavors, but I'm open to integrate fixes that you may find along the way.

CarlSinclair commented 2 months ago

I tried setting it up using Postgres but ran into other problems probably due to the fact that I'm on RHEL, so I'm just going to give up on it for now until I set up a Debian-based machine.

pann commented 1 month ago

I am seeing the same issue, on a fresh Debian 12 installation, MariaDB info: Server version: 10.11.6-MariaDB-0+deb12u1 Debian 12 Movim is the only database that was created, and no modifications to any MariaDB configs.

pann commented 1 month ago

I am seeing the same issue, on a fresh Debian 12 installation, MariaDB info: Server version: 10.11.6-MariaDB-0+deb12u1 Debian 12 Movim is the only database that was created, and no modifications to any MariaDB configs.

Perhaps this is related: https://jira.mariadb.org/browse/MDEV-31987?jql=text%20~%20%22set_foreign_key_Check%22

edhelas commented 1 month ago

Did you find the cause of the issue ?

pann commented 1 month ago

There was an update to mariaDB regarding the handling of foreign keys. I managed to install MariaDB 10.3 using this: https://olvy.net/blog/olvy-ported-mariadb103-to-debian12-and-ubuntu2204/

If I understood correctly, the update was first released as a patch, but I did not figure out when it was pulled into the normal releases.