Download the PHP package mitsuki/mitsuki-db-migrations without Composer
On this page you can find all versions of the php package mitsuki/mitsuki-db-migrations. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mitsuki/mitsuki-db-migrations
More information about mitsuki/mitsuki-db-migrations
Files in mitsuki/mitsuki-db-migrations
Package mitsuki-db-migrations
Short Description A lightweight, fluent database migration wrapper for the Mitsuki framework, built on top of Phinx.
License MIT
Informations about the package mitsuki-db-migrations
Mitsuki Database Migrations
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
CREATEorALTER. - 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
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.
2. ๐ Foreign Keys & Relationships
The foreignIdFor() method simplifies relationship management by automatically guessing column and table names.
๐ป 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:
Run Migrations
Execute all pending migrations:
Rollback
Undo the last migration:
Check Status
See the list of migrated and pending files:
โ๏ธ 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:
- If the table doesn't exist: It executes a
CREATE TABLEstatement (withid => falseto let the Blueprint manage the primary key). - If the table exists: It automatically switches to
ALTER TABLEto add your new columns without destroying existing data.
๐งช Testing
We take stability seriously. The library is fully covered by Pest PHP unit tests.
๐ License
The Mitsuki Database Migrations library is open-sourced software licensed under the MIT license.
Developed with โค๏ธ by [Zgeniuscoders](mailto:[email protected])