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

Migration_7_8.java « migration « persistence « notes « owncloud « niedermann « it « java « main « src « app - github.com/stefan-niedermann/nextcloud-notes.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d1fd40c0998b49a1f965a061be663adfa5e02c5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package it.niedermann.owncloud.notes.persistence.migration;

import android.database.sqlite.SQLiteDatabase;

import androidx.annotation.NonNull;

import it.niedermann.owncloud.notes.shared.util.DatabaseIndexUtil;

public class Migration_7_8 {
    public Migration_7_8(@NonNull SQLiteDatabase db) {
        final String table_temp = "NOTES_TEMP";
        db.execSQL("CREATE TABLE " + table_temp + " ( " +
                "ID INTEGER PRIMARY KEY AUTOINCREMENT, " +
                "REMOTEID INTEGER, " +
                "STATUS VARCHAR(50), " +
                "TITLE TEXT, " +
                "MODIFIED INTEGER DEFAULT 0, " +
                "CONTENT TEXT, " +
                "FAVORITE INTEGER DEFAULT 0, " +
                "CATEGORY TEXT NOT NULL DEFAULT '', " +
                "ETAG TEXT)");
        DatabaseIndexUtil.createIndex(db, table_temp, "REMOTEID", "STATUS", "FAVORITE", "CATEGORY", "MODIFIED");
        db.execSQL(String.format("INSERT INTO %s(%s,%s,%s,%s,%s,%s,%s,%s,%s) ", table_temp, "ID", "REMOTEID", "STATUS", "TITLE", "MODIFIED", "CONTENT", "FAVORITE", "CATEGORY", "ETAG")
                + String.format("SELECT %s,%s,%s,%s,strftime('%%s',%s),%s,%s,%s,%s FROM %s", "ID", "REMOTEID", "STATUS", "TITLE", "MODIFIED", "CONTENT", "FAVORITE", "CATEGORY", "ETAG", "NOTES"));
        db.execSQL("DROP TABLE NOTES");
        db.execSQL(String.format("ALTER TABLE %s RENAME TO %s", table_temp, "NOTES"));
    }
}