-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
It was detected a case when down-migration was generated with wrong operations order.
It is actual for case when it is used named index.
For example we have named index item_resource_some_index with 2 fields and we want to add one more field for index - deleted_at.
Base entity:
/**
* @Cycle\Entity(
* table="item_resource",
* repository="App\Repository\ItemResourceRepository"
* )
*
* @Cycle\Table(
* indexes={
* @Cycle\Table\Index(
* columns={"resource_id", "item_uuid"},
* unique=true,
* name="item_resource_some_index"
* )
* }
* )
*/
class ItemResource
{
/**
* @Cycle\Relation\BelongsTo(target=Item::class, innerKey="item_uuid")
*/
public Item $item;
/**
* @Cycle\Relation\BelongsTo(target=ResourceEntity::class, innerKey="resource_id")
*/
public ResourceEntity $resource;
...
}When we add 3rd field and run cycle:migrate we will receive:
class ModifyNodeEstimateIndexMigration extends Migration
{
public function up(): void
{
$this->table('item_resource')
->addIndex(
["resource_id", "item_uuid", "deleted_at"],
[
'name' => 'item_resource_some_index',
'unique' => true
]
)
->dropIndex(["resource_id", "item_uuid"])
->update();
}
public function down(): void
{
$this->table('item_resource')
->addIndex(
["resource_id", "item_uuid"],
[
'name' => 'item_resource_some_index',
'unique' => true
]
)
->dropIndex(["resource_id", "item_uuid", "deleted_at"])
->update();
}
}On down migration new index can't be created while old same-named index exists
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Backlog