Search by

tereta / application-migration

tereta

The migration package for the tereta/application framework.It applies database migrations of the application modules and dumps and restores table data with the database:migration, database:data:dump and database:data:restore console commands.

Package info

gitlab.com/tereta/application/migration

Homepage

Issues

pkg:composer/tereta/application-migration

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

0.0.1 2026-10-18 21:29 UTC

This package is not auto-updated.

Last update: 2026-10-18 18:30:28 UTC


README

🌐 English | Русский | Π£ΠΊΡ€Π°Ρ—Π½ΡΡŒΠΊΠ°

The migration package for the tereta/application framework. It applies database migrations of the application modules, and dumps and restores table data. The package adds three console commands:

  • database:migration - apply the migrations of the modules;
  • database:data:dump - dump the data of the module tables to files;
  • database:data:restore - restore the data of the tables from files.

Installation

composer require tereta/application-migration

Usage

Prepare a module

A module tells the package where its files are:

  • getDatabaseMigrations() from the Migration interface returns the list of migration files (.sql or .php);
  • getDatabaseData() from the Schema interface returns the data files, the key is the table name.
use Tereta\Application\Interfaces\Schema;
use Tereta\ApplicationMigration\Interfaces\Migration;

class Module implements Migration, Schema
{
    public static function getDatabaseMigrations(): array
    {
        return [
            __DIR__ . '/../resources/database/migration/001_create_book.sql',
        ];
    }

    public static function getDatabaseSchemas(): array
    {
        return [];
    }

    public static function getDatabaseData(): array
    {
        return [
            'book' => __DIR__ . '/../resources/database/data/book.xml',
        ];
    }
}

Run the commands

Each migration is applied only once. Dump writes the data of every table to its file, restore loads it back.

php bin/console.php database:migration
php bin/console.php database:data:dump
php bin/console.php database:data:restore

License

Apache License 2.0. See the LICENSE file.