@Index
Has anyone gotten the @Index annotation to work? I've tried it every which way with no luck. It'll compile and creates an IndexProperty in the associated *_Table class, but the sqlite database has no index.
I have gotten @Unique to work though.
So here's my table
@ModelContainer
@Table(database = Database.class, name = TrackLocation.TABLE_NAME,indexGroups = {@IndexGroup(number = 1,name = "trackLocations")})
public class TrackLocation extends BaseTable implements Parcelable {
public static final String TABLE_NAME = "track_locations";
@NotNull
@Index(indexGroups = 1)
@ForeignKey(
tableClass = Track.class,
onDelete = ForeignKeyAction.CASCADE,
references = {@ForeignKeyReference(
columnName = "track_id",
foreignKeyColumnName = _ID,
referencedFieldIsPackagePrivate = true,
columnType = Long.class)})
protected long track_id;
And the generated _Table class has the index property:
public static final IndexProperty<TrackLocation> index_trackLocations = new IndexProperty<>("trackLocations", false, TrackLocation.class, track_id);
But no index is actually created. When I pull the database off the device and look at it, there is no index. Seems to me indexing is completely broken.
create an IndexMigration on version 0 that will activate it.
Thanks for the reply. I hope you'll consider changing this. If I add an the annotations to an existing table class, I would expect to have to do a migration to add the new index. But on a newly created table class with the annotations in place, I'd expect the indexes to get created with the table. Also this appears to be how unique indexing currently works.
https://github.com/Raizlabs/DBFlow/blob/develop/usage2/Indexing.md :)