aliengen / pachyderm-migration
A migration tool for Pachyderm SQL database
Requires
- php: >=8.4
- aliengen/pachyderm: dev-master
This package is auto-updated.
Last update: 2025-08-26 08:03:05 UTC
README
A simple and reliable SQL database migration tool for Pachyderm applications. Manage your database schema changes through SQL files with automatic tracking and ordered execution.
β¨ Features
- π Automatic Tracking: Tracks executed migrations automatically
- π SQL File-based: Simple SQL files for your migrations
- π Ordered Execution: Runs migrations in alphabetical order
- π‘οΈ Safe: Prevents duplicate execution
- β‘ Zero Config: Works out of the box
- π€ Easy Setup: Simple command to set up the migration structure
π Requirements
- PHP: 8.4 or higher
- Pachyderm: Latest version
- Composer: For dependency management
π Quick Start
Installation
composer require aliengen/pachyderm-migration
Setup
After installation, run the setup command to create the necessary files:
./vendor/bin/pachyderm-migration --setup
This will automatically create:
database/migrations/
folder for your SQL filesmigration.php
file for easy execution
Basic Usage
- Create a migration by adding a SQL file to
database/migrations/
:
-- database/migrations/001_create_users_table.sql CREATE TABLE users ( id INT AUTO_INCREMENT PRIMARY KEY, username VARCHAR(255) NOT NULL UNIQUE, email VARCHAR(255) NOT NULL UNIQUE, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP );
- Run migrations using any of these methods:
# Option 1: Using the generated migration.php file php migration.php # Option 2: Using the vendor binary directly ./vendor/bin/pachyderm-migration # Option 3: Using composer run composer run pachyderm-migration
That's it! Your migration will be executed and tracked automatically.
π Usage
Run all pending migrations using any of these methods:
# Using the generated file php migration.php # Using the vendor binary ./vendor/bin/pachyderm-migration # Using composer composer run pachyderm-migration
π Project Structure
your-project/
βββ database/
β βββ migrations/ # Your SQL migration files
β βββ 001_create_users.sql
β βββ 002_create_posts.sql
β βββ 003_add_indexes.sql
βββ vendor/ # Composer dependencies
βββ migration.php # Migration execution script
βββ composer.json
π§ Configuration
Database Connection
Ensure your Pachyderm config.php
file includes the necessary database configuration. The migration tool will use Pachyderm's database service to connect to your database.
Example of the database
service declaration in the config.php
file:
Service::set('database', function () { return Db::getInstance(); });
π€ Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Support
- Issues: GitHub Issues
Made with β€οΈ by the AlienGen team