PHP code example of meritum / migrations

1. Go to this page and download the library: Download meritum/migrations library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

meritum / migrations example snippets




use Georgeff\Schema\Blueprint;
use Meritum\Migrations\SchemaInterface;
use Meritum\Migrations\MigrationInterface;

return new class implements MigrationInterface {

    public function up(SchemaInterface $schema): void
    {
        $schema->create('users', function (Blueprint $blueprint) {
            $blueprint->uuid()->unique()->primary();
            $blueprint->string('name');
            $blueprint->string('email')->unique();
            $blueprint->timestamps();
        });
    }

    public function down(SchemaInterface $schema): void
    {
        $schema->dropIfExists('users');
    }
};

use Meritum\Migrations\Factory\KernelBuilder;

$kernel = KernelBuilder::build(environment: 'production');
$kernel->boot();
$kernel->run();

use Georgeff\Kernel\ServiceRegistrar;
use Meritum\Migrations\Factory\KernelBuilder;

$registrar = new ServiceRegistrar();
$registrar->register(new MyCustomModule());

$kernel = KernelBuilder::build(registrar: $registrar);
$kernel->boot();
$kernel->run();

 -------------------------------------------- ------- ---------------------
  Migration                                    Batch   Migrated At
 -------------------------------------------- ------- ---------------------
  2026_06_01_000000_create_users_table.php     1       2026-06-01 10:00:00
  2026_06_10_000000_create_posts_table.php     2       2026-06-10 14:30:00
  2026_06_15_000000_add_email_to_users.php
 -------------------------------------------- ------- ---------------------