Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8949e309 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

Merge branch '3001-main-migration' into 'main'

Sync all notes due to outage

See merge request !63
parents fb43d2b0 882ed60f
Loading
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
/*
 * 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 <https://www.gnu.org/licenses/>.
 */

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()
        )
    }
}
+4 −2
Original line number Diff line number Diff line
@@ -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()