yiisoft / yiisoft/db-migration
Possible syntax improvements
Open
Nobody has claimed this yet.
type:enhancement
- Dominant language
- PHP
- Stars
- 32
- Forks
- 18
- Avg merge
- 22h 18m
- Merged PRs (30d)
- 2
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');
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the current and proposed migration examples, then trace MigrationBuilder, columnBuilder(), and RevertibleMigrationInterface. Clarify the intended parameter and naming changes, inspect existing migration-related tests, and consider the work done when the revised syntax is consistently supported for both up() and down() migrations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100