First stable version of DB Migration package was realeased.
It allows you to manage database schema using migrations.
Supports the following databases out of the box:
- MSSQL of versions 2017, 2019, 2022.
- MySQL of versions 5.7ā8.0.
- MariaDB of versions 10.4ā10.9.
- Oracle of versions 12cā21c.
- PostgreSQL of versions 9.6ā15.
- SQLite of version 3.3 and above.
You can use it in Yii applications, Symfony console or as a standalone utility.
Migrations itself are written with IDE-friendly query builder:
<?php
declare(strict_types=1);
namespace App\Migrations;
use Yiisoft\Db\Migration\MigrationBuilder;
use Yiisoft\Db\Migration\RevertibleMigrationInterface;
final class M231219204516Test implements RevertibleMigrationInterface
{
public function up(MigrationBuilder $b): void
{
$b->createTable('test', [
'id' => $b->primaryKey(),
'name' => $b->string(255)->notNull(),
'email' => $b->string(255)->notNull(),
'status' => $b->integer()->notNull()->defaultValue(10),
'created_at' => $b->dateTime()->notNull(),
'updated_at' => $b->dateTime()->notNull(),
]);
}
public function down(MigrationBuilder $b): void
{
$b->dropTable('test');
}
}