Bug Description
Impossible to perform migrations through spark (experienced in versions 4.0.2 to 4.0.4)
Although DB credentials are set in .env and/orin app/Config/Database.php and successful query results obtained through Controller classes,
php spark migrate causes CodeIgniter\Database\Exceptions\DatabaseException
Exact command line output:
CodeIgniter CLI Tool - Version 4.0.4 - Server-Time: 2020-07-19 05:22:57am
Running all new migrations...
An uncaught Exception was encountered
Type: CodeIgniter\Database\Exceptions\DatabaseException
Message: Unable to connect to the database.
Filename: /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/Database/BaseConnection.php
Line Number: 425
Backtrace:
-646 - /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/Database/BaseConnection.php::initialize
-1548 - /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/Database/BaseConnection.php::query
-1591 - /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/Database/BaseConnection.php::listTables
-945 - /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/Database/MigrationRunner.php::tableExists
-193 - /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/Database/MigrationRunner.php::ensureTable
-128 - /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/Commands/Database/Migrate.php::latest
-100 - /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/CLI/Commands.php::run
-107 - /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/CLI/CommandRunner.php::run
-85 - /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/CLI/CommandRunner.php::index
-914 - /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/CodeIgniter.php::_remap
-404 - /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/CodeIgniter.php::runController
-312 - /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/CodeIgniter.php::handleRequest
-86 - /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/CLI/Console.php::run
-57 - /Applications/MAMP/ci4projs/deneme/spark::run
CodeIgniter 4 version
Last gotten in v4.0.4 release
Affected module(s)
spark
Expected behavior
All migrations performed successfully (without exceptions).
Steps to reproduce
- Open up a Terminal / command line window
- Change to the directory to the grand-parent level of your webserver's htdocs where htdocs will be substituted with the public directory of CI4
- composer create-project codeigniter4/appstarter deneme
- Open the project in your code editor and edit the .env file to set CI_ENVIRONMENT = development (duplicate it first from the file named 'env' if it doesn't exist - i.e.
cp env .env)
- Perform one or both of steps 6 and 7:
- Enter DB credentials for MySQL in .env file (with
database.default.DBDriver = MySQLi)
- Enter DB credentials in app/Config/Database.php
- Go back to the command line and run the following commands (in my example proj name is 'deneme':
9: cd deneme
php spark migrate:create AddBlog
- (Optional) Go back to your code editor and open the file whose name is resembles "2020_mm_dd_hhmmss_AddBlog.php" from app/Database/Migrations
- (Optional) Replace the contents of up() and down() methods with example from https://codeigniter.com/user_guide/dbmgmt/migration.html
- Go back to the command line and while still in the root directory of the CI4 project run
php spark migrate
- Compare your Terminal output to the following output:
CodeIgniter CLI Tool - Version 4.0.4 - Server-Time: 2020-07-19 05:42:10am
Running all new migrations...
An uncaught Exception was encountered
Type: CodeIgniter\Database\Exceptions\DatabaseException
Message: Unable to connect to the database.
Filename: /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/Database/BaseConnection.php
Line Number: 425
Backtrace:
-646 - /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/Database/BaseConnection.php::initialize
-1548 - /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/Database/BaseConnection.php::query
-1591 - /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/Database/BaseConnection.php::listTables
-945 - /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/Database/MigrationRunner.php::tableExists
-193 - /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/Database/MigrationRunner.php::ensureTable
-128 - /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/Commands/Database/Migrate.php::latest
-100 - /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/CLI/Commands.php::run
-107 - /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/CLI/CommandRunner.php::run
-85 - /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/CLI/CommandRunner.php::index
-914 - /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/CodeIgniter.php::_remap
-404 - /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/CodeIgniter.php::runController
-312 - /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/CodeIgniter.php::handleRequest
-86 - /Applications/MAMP/ci4projs/deneme/vendor/codeigniter4/framework/system/CLI/Console.php::run
-57 - /Applications/MAMP/ci4projs/deneme/spark::run
Context
- OS: Experienced in macOS 10.3
- Web server: Apache 2.x (in MAMP 5.4)
- PHP version 7.3.7
- MySQL 5.7
Bug Description
Impossible to perform migrations through spark (experienced in versions 4.0.2 to 4.0.4)
Although DB credentials are set in .env and/orin app/Config/Database.php and successful query results obtained through Controller classes,
php spark migratecausesCodeIgniter\Database\Exceptions\DatabaseExceptionExact command line output:
CodeIgniter 4 version
Last gotten in v4.0.4 release
Affected module(s)
spark
Expected behavior
All migrations performed successfully (without exceptions).
Steps to reproduce
cp env .env)database.default.DBDriver = MySQLi)9:
cd denemephp spark migrate:create AddBlogphp spark migrateContext