cakephp / cakephp/phinx

Reference a migration from other

Open
#1,638 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
PHP
Stars
4.5k
Forks
884
PR merge metrics
No merged PRs in 30d

Description

Use case:

Migration A: xxxxx_create_table_orders.php
Many migrations and months later
Migration Z: xxxxx_drop_table_orders.php

To make migration Z reversible, I need to implement up and down methods.

The up have a drop() call, so, on down I need a create() counterpart, with all my schema.

Suggestion

If we have one method to call from down witch run the migration A::up (or change) would be great. Something like:

public function down() {
    $this->use('create_table_orders');
}

I know there are limitations: if you have changed anything into table between the two migrations, that will be loose. But I think that can be advertised on docs.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the migration A and migration Z scenario in the issue, then review how the up and down methods currently run. Determine whether a down migration can safely reference another migration's up or change operation, including the stated limitation around later schema changes. Done means the behavior, limitations, and documentation expectations are defined clearly enough to implement and test.

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
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.