Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-notes.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_9_10.java')
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_9_10.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_9_10.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_9_10.java
new file mode 100644
index 00000000..98ddc601
--- /dev/null
+++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_9_10.java
@@ -0,0 +1,26 @@
+package it.niedermann.owncloud.notes.persistence.migration;
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+
+import androidx.annotation.NonNull;
+
+import it.niedermann.owncloud.notes.util.NoteUtil;
+
+public class Migration_9_10 {
+ /**
+ * Adds a column to store excerpt instead of regenerating it each time
+ * https://github.com/stefan-niedermann/nextcloud-notes/issues/528
+ */
+ public Migration_9_10(@NonNull SQLiteDatabase db) {
+ db.execSQL("ALTER TABLE NOTES ADD COLUMN EXCERPT INTEGER NOT NULL DEFAULT ''");
+ Cursor cursor = db.query("NOTES", new String[]{"ID", "CONTENT"}, null, null, null, null, null, null);
+ while (cursor.moveToNext()) {
+ ContentValues values = new ContentValues();
+ values.put("EXCERPT", NoteUtil.generateNoteExcerpt(cursor.getString(1)));
+ db.update("NOTES", values, "ID" + " = ? ", new String[]{cursor.getString(0)});
+ }
+ cursor.close();
+ }
+}