Given this table:
class TodoCategories extends Table {
IntColumn get age => integer()();
TextColumn get name => text()();
}
how can I add an index to the name column? I see from the documentation there is an Index class, but I'm not clear how to use it.
I found a comment in the source code (
index.dart) stating that indexes can be created only in.driftfiles. In my case, I had to move all of the sql into.driftfiles to get it to work. There is no mention in the documentation of whether it is possible to create Drift tables in both the dart files and the .drift files, but when I tried it, it failed silently.So to answer the question, create a file like
In the dart source: