Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrations randomly failing, no way to troubleshoot #139

Open
vpithart opened this issue Dec 10, 2024 · 1 comment
Open

Migrations randomly failing, no way to troubleshoot #139

vpithart opened this issue Dec 10, 2024 · 1 comment

Comments

@vpithart
Copy link

vpithart commented Dec 10, 2024

Issue 1: Some migrations fail without apparent reason.

Here's the migration SQL (/db/structures/2024-12-07-134509-dokumenty.sql)

CREATE TABLE Dokument (
    id INT AUTO_INCREMENT PRIMARY KEY,
    event1_time TIMESTAMP,
    event2_time TIMESTAMP
);

☝ tested in MySQL CLI and works.

On running php www/index.php migrations:continue it fails:
ERROR: Executing migration "../db/structures/2024-12-07-134509-dokumenty.sql" has failed.

Issue 2: There's no way to tell why.

The error output is completely useless and provides no clue on what's wrong:

$ php www/index.php migrations:continue 
Nextras Migrations
CONTINUE
2 migrations need to be executed.
ERROR: Executing migration "../db/structures/2024-12-07-134509-dokumenty.sql" has failed.
[10-Dec-2024 13:51:59 Europe/Prague] PHP Fatal error:  Uncaught TypeError: Cannot assign bool to property Nette\Application\Application::$errorPresenter of type ?string in /opt/.../temp/cache/nette.configurator/Container_2dae16c776.php:1990
Stack trace:
#0 /opt/.../vendor/nette/utils/src/Utils/Arrays.php(491): Container_2dae16c776->{closure}()
#1 /opt/.../vendor/nette/application/src/Application/Application.php(81): Nette\Utils\Arrays::invoke()
#2 /opt/.../www/index.php(9): Nette\Application\Application->run()
#3 {main}
  thrown in /opt/.../temp/cache/nette.configurator/Container_2dae16c776.php on line 1990

This output is the same no matter what the SQL file actually contains. Valid SQL, invalid SQL, even with any gibberish -- no useless error message.

Versions

PHP 8.2.26
"nextras/migrations": "^3.3",
"nette/database": "~3.2.0",

config.neon:

migrations:
    dir: %appDir%/../db         # migrations base directory
    driver: mysql               # pgsql or mysql
    dbal: nette                 # nextras, nette, doctrine or dibi

Database Server version: 10.1.48-MariaDB-1~bionic mariadb.org binary distribution

@mabar
Copy link
Contributor

mabar commented Dec 10, 2024

It clearly tells fatal error happened due to app beingly wrongly configured. Specifically configuration of error presenter. When the error handler itself is broken, you simply can't get reasonable error message from any console command, this is not problem in nextras/migrations.

Making an educated guess - the error occurs here https://github.com/Kdyby/Console/blob/2dd595a086e1f06cd40233d1c7a8e6a57e42acd9/src/DI/ConsoleExtension.php#L204 kdyby/console is not compatible with the version of nette/application that you use.

Accessing console application via www/index.php has been always a bad and even kdyby/console docs recommend another way - https://github.com/Kdyby/Console/blob/2dd595a086e1f06cd40233d1c7a8e6a57e42acd9/docs/en/index.md#running-the-console
That way, no nette/application bridge is needed.

Also whole Kdyby is practically dead for a long time and you shall replace it with dependencies that are maintained, e.g. https://github.com/orisai/nette-console

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants