webandco / flow-migrate-database
此包的最新版本(0.0.1)没有提供许可信息。
0.0.1
2022-05-04 16:01 UTC
Requires
- neos/flow: *
README
Neos Flow 插件,用于运行 doctrine 迁移,并将数据从源数据库复制到目标数据库。
目录
快速入门
- 使用 composer 安装此包
composer require webandco/flow-migrate-database
(或通过将依赖项添加到已安装包的 composer 清单中)
- 配置源和目标数据库
Webandco: MigrateDatabase: connections: source: persistence: doctrine: # secondLevelCache is needed by the entitymanager secondLevelCache: enable: false backendOptions: driver: pdo_mysql dbname: docker user: someuser password: somepassword host: mysql charset: 'UTF8' defaultTableOptions: charset: 'UTF8' destination: persistence: doctrine: # secondLevelCache is needed by the entitymanager secondLevelCache: enable: false backendOptions: driver: pdo_pgsql dbname: docker user: user password: pwd host: postgres charset: 'UTF8' defaultTableOptions: charset: 'UTF8'
- 配置创建表结构的命令
Webandco: MigrateDatabase: preprocess: commands: doctrineMigrate: command: 'doctrine:migrate' someFlowpackJobQueue: command: 'queue:setup' arguments: queue: 'jobQueueName'
- 在目标数据库中创建表结构
./flow migration:createStructure
- 从源复制行到目标
./flow migration:copyTables
介绍
此包旨在临时安装,直到完成迁移所需的时间。迁移分为两个阶段
- 创建目标表结构,例如,通过在目标数据库上使用
doctrine:migrate
命令 - 从源数据库复制行到目标
为了在目标数据库上运行 1.,使用了自定义的 EntityManagerFactory
,它根据环境变量选择数据库连接设置。
此包不会干扰 Neos.Flow.persistence
中配置的数据库,而是使用源和目标数据库的自定义设置。
这些自定义数据库设置与 Neos.Flow.persistence
的配置选项相同。
命令行界面
使用 webandco.migratedatabase:migration:*
命令运行迁移
性能
插入被分成块,并通过 INSERT INTO [table] (col1,col2,....) VALUES (...),(...),(...),..
发送到目标数据库。
在本地测试迁移中,从 MySql 到 PostgreSQL 的约 2.6 百万行数据花费了大约 5 分钟。
许可
此包根据 MIT 许可证授权