codeigniter4 / shield

Authentication and Authorization for CodeIgniter 4
https://shield.codeigniter.com
MIT License
366 stars 133 forks source link

Bug: COLLATION 'utf8mb4_general_ci' is not valid for CHARACTER SET 'utf8mb3' #820

Closed hafizah65 closed 1 year ago

hafizah65 commented 1 year ago

PHP Version

8.1.10

CodeIgniter4 Version

4.4.1

Shield Version

dev-develop

Which operating systems have you tested for this bug?

Windows

Which server did you use?

apache

Database

8.0.29 - MySQL Community Server - GPL, 10.5.8-MariaDB - MariaDB Server

Did you customize Shield?

no

What happened?

i already have a db in both my local machine and development server but when i'm running php spark shield:setup, it stuck at migrating the tables. i'm getting the following error. all my db and table are set to utf8mb4 so i dont know where utf8mb3 came from

[CodeIgniter\Database\Exceptions\DatabaseException]

COLLATION 'utf8mb4_general_ci' is not valid for CHARACTER SET 'utf8mb3'

at SYSTEMPATH\Database\BaseConnection.php:646

Backtrace:
  1    SYSTEMPATH\Database\Forge.php:546
       CodeIgniter\Database\BaseConnection()->query('CREATE TABLE `migrations` (
        `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
        `version` VARCHAR(255) NOT NULL,
        `class` VARCHAR(255) NOT NULL,
        `group` VARCHAR(255) NOT NULL,
        `namespace` VARCHAR(255) NOT NULL,
        `time` INT(11) NOT NULL,
        `batch` INT(11) UNSIGNED NOT NULL,
        CONSTRAINT `pk_migrations` PRIMARY KEY(`id`)
) DEFAULT CHARACTER SET = utf8 COLLATE = utf8mb4_general_ci')

  2    SYSTEMPATH\Database\MigrationRunner.php:815
       CodeIgniter\Database\Forge()->createTable('migrations', true)

  3    SYSTEMPATH\Database\MigrationRunner.php:168
       CodeIgniter\Database\MigrationRunner()->ensureTable()

  4    SYSTEMPATH\Commands\Database\Migrate.php:84
       CodeIgniter\Database\MigrationRunner()->latest(null)

  5    VENDORPATH\codeigniter4\shield\src\Commands\Setup.php:308
       CodeIgniter\Commands\Database\Migrate()->run([...])

  6    VENDORPATH\codeigniter4\shield\src\Commands\Setup.php:92
       CodeIgniter\Shield\Commands\Setup()->runMigrations()

  7    VENDORPATH\codeigniter4\shield\src\Commands\Setup.php:79
       CodeIgniter\Shield\Commands\Setup()->publishConfig()

  8    SYSTEMPATH\CLI\Commands.php:65
       CodeIgniter\Shield\Commands\Setup()->run([])

  9    SYSTEMPATH\CLI\Console.php:37
       CodeIgniter\CLI\Commands()->run('shield:setup', [])

 10    ROOTPATH\spark:102
       CodeIgniter\CLI\Console()->run()

Steps to Reproduce

create a ci4 app with connecting db table users already existing installing shield and running command setup

Expected Output

table users updated with migrated fields

Anything else?

image
datamweb commented 1 year ago

Can you tell me the result of run the following command?

php spark migrate -n CodeIgniter\Shield