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

feat: Add InnoDB engine to migration create table methods #745

Merged
merged 4 commits into from
May 17, 2023

Conversation

kpeu3u
Copy link
Contributor

@kpeu3u kpeu3u commented May 16, 2023

resolved: #741

@kenjis
Copy link
Member

kenjis commented May 16, 2023

Add the attribute only when using MySQL.

There were 212 errors:

1) Tests\Authentication\ForcePasswordResetTest::testForceGlobalPasswordReset
CodeIgniter\Database\Exceptions\DatabaseException: SQLite3::exec(): near "'InnoDB'": syntax error

/home/runner/work/shield/shield/vendor/codeigniter4/framework/system/Database/BaseConnection.php:646
/home/runner/work/shield/shield/vendor/codeigniter4/framework/system/Database/Forge.php:546
/home/runner/work/shield/shield/src/Database/Migrations/2020-12-28-223112_create_auth_tables.php:48
/home/runner/work/shield/shield/vendor/codeigniter4/framework/system/Database/MigrationRunner.php:877
/home/runner/work/shield/shield/vendor/codeigniter4/framework/system/Database/MigrationRunner.php:188
/home/runner/work/shield/shield/vendor/codeigniter4/framework/system/Test/DatabaseTestTrait.php:151
/home/runner/work/shield/shield/vendor/codeigniter4/framework/system/Test/DatabaseTestTrait.php:109
/home/runner/work/shield/shield/vendor/codeigniter4/framework/system/Test/DatabaseTestTrait.php:55
/home/runner/work/shield/shield/vendor/codeigniter4/framework/system/Test/CIUnitTestCase.php:248
/home/runner/work/shield/shield/tests/_support/TestCase.php:21
/home/runner/work/shield/shield/tests/Authentication/ForcePasswordResetTest.php:31

https://github.com/codeigniter4/shield/actions/runs/4989110786/jobs/8932607159?pr=745

@kpeu3u
Copy link
Contributor Author

kpeu3u commented May 16, 2023

['ENGINE' => 'InnoDB'] has been restricted to MySQLi platform only.

$authConfig = config('Auth');
$this->tables = $authConfig->tables;
$this->ifNotExists = false;
$this->attributes = ($this->db->getPlatform() === 'MySQLi') ? ['ENGINE' => 'InnoDB'] : [];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kenjis , as far as I know, MySQLi, OCI8, Postgre and SQLSRV accept the attributes ['ENGINE' => 'InnoDB'].
And only SQLite3 does not understand ['ENGINE' => 'InnoDB']. Isn't it better to act as follows?

$this->attributes = ($this->db->getPlatform() === 'SQLite3') ? [] :  ['ENGINE' => 'InnoDB'];

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. InnoDB (and ENGINE) is configration only in MySQL.
I believe OCI8, Postgre and SQLSRV does not understand the attribute.
I don't know why these drivers do not report an error like SQLite.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it will stay like i did it, e.g. restricted to MySQL only!

@datamweb
Copy link
Collaborator

@kpeu3u Thank you!

@datamweb datamweb merged commit 8455236 into codeigniter4:develop May 17, 2023
@kpeu3u kpeu3u deleted the innodb_engine branch December 7, 2023 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Database exceptions "Specified key was too long; max key length is 1000 bytes"
3 participants