定制 arfaram/ezdatabasemigrationschema 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

arfaram/ezdatabasemigrationschema

Composer 安装命令:

composer require arfaram/ezdatabasemigrationschema

包简介

This bundle gives you the possibility to import,export and drop database table(s) by extending the doctrine-dbal-schema bundle introduced in v2.5

README 文档

README

This bundle comes with several commands to export, import and drop database table(s) using schema files during or after site development. It allows you also to add data to your tables

Basically, you can use DoctrineMigrationsBundle or KaliopMigrationBundle to achieve database migration but this bundle uses the doctrine-dbal-schema bundle(used only during eZ Platform installation) and coming with ezplatform v2.5. It uses the same concept and classes to migrate custom schema either using mysql or postgresql databases.

Requirement

eZPlatform 2.5+ (Open Source or EE), PHP 7+

Installation

composer require arfaram/ezdatabasemigrationschema:^0.1
  • Activate the Bundle in AppKernel.php
    public function registerBundles()
    {
        $bundles = array(
            new EzPlatform\DatabaseSchemaMigrationBundle\EzPlatformDatabaseSchemaMigrationBundle(),
        );

Commands

Export Schema

php bin/console db_schema_migration:schema:export

Parameters:

  • -t, --table[=TABLE] : The table name to be exported. It will create an export file using the same table name and current timestamp e.g ezcobj_state_1572446173.yaml
  • all: (default) If you don't specify explicitly the table name then it will export the entire db schema in db_schema_<timestamp>>.yaml

Note: You can specify the export folder path in parameters.yml otherwise it will create the dump files in your installation root folder:

Example:

parameters:
    database_schema_migration.export.schema.folder.path: '%kernel.root_dir%/../var/schemaexport/'

Note: Using eZPlatform Cloud you should mount the export path folder in .platform.app.yaml:

Import Schema

php bin/console db_schema_migration:schema:import

This command imports custom schema definition and you have to add the schema file path in parameters.yml

Example:

parameters:
    database_schema_migration.schema.file.path: '%kernel.root_dir%/../<Schema-file-path>'

You can find a schema example in bundle/doc/schema.yml or the legacy ezplatform schema.yaml

Import Data

Sometimes you want also to import data to an existing database table. This is also possible using below command:

php bin/console db_schema_migration:data:import

You have to add your sql file path in parameters.yml

Example:

parameters:
    database_schema_migration.import.data.file.path: '%kernel.root_dir%/../<mysql-or-postgresql-file-path>'

You can find an sql file example in bundle/doc/mysql/data.sql or just check more ezplatform mysql or postgresql clean data installation example.

Drop table(s) using schema file

php bin/console db_schema_migration:schema:drop

This command removes table(s) using an existing schema file.You have to add the file path in parameters.yml

Example:

parameters:
    database_schema_migration.schema.file.path: '%kernel.root_dir%/../<Schema-file-path>'

Drop table(s) using table name

php bin/console db_schema_migration:table:drop <Table-Name>

This command is using doctrine schema manager to drop db table.

How it works:

SchemaBuilder

The Installer.php class extends the CoreInstaller (used only during eZ Platform installation) but its constructor becomes a custom SchemaBuilder. It has the same structure like the EzSystems\DoctrineSchema\Builder\SchemaBuilder introduced in the doctrine-dbal-schema bundle.

The EventsSubscriber BuildSchemaSubscriber class will load the schema using the importSchemaFromFile() method defined in the SchemaBuilder.

You can also add a custom Subscriber which contains your custom schema. See the example in services.yml.

Take into account to use the SchemaBuilderEvents::INSTALLER_BUILD_SCHEMA event name to dispatch your subscriber during execution.

ImportData

The DbDataInstaller extend the DbBasedInstaller coming with the PlatformInstallerBundle and being used by CoreInstaller.php (used only during eZ Platform installation)

This class hat its own constructor and importData() method which runs your custom queries.

arfaram/ezdatabasemigrationschema 适用场景与选型建议

arfaram/ezdatabasemigrationschema 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 10 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「ezplatform」 「doctrine-dbal-schema」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 arfaram/ezdatabasemigrationschema 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 arfaram/ezdatabasemigrationschema 我们能提供哪些服务?
定制开发 / 二次开发

基于 arfaram/ezdatabasemigrationschema 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 16
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-only
  • 更新时间: 2019-10-30