-
-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Labels
type:enhancementEnhancementEnhancement
Description
Proposed new feature or change
Why
It should be as easy as possible to write and read migrations. Current syntax could be optimized.
Current syntax
<?php
declare(strict_types=1);
namespace App\Migration;
use Yiisoft\Db\Migration\MigrationBuilder;
use Yiisoft\Db\Migration\RevertibleMigrationInterface;
final class M251225221906CreateNewsTable implements RevertibleMigrationInterface
{
public function up(MigrationBuilder $b): void
{
$cb = $b->columnBuilder();
$b->createTable('news', [
'id' => $cb::uuidPrimaryKey(),
'title' => $cb::string()->notNull(),
'content' => $cb::text(),
]);
}
public function down(MigrationBuilder $b): void
{
$b->dropTable('news');
}
}Proposal
- Pass column builder as argument so there's no need to call
$cb = $b->columnBuilder(); - Better naming.
<?php
declare(strict_types=1);
namespace App\Migration;
use Yiisoft\Db\Migration\MigrationBuilder;
use Yiisoft\Db\Migration\RevertibleMigrationInterface;
final class M251225221906CreateNewsTable implements RevertibleMigrationInterface
{
public function up(MigrationBuilder $build, string $type): void
{
$build->createTable('news', [
'id' => $type::uuidPrimaryKey(),
'title' => $type::string()->notNull(),
'content' => $type::text(),
]);
}
public function down(MigrationBuilder $build): void
{
$build->dropTable('news');
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type:enhancementEnhancementEnhancement