crater-invoice / crater

Open Source Invoicing Solution for Individuals & Businesses
https://craterapp.com
GNU Affero General Public License v3.0
7.71k stars 1.6k forks source link

Database initialization - Cannot declare class CreateBouncerTables #1117

Open cgx opened 1 year ago

cgx commented 1 year ago

During the database initialization step of the installation wizard, I get the error Cannot declare class CreateBouncerTables, because the name is already in use.

crater-db-init-error

The MySQL database is initially empty but when the error occurs, the migrations table has been created but has no row.

Environment

cgx commented 1 year ago

Full error from the logs:

[2022-12-31 22:19:17] production.ERROR: Cannot declare class CreateBouncerTables, because the name is already in use {"exception":"[object] (Symfony\\Component\\ErrorHandler\
\Error\\FatalError(code: 0): Cannot declare class CreateBouncerTables, because the name is already in use at /var/www/html/database/migrations/2022_12_31_221846_create_bounce
r_tables.php:0)
[stacktrace]
#0 {main}
"}
natterstefan commented 1 year ago

Hi @cgx,

I've got the same issue at the moment... Did you find a solution for this?

d9media commented 1 year ago

same

shinsenter commented 1 year ago

After reviewing the Crater installation process, I discovered that two dependencies were causing issues. They will generate their own migration scripts when Crater saving the database connection settings.

https://github.com/spatie/laravel-medialibrary/blob/067a3710096fec4e5ed193031803cc5b91e476f5/src/MediaLibraryServiceProvider.php#L47-L51

https://github.com/JosephSilber/bouncer/blob/2c08082f0e4d13fcdc11ceb020badf272c05faa6/src/BouncerServiceProvider.php#L100-L113

I think this issue needs to be reviewed by Crater's developers and they would provide a fix soon.

cgx commented 1 year ago

I've got the same issue at the moment... Did you find a solution for this?

It looks like the migration step is timing out when executed from the Web wizard. My solution was to run all initialization commands from the terminal:

php artisan migrate:fresh
php artisan db:seed
php artisan db:seed --class=DemoSeeder

Make sure to first configure the database environment variables.