core icon indicating copy to clipboard operation
core copied to clipboard

Support database table rollbacks

Open ashleyfae opened this issue 5 years ago • 6 comments

It would be cool to support rollbacks, kind of like Laravel does. For each table upgrade, you'd also write a rollback so you can go forward and go backwards to revert it.

ashleyfae avatar Apr 28 '20 06:04 ashleyfae

I agree, this would be pretty awesome.

I hadn't built the Table class with rollbacks in mind, so it may take a bit of effort and rethinking things to make it happen. That shouldn't stop us, though!

JJJ avatar May 03 '20 15:05 JJJ

I wonder if an update would be best served as a class that is extended and instantiated? This would allow us to make abstract functions for both upgrading,and downgrading.

alexstandiford avatar May 04 '20 15:05 alexstandiford

I wonder if an update would be best served as a class that is extended and instantiated? This would allow us to make abstract functions for both upgrading,and downgrading.

IIRC that's how Laravel does it.

class YourMigrationClass extends Migration {
    /**
     * Run the migration
     */
    public function up() {}

    /**
     * Reverse the migration
     */
    public function down() {}
}

ashleyfae avatar May 04 '20 15:05 ashleyfae

See: https://laravel.com/docs/8.x/migrations

JJJ avatar May 05 '21 01:05 JJJ

Also see: https://make.wordpress.org/core/2021/05/03/feature-project-updates-on-updating-the-updaters/

Specifically outcomes 2 and 3. It talks about database migrations and rollbacks.

ashleyfae avatar May 05 '21 09:05 ashleyfae

There are some updates about it? I see that some plugin that use berlindb have something for that

Mte90 avatar Jul 06 '22 17:07 Mte90