dart-backend / angel

A polished, production-ready backend framework in Dart for the VM, AOT, and Flutter.
https://github.com/dukefirehawk/angel
BSD 3-Clause "New" or "Revised" License
173 stars 21 forks source link

add a way to change indexes with migrations without alter table #148

Closed Garthi closed 1 month ago

Garthi commented 1 month ago

hi, here is a index update for the migrations working for MySQL, MariaDB, and PostgreSQL

the methods for the index migration is addIndex, dropIndex, and dropPrimaryIndex

here is a example

class UserTodoMigration5 extends Migration {
  @override
  void up(Schema schema) {
    schema.indexes('user_todo', (table) {
      table.dropIndex('user_id_index');
    });
  }

  @override
  void down(Schema schema) {
    schema.indexes('user_todo', (table) {
      table.addIndex('user_id_index', ['user_id'], IndexType.standardIndex);
    });
  }
}