Added account indices

pull/206/head
M66B 3 years ago
parent edfed0274b
commit b39d2fa147

File diff suppressed because it is too large Load Diff

@ -68,7 +68,7 @@ import io.requery.android.database.sqlite.SQLiteDatabase;
// https://developer.android.com/topic/libraries/architecture/room.html // https://developer.android.com/topic/libraries/architecture/room.html
@Database( @Database(
version = 213, version = 214,
entities = { entities = {
EntityIdentity.class, EntityIdentity.class,
EntityAccount.class, EntityAccount.class,
@ -2175,6 +2175,15 @@ public abstract class DB extends RoomDatabase {
Log.i("DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `account` ADD COLUMN `category` TEXT"); db.execSQL("ALTER TABLE `account` ADD COLUMN `category` TEXT");
} }
}).addMigrations(new Migration(213, 214) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("CREATE INDEX `index_account_synchronize` ON `account` (`synchronize`)");
db.execSQL("CREATE INDEX `index_account_category` ON `account` (`category`)");
db.execSQL("DROP VIEW `account_view`");
db.execSQL("CREATE VIEW IF NOT EXISTS `account_view` AS " + TupleAccountView.query);
}
}).addMigrations(new Migration(998, 999) { }).addMigrations(new Migration(998, 999) {
@Override @Override
public void migrate(@NonNull SupportSQLiteDatabase db) { public void migrate(@NonNull SupportSQLiteDatabase db) {

@ -32,6 +32,7 @@ import androidx.annotation.RequiresApi;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
import androidx.room.ColumnInfo; import androidx.room.ColumnInfo;
import androidx.room.Entity; import androidx.room.Entity;
import androidx.room.Index;
import androidx.room.PrimaryKey; import androidx.room.PrimaryKey;
import org.json.JSONException; import org.json.JSONException;
@ -47,6 +48,8 @@ import java.util.UUID;
@Entity( @Entity(
tableName = EntityAccount.TABLE_NAME, tableName = EntityAccount.TABLE_NAME,
indices = { indices = {
@Index(value = {"synchronize"}),
@Index(value = {"category"})
} }
) )
public class EntityAccount extends EntityOrder implements Serializable { public class EntityAccount extends EntityOrder implements Serializable {

@ -31,7 +31,7 @@ import java.util.Objects;
value = TupleAccountView.query value = TupleAccountView.query
) )
public class TupleAccountView { public class TupleAccountView {
static final String query = "SELECT id, pop, name, color, synchronize, notify, leave_deleted, auto_seen, created FROM account"; static final String query = "SELECT id, pop, name, category, color, synchronize, notify, leave_deleted, auto_seen, created FROM account";
@NonNull @NonNull
public Long id; public Long id;
@ -39,6 +39,7 @@ public class TupleAccountView {
@ColumnInfo(name = "pop") @ColumnInfo(name = "pop")
public Integer protocol; public Integer protocol;
public String name; public String name;
public String category;
public Integer color; public Integer color;
@NonNull @NonNull
public Boolean synchronize; public Boolean synchronize;

Loading…
Cancel
Save