1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-24 08:44:26 +00:00

Added account indices

This commit is contained in:
M66B 2021-10-04 10:29:23 +02:00
parent edfed0274b
commit b39d2fa147
4 changed files with 2620 additions and 2 deletions

File diff suppressed because it is too large Load diff

View file

@ -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) {

View file

@ -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 {

View file

@ -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;