承接 mitsuki/mitsuki-db-migrations 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

mitsuki/mitsuki-db-migrations

Composer 安装命令:

composer require mitsuki/mitsuki-db-migrations

包简介

A lightweight, fluent database migration wrapper for the Mitsuki framework, built on top of Phinx.

README 文档

README

Mitsuki Database Migrations is a lightweight, fluent schema builder for PHP. Built as a powerful wrapper around Phinx, it allows you to define your database structure using a clean, expressive syntax inspired by Laravel's Migration system.

✨ Features

  • Fluent API: Define tables and columns using clean method chaining.
  • Smart Migrations: Automatically detects if a table exists to choose between CREATE or ALTER.
  • Standardized Fields: Quick helpers for primary keys (id()) and tracking (timestamps()).
  • Relationship Helpers: Intelligent foreign key resolution with foreignIdFor().
  • Phinx Powered: Seamlessly integrates with your existing Phinx environments and commands.
  • Fully Tested: High-reliability codebase tested with Pest PHP and Mockery.

🚀 Installation & Setup

1. Install via Composer

composer require mitsuki/db-migrations

2. Initialize Phinx

Ensure your phinx.php is configured to use the Mitsuki template and environment variables.

🛠 Usage

1. Basic Table Creation

Use the Schema facade. It coordinates with the Phinx migration instance to execute your definitions.

use Mitsuki\Database\Schema\Schema;
use Mitsuki\Database\Table;
use Mitsuki\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    public function up(): void
    {
        Schema::create('users', function (Table $table) {
            $table->string('username', 100);
            $table->string('email')->nullable();
            $table->timestamps(); // Adds 'created_at' and 'updated_at'
        }, $this);
    }

    public function down(): void
    {
        $this->table('users')->drop()->save();
    }
}

2. 🔗 Foreign Keys & Relationships

The foreignIdFor() method simplifies relationship management by automatically guessing column and table names.

$table->foreignIdFor(\App\Models\User::class)
      ->constrained()
      ->onDelete('cascade');

💻 Console Commands

Mitsuki leverages the Phinx CLI. Here are the essential commands for your workflow:

Create a New Migration

Generate a new migration file using the Mitsuki stub:

vendor/bin/phinx create MyNewMigration

Run Migrations

Execute all pending migrations:

# Running in default environment (Testing/SQLite)
vendor/bin/phinx migrate

# Force a specific environment (Development/MySQL)
vendor/bin/phinx migrate -e development

Rollback

Undo the last migration:

vendor/bin/phinx rollback

Check Status

See the list of migrated and pending files:

vendor/bin/phinx status

⚙️ Configuration (phinx.php)

Mitsuki handles environment switching automatically based on your .env file:

Env Var Default Description
ENVIRONEMENT testing Switches between testing (SQLite) and development (MySQL).
DB_CONNECTION mysql The database driver to use in development.
DB_DATABASE mitsuki_db The name of your database or path to SQLite file.

🧠 Smart Save Logic

Mitsuki is designed to be safe. When you call save(), the library checks the database state:

  1. If the table doesn't exist: It executes a CREATE TABLE statement (with id => false to let the Blueprint manage the primary key).
  2. If the table exists: It automatically switches to ALTER TABLE to add your new columns without destroying existing data.

🧪 Testing

We take stability seriously. The library is fully covered by Pest PHP unit tests.

composer test

📄 License

The Mitsuki Database Migrations library is open-sourced software licensed under the MIT license.

**Developed with ❤️ by Zgeniuscoders**

mitsuki/mitsuki-db-migrations 适用场景与选型建议

mitsuki/mitsuki-db-migrations 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 03 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 mitsuki/mitsuki-db-migrations 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-09