luyadev / luya

LUYA is a scalable web framework and content management system with the goal to please developers, clients and users alike.
https://luya.io
MIT License
812 stars 207 forks source link

Migration fail #1797

Closed Taroxx closed 6 years ago

Taroxx commented 6 years ago

What steps will reproduce the problem?

New install. Step migration.

What is the expected result?

Use it)

What do you get instead? (A Screenshot can help us a lot!)

Migration failed.

*** applying m161220_183300_lcp_base_tables
    > create table admin_proxy_machine ...Exception: SQLSTATE[HY000]: General error: 1709 Index column size too large. The maximum column size is 767 bytes.
The SQL being executed was: CREATE TABLE `admin_proxy_machine` (
        `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
        `name` varchar(255) NOT NULL,
        `access_token` varchar(255) NOT NULL,
        `identifier` varchar(255) NOT NULL UNIQUE,
        `is_deleted` tinyint(1) DEFAULT FALSE,
        `is_disabled` tinyint(1) DEFAULT FALSE
) (/var/www/defpro.ru/luya-kickstarter/vendor/yiisoft/yii2/db/Schema.php:664)
#0 /var/www/defpro.ru/luya-kickstarter/vendor/yiisoft/yii2/db/Command.php(1263): yii\db\Schema->convertException(Object(PDOException), 'CREATE TABLE `a...')
#1 /var/www/defpro.ru/luya-kickstarter/vendor/yiisoft/yii2/db/Command.php(1075): yii\db\Command->internalExecute('CREATE TABLE `a...')
#2 /var/www/defpro.ru/luya-kickstarter/vendor/yiisoft/yii2/db/Migration.php(323): yii\db\Command->execute()
#3 /var/www/defpro.ru/luya-kickstarter/vendor/luyadev/luya-module-admin/src/migrations/m161220_183300_lcp_base_tables.php(15): yii\db\Migration->createTable('admin_proxy_mac...', Array)
#4 /var/www/defpro.ru/luya-kickstarter/vendor/yiisoft/yii2/db/Migration.php(114): m161220_183300_lcp_base_tables->safeUp()
#5 /var/www/defpro.ru/luya-kickstarter/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(725): yii\db\Migration->up()
#6 /var/www/defpro.ru/luya-kickstarter/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(199): yii\console\controllers\BaseMigrateController->migrateUp('m161220_183300_...')
#7 [internal function]: yii\console\controllers\BaseMigrateController->actionUp(0)
#8 /var/www/defpro.ru/luya-kickstarter/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#9 /var/www/defpro.ru/luya-kickstarter/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#10 /var/www/defpro.ru/luya-kickstarter/vendor/yiisoft/yii2/console/Controller.php(148): yii\base\Controller->runAction('', Array)
#11 /var/www/defpro.ru/luya-kickstarter/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('', Array)
#12 /var/www/defpro.ru/luya-kickstarter/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate', Array)
#13 /var/www/defpro.ru/luya-kickstarter/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('migrate', Array)
#14 /var/www/defpro.ru/luya-kickstarter/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(yii\console\Request))
#15 /var/www/defpro.ru/luya-kickstarter/vendor/luyadev/luya-core/base/Boot.php(205): yii\base\Application->run()
#16 /var/www/defpro.ru/luya-kickstarter/vendor/luyadev/luya-core/bin/luya(22): luya\base\Boot->applicationConsole()
#17 {main}
*** failed to apply m161220_183300_lcp_base_tables (time: 0.012s)

0 from 16 migrations were applied.

Migration failed. The rest of the migrations are canceled.

LUYA Check ouput (run this script and post the result: [luyacheck.php]https://gist.github.com/nadar/022f890e064c068e75ce6178cd14a09e

Additional infos

Q A
LUYA Version latest
PHP Version 7.1
Platform nginx, MariaDB
Operating system Debian 9.
nadar commented 6 years ago

Hi @Taroxx could you please try to use the luya admin dev-master (^1.2@dev) i guess this is fixed by https://github.com/luyadev/luya-module-admin/issues/109

Taroxx commented 6 years ago

Solved. The index limit is 767 bytes, not characters. And since Mysql's utf8mb4 character set (which the rest of the world calls utf8) needs (at most) 4 bytes per character you can only index up to VARCHAR(191). I rewrite migrations files. And it's ok now!

nadar commented 6 years ago

Thanks for investigation, so issue https://github.com/luyadev/luya-module-admin/issues/109 should fix the problem and we can close this issue?

Taroxx commented 6 years ago

Yes, of course!