MCPcopy Create free account
hub / github.com/M66B/FairEmail / migrate

Method migrate

app/src/main/java/eu/faircode/email/DB.java:773–3148  ·  view source on GitHub ↗
(final Context context, RoomDatabase.Builder<DB> builder)

Source from the content-addressed store, hash-verified

771 }
772
773 private static RoomDatabase.Builder<DB> migrate(final Context context, RoomDatabase.Builder<DB> builder) {
774 // https://www.sqlite.org/lang_altertable.html
775 return builder
776 .addMigrations(new Migration(1, 2) {
777 @Override
778 public void migrate(@NonNull SupportSQLiteDatabase db) {
779 logMigration(startVersion, endVersion);
780 db.execSQL("ALTER TABLE `folder` RENAME COLUMN `after` TO `sync_days`");
781 db.execSQL("ALTER TABLE `folder` ADD COLUMN `keep_days` INTEGER NOT NULL DEFAULT 30");
782 db.execSQL("UPDATE `folder` SET keep_days = sync_days");
783 }
784 })
785 .addMigrations(new Migration(2, 3) {
786 @Override
787 public void migrate(@NonNull SupportSQLiteDatabase db) {
788 logMigration(startVersion, endVersion);
789 db.execSQL("ALTER TABLE `identity` ADD COLUMN `signature` TEXT");
790 db.execSQL("UPDATE `identity` SET signature =" +
791 " (SELECT account.signature FROM account WHERE account.id = identity.account)");
792 }
793 })
794 .addMigrations(new Migration(3, 4) {
795 @Override
796 public void migrate(@NonNull SupportSQLiteDatabase db) {
797 logMigration(startVersion, endVersion);
798 db.execSQL("ALTER TABLE `message` ADD COLUMN `forwarding` INTEGER" +
799 " REFERENCES `message`(`id`) ON UPDATE NO ACTION ON DELETE SET NULL");
800 db.execSQL("CREATE INDEX `index_message_forwarding` ON `message` (`forwarding`)");
801 }
802 })
803 .addMigrations(new Migration(4, 5) {
804 @Override
805 public void migrate(@NonNull SupportSQLiteDatabase db) {
806 logMigration(startVersion, endVersion);
807 db.execSQL("ALTER TABLE `account` ADD COLUMN `last_connected` INTEGER");
808 db.execSQL("ALTER TABLE `message` ADD COLUMN `last_attempt` INTEGER");
809 }
810 })
811 .addMigrations(new Migration(5, 6) {
812 @Override
813 public void migrate(@NonNull SupportSQLiteDatabase db) {
814 logMigration(startVersion, endVersion);
815 db.execSQL("ALTER TABLE `account` ADD COLUMN `notify` INTEGER NOT NULL DEFAULT 0");
816 }
817 })
818 .addMigrations(new Migration(6, 7) {
819 @Override
820 public void migrate(@NonNull SupportSQLiteDatabase db) {
821 logMigration(startVersion, endVersion);
822 db.execSQL("ALTER TABLE `message` ADD COLUMN `answered` INTEGER NOT NULL DEFAULT 0");
823 db.execSQL("ALTER TABLE `message` ADD COLUMN `ui_answered` INTEGER NOT NULL DEFAULT 0");
824 }
825 })
826 .addMigrations(new Migration(7, 8) {
827 @Override
828 public void migrate(@NonNull SupportSQLiteDatabase db) {
829 logMigration(startVersion, endVersion);
830 db.execSQL("ALTER TABLE `message` ADD COLUMN `keywords` TEXT");

Callers 1

getInstanceMethod · 0.95

Calls 15

logMigrationMethod · 0.95
decodeAddressesMethod · 0.95
getSortKeyMethod · 0.95
eMethod · 0.95
ensureExistsMethod · 0.95
sanitizeFilenameMethod · 0.95
iMethod · 0.95
secureDeleteMethod · 0.95
isPlayStoreInstallMethod · 0.95
dropTriggersMethod · 0.95
convertMethod · 0.95
deleteMethod · 0.95

Tested by

no test coverage detected