tereta / application-migration
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.
Requires
- php: >=8.2
- psr/cache: ^3.0
- psr/log: ^3.0
- tereta/application: @dev
- tereta/console: @dev
- tereta/migration: @dev
- tereta/orm: @dev
Requires (Dev)
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^11.0
- squizlabs/php_codesniffer: ^3.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
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 theMigrationinterface returns the list of migration files (.sqlor.php);getDatabaseData()from theSchemainterface 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.