Tik*_*TaZ 4 symfony doctrine-migrations
在带有 Doctrine Migrations 2.2.0 的 Symfony 5 上,我想执行自定义的 Doctrine 迁移文件。我的实体是使用 InnoDB utf8mb4_unicode_ci (doctrine.yaml 中的默认值)创建的。
当我执行时bin/console doctrine:migrations:status --show-versions我得到:
An exception occurred while executing 'CREATE TABLE migration_versions (version VARCHAR(1024) NOT NULL, executed_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', PRIMARY KEY(version)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB':
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 3072 bytes
Run Code Online (Sandbox Code Playgroud)
所以我修改doctrine_migrations.yaml并将version_column_length的值更改为255,但现在使用相同的命令我得到
In BaseNode.php line 425:
Invalid configuration for path "doctrine_migrations.storage.table_storage.version_column_length": The minimum length for the version column is 1024.
In ExprBuilder.php line 187:
The minimum length for the version column is 1024.
Run Code Online (Sandbox Code Playgroud)
可以将自动创建的实体表的 varchar 长度更改为 1024,因此这不是我的数据库的限制。如何自动创建具有适当列长度的migrations_versions表?
配置/包/doctrine.yaml
In BaseNode.php line 425:
Invalid configuration for path "doctrine_migrations.storage.table_storage.version_column_length": The minimum length for the version column is 1024.
In ExprBuilder.php line 187:
The minimum length for the version column is 1024.
Run Code Online (Sandbox Code Playgroud)
配置/包/doctrine_migrations.yaml
doctrine:
dbal:
url: '%env(resolve:DATABASE_URL)%'
mapping_types:
enum: string
# IMPORTANT: You MUST configure your server version,
# either here or in the DATABASE_URL env var (see .env file)
#server_version: '5.7'
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1463 次 |
| 最近记录: |