From 882ed60f3546c5b26e148ec65ebd90f1dca2eecd Mon Sep 17 00:00:00 2001 From: althafvly Date: Tue, 18 Feb 2025 19:32:58 +0530 Subject: [PATCH] notes: Sync all notes due to outage --- .../e/notes/migration/Migration_23_24.kt | 38 +++++++++++++++++++ .../notes/persistence/NotesDatabase.java | 6 ++- 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/foundation/e/notes/migration/Migration_23_24.kt diff --git a/app/src/main/java/foundation/e/notes/migration/Migration_23_24.kt b/app/src/main/java/foundation/e/notes/migration/Migration_23_24.kt new file mode 100644 index 000000000..9cb085b69 --- /dev/null +++ b/app/src/main/java/foundation/e/notes/migration/Migration_23_24.kt @@ -0,0 +1,38 @@ +/* + * Copyright e Foundation 2025 + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package foundation.e.notes.migration + +import androidx.room.migration.Migration +import androidx.sqlite.db.SupportSQLiteDatabase + +class Migration_23_24 : Migration(23, 24) { + override fun migrate(db: SupportSQLiteDatabase) { + db.execSQL( + """ + UPDATE `Note` + SET status = 'LOCAL_EDITED' + WHERE (status IS NULL OR status = '') + AND accountId IN ( + SELECT id FROM `Account` + WHERE userName != 'Local' + AND url IS NOT NULL + AND url != '' + ); + """.trimIndent() + ) + } +} diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java index db7d7ded5..3072aa1bd 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java @@ -11,6 +11,7 @@ import androidx.sqlite.db.SupportSQLiteDatabase; import java.util.List; +import foundation.e.notes.migration.Migration_23_24; import it.niedermann.owncloud.notes.persistence.dao.AccountDao; import it.niedermann.owncloud.notes.persistence.dao.CategoryOptionsDao; import it.niedermann.owncloud.notes.persistence.dao.NoteDao; @@ -45,7 +46,7 @@ import trikita.log.Log; CategoryOptions.class, SingleNoteWidgetData.class, NotesListWidgetData.class - }, version = 23 + }, version = 24 ) @TypeConverters({Converters.class}) public abstract class NotesDatabase extends RoomDatabase { @@ -80,7 +81,8 @@ public abstract class NotesDatabase extends RoomDatabase { new Migration_19_20(context), new Migration_20_21(), new Migration_21_22(context), - new Migration_22_23() + new Migration_22_23(), + new Migration_23_24() ) .fallbackToDestructiveMigrationOnDowngrade() .fallbackToDestructiveMigration() -- GitLab