How to do migration when index added #2766
-
Hello, I've added an index to a table using the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can create the index separately in the migration. Drift will generate a getter in the database class for indices added to tables based on the name in the onUpgrade: (m, from, to) async {
if (...) {
await m.addColumn(table, table.newColumn);
await m.create(tableIndex);
}
} There's been a bug fixed in drift_dev 2.14.0 causing the getter to not be added in some cases - if you don't have it in your database, please try upgrading. |
Beta Was this translation helpful? Give feedback.
You can create the index separately in the migration. Drift will generate a getter in the database class for indices added to tables based on the name in the
TableIndex
annotation. So you can doThere's been a bug fixed in drift_dev 2.14.0 causing the getter to not be added in some cases - if you don't have it in your database, please try upgrading.