wintercms / winter

Free, open-source, self-hosted CMS platform based on the Laravel PHP Framework.
https://wintercms.com
MIT License
1.36k stars 192 forks source link

Error with the database when installing version 1.2.4 #1060

Closed WebProviderNGO closed 7 months ago

WebProviderNGO commented 7 months ago

Winter CMS Build

1.2

PHP Version

8.1

Database engine

SQLite

Plugins installed

No response

Issue description

After installing v1.2.4, when accessing the Backend, the error is "Database missing".

In the console after executing php artisan winter:up error:

In Connection.php line 760:                                                                                                                                                     
could not find driver (SQL: select * from information_schema.tables where table_schema = database and table_name = migrations and table_type = 'BASE TABLE')  
In Exception.php line 18:
could not find driver  
In PDOConnection.php line 40:
could not find driver

I carry out the installation as always, there have never been any problems before. Tried it on several independent hosting providers.

In the new version, I noticed that it is now necessary to specify the path to the database. I tried in the root (by default) and the storage folder (as was the case in older versions).

To work around the bug, I install v1.2.2 first and then update. Everything works without errors.

Steps to replicate

Just install a new project with a new version :)

Workaround

To work around the bug, I install v1.2.2 first and then update. Everything works without errors.

LukeTowers commented 7 months ago

@WebProviderNGO this is very odd, our default DB config hasn't changed in years: https://github.com/wintercms/winter/blob/develop/config/database.php#L35

@mjauvin are you able to replicate this?

mjauvin commented 7 months ago

@LukeTowers the difference is that you added the following to core composer.json:

    "scripts": {
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],

So even when selecting SQLite as the database engine during the install, the database gets taken from the .env file (which contains mysql as the database).

mjauvin commented 7 months ago

@LukeTowers I think we should remove/comment out the DB_* settings in the .env.example file, that would resolve the issue.

bennothommo commented 7 months ago

I would probably prefer removing that script entirely. While I am all for environment files, Winter works fine without them, and some people prefer the config files.

I know this was added in https://github.com/wintercms/winter/pull/939 to support Laravel Sail, but I would imagine one could simply copy .env.example to .env as part of the bootstrap process and still achieve the same effect.

mjauvin commented 7 months ago

@bennothommo what does the web-installer do with the config? Does it fill-in the dotEnv file or the config/database.php one ?

bennothommo commented 7 months ago

@mjauvin it fills out the config currently, using the Laravel Config Writer that @jaxwilko wrote.

mjauvin commented 7 months ago

@bennothommo So I assume you remove the script entry in the composer.json ?

jaxwilko commented 7 months ago

My personal view would be to remove the script in composer.json and either people can run cp .env.example .env or ./artisan winter:env

LukeTowers commented 7 months ago

@marvindurot Will this break your workflow if we remove the command from the composer script but leave the example file?