berlindb / core

All of the required core code
MIT License
253 stars 27 forks source link

Support database table rollbacks #40

Open ashleyfae opened 4 years ago

ashleyfae commented 4 years ago

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.

JJJ commented 4 years ago

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!

alexstandiford commented 4 years ago

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.

ashleyfae commented 4 years ago

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() {}
}
JJJ commented 3 years ago

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

ashleyfae commented 3 years ago

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.

Mte90 commented 2 years ago

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