corrivate/laravel-mysqldump 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

corrivate/laravel-mysqldump

Composer 安装命令:

composer require corrivate/laravel-mysqldump

包简介

Artisan commands to conveniently dump and import the DB, with stripping options

README 文档

README

logo

Total Downloads Latest Stable Version License

Purpose

  • Easily dump whole databases or specific tables, with artisan mysql:export
  • Easily import, with artisan mysql:import
  • Strip content from tables, for example, strip the customer data but keep the product catalog.

IMPORTANT Stripping content from tables does not respect foreign key constraints. Meaning, if you strip a parent table but NOT a child table that depends on the parent, and then import that file somewhere else, you're going to foreign key failures. Always make sure to also strip dependent tables.

Setup

Install with:

composer require corrivate/laravel-mysqldump

Configuration

Configuration is not required. You can ad-hoc decide to strip tables by using artisan mysql:export --strip= with a comma-separated list of tables.

If your project has a standard set of tables you usually want to strip during export, you can add those to your config/database.php to be stripped by default.

'mysql' => [
    'driver' => 'mysql',
    'url' => env('DB_URL'),
    'host' => env('DB_HOST', '127.0.0.1'),
    'port' => env('DB_PORT', '3306'),
    'database' => env('DB_DATABASE', 'laravel'),
    'username' => env('DB_USERNAME', 'root'),
    'password' => env('DB_PASSWORD', ''),
    'unix_socket' => env('DB_SOCKET', ''),
    'charset' => env('DB_CHARSET', 'utf8mb4'),
    'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
    'prefix' => '',
    'prefix_indexes' => true,
    'strict' => true,
    'engine' => null,
    'options' => extension_loaded('pdo_mysql') ? array_filter([
        PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
    ]) : [],
    
    // These tables will only have their schema exported, no data
    'strip_tables_on_export' => [
        'cache', 'cache_locks',
        'job_batches', 'jobs',
        'users', 'password_reset_tokens', 'sessions',
        'pulse_aggregates', 'pulse_entries', 'pulse_values',
    ],
],

This configuration will be applied by default when using a stripped mode export. If you want to run a stripped export without this configuration, pass a --config-stripped=0 option to the command.

Note that you can combine or replace this with the --strip-manual=your,specific,tables option.

Usage

Export

artisan mysql:export [options]

The default behavior is to create a gzipped file dump.sql.gz with an export based on your stripping configuration.

Options

  • --filename=dump.sql: Name of the file to export to. Note that '.gz' will be appended if using the gzip option as well.
  • --gzip=1 can be set to 0 to turn off compression.
  • --mode=stripped: perform a stripped, schema or full export. Default is stripped.
  • --config-stripped=1 adds the tables configured in database.mysql.strip_tables_on_export to the list of tables to strip. Default is 1; set to 0 if you only want to manually strip tables.
  • --strip-manual= (OPTIONAL) accepts a comma-separated list of tables to strip. These will me merged with those from your configuration (if any).

Import

artisan mysql:import <filename>

Credits

This package is built on top of spatie/db-dumper. The original inspiration was the Magento packages magerun2 and mage-db-sync.

Corrivate

(en.wiktionary.org)

Etymology

From Latin corrivatus, past participle of corrivare ("to corrivate").

Verb

corrivate (third-person singular simple present corrivates, present participle corrivating, simple past and past participle corrivated)

(obsolete) To cause to flow together, as water drawn from several streams.

corrivate/laravel-mysqldump 适用场景与选型建议

corrivate/laravel-mysqldump 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 478 次下载、GitHub Stars 达 2, 最近一次更新时间为 2024 年 01 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 corrivate/laravel-mysqldump 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-01-08