-
Hi, we have tables generated by Drift. But now we want to index some columns for faster DB queries. |
Beta Was this translation helpful? Give feedback.
Answered by
simolus3
Sep 9, 2022
Replies: 1 comment
-
Hi, at the moment this is not directly possible with a high-level Dart API. You can write the @override
List<DatabaseSchemaEntity> get allSchemaEntities => [
...super.allSchemaEntities,
_myIndex,
];
final Index _myIndex =
Index('my_index', 'CREATE INDEX my_index ON foo (bar, baz)');
Added like this, the index will be created automatically when the database is created. You can also create it manually with |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
TinhHuynh
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, at the moment this is not directly possible with a high-level Dart API. You can write the
CREATE INDEX
statement manually and add it to your database like this:Added like this, the index will be created automatically when the database is created. You can also create it manually with
migrator.create(_myIndex)
in a schema migration.