rhubarbphp / scaffold-database-migrations
A stem implementation of Module.Migrations for database migrations
Installs: 4 193
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 15
Forks: 0
Open Issues: 1
Requires
Requires (Dev)
- codeception/codeception: 2.3.*
- codeception/verify: ^1.0
- phpunit/phpunit: ^6.5
- rhubarbphp/module-migrations: *
This package is auto-updated.
Last update: 2024-12-11 15:49:11 UTC
README
This scaffold is a stem-specific implementation of the Migrations module. It includes:
DatabaseMigrationsStateProvider
which stores the local state of your application using Stem.
DataMigrationScript
an implementation of MigrationScriptInterface with additional helper methods to perform common data migrations.
Registering your script
Scripts will not be ran unless they are registered. Scripts can be registered by calling registerMigrationScripts($scriptsArray)
on MigrationsModule.
MigrationsManager::getMigrationsManager()->registerMigrationScripts([ SplitNameColumnScript::class, DeleteAllImagesScript::class, UpdatedGdprInfoScript::class ]);
Data Migration Scripts
DataMigrationScripts implement MigrationsScriptInterface and includes common migration types that can be called during execution of your script.
class ContactNameSplitting extends DataMigrationScript { public function execute() { foreach (Image::all(new Equals('active', false)) as $image) { unlink($image->filePath); $image->delete(); } try { $this->updateEnumOption( User::class, 'status', 'on line', 'online' ); } catch (\Rhubarb\Crown\Exceptions\ImplementationException $e) { } } public function version(): int { return 18; } public function priority(): int { return 10; } }