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
@Database(
version = 213,
version = 214,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -2175,6 +2175,15 @@ public abstract class DB extends RoomDatabase {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
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) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {

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

@ -31,7 +31,7 @@ import java.util.Objects;
value = TupleAccountView.query
)
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
public Long id;
@ -39,6 +39,7 @@ public class TupleAccountView {
@ColumnInfo(name = "pop")
public Integer protocol;
public String name;
public String category;
public Integer color;
@NonNull
public Boolean synchronize;

Loading…
Cancel
Save