From e5e182761ed599f420ee27f8fd623de9d3e9e3c1 Mon Sep 17 00:00:00 2001 From: aminecmi Date: Wed, 28 Dec 2022 15:27:17 +0100 Subject: [PATCH 1/2] Running migrations. --- .../bou/amine/apps/readerforselfossv2/android/MyApp.kt | 7 ++----- .../apps/readerforselfossv2/repository/RepositoryImpl.kt | 4 ++++ .../sqldelight/bou/amine/apps/readerforselfossv2/dao/1.sqm | 7 ++++++- .../sqldelight/bou/amine/apps/readerforselfossv2/dao/2.sqm | 6 ------ 4 files changed, 12 insertions(+), 12 deletions(-) delete mode 100644 shared/src/commonMain/sqldelight/bou/amine/apps/readerforselfossv2/dao/2.sqm diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/MyApp.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/MyApp.kt index 074a5c6..266f2e5 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/MyApp.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/MyApp.kt @@ -3,10 +3,7 @@ package bou.amine.apps.readerforselfossv2.android import android.app.NotificationChannel import android.app.NotificationManager import android.content.Context -import android.graphics.drawable.Drawable -import android.net.Uri import android.os.Build -import android.widget.ImageView import android.widget.Toast import androidx.lifecycle.DefaultLifecycleObserver import androidx.lifecycle.LifecycleOwner @@ -18,8 +15,6 @@ import bou.amine.apps.readerforselfossv2.dao.DriverFactory import bou.amine.apps.readerforselfossv2.dao.ReaderForSelfossDB import bou.amine.apps.readerforselfossv2.repository.Repository import bou.amine.apps.readerforselfossv2.service.AppSettingsService -import com.bumptech.glide.Glide -import com.bumptech.glide.request.RequestOptions import com.github.ln_12.library.ConnectivityStatus import io.github.aakira.napier.DebugAntilog import io.github.aakira.napier.Napier @@ -83,6 +78,8 @@ class MyApp : MultiDexApplication(), DIAware { } } } + + repository.migrate(driverFactory) } override fun attachBaseContext(base: Context?) { diff --git a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt index 26d1733..9270167 100644 --- a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt +++ b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt @@ -576,4 +576,8 @@ class Repository( fun getReaderItems(): ArrayList { return _readerItems } + + fun migrate(driverFactory: DriverFactory) { + ReaderForSelfossDB.Schema.migrate(driverFactory.createDriver(), 0, 1) + } } \ No newline at end of file diff --git a/shared/src/commonMain/sqldelight/bou/amine/apps/readerforselfossv2/dao/1.sqm b/shared/src/commonMain/sqldelight/bou/amine/apps/readerforselfossv2/dao/1.sqm index 6f9532c..bc2dc04 100644 --- a/shared/src/commonMain/sqldelight/bou/amine/apps/readerforselfossv2/dao/1.sqm +++ b/shared/src/commonMain/sqldelight/bou/amine/apps/readerforselfossv2/dao/1.sqm @@ -1 +1,6 @@ -ALTER TABLE ITEM ADD COLUMN `author` TEXT NOT NULL; \ No newline at end of file +CREATE TABLE ITEM_BACKUP AS SELECT `id`, `datetime`, `title`, `content`, + `unread`, `starred`, `thumbnail`, `icon`, `link`, `sourcetitle`, + `tags` FROM ITEM; +ALTER TABLE ITEM_BACKUP ADD COLUMN `author` TEXT; +DROP TABLE ITEM; +ALTER TABLE ITEM_BACKUP RENAME TO ITEM; \ No newline at end of file diff --git a/shared/src/commonMain/sqldelight/bou/amine/apps/readerforselfossv2/dao/2.sqm b/shared/src/commonMain/sqldelight/bou/amine/apps/readerforselfossv2/dao/2.sqm deleted file mode 100644 index bc2dc04..0000000 --- a/shared/src/commonMain/sqldelight/bou/amine/apps/readerforselfossv2/dao/2.sqm +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE ITEM_BACKUP AS SELECT `id`, `datetime`, `title`, `content`, - `unread`, `starred`, `thumbnail`, `icon`, `link`, `sourcetitle`, - `tags` FROM ITEM; -ALTER TABLE ITEM_BACKUP ADD COLUMN `author` TEXT; -DROP TABLE ITEM; -ALTER TABLE ITEM_BACKUP RENAME TO ITEM; \ No newline at end of file -- 2.34.1 From 2e7f7f23b38a4b8a9305602d201105ea8dbc4924 Mon Sep 17 00:00:00 2001 From: aminecmi Date: Wed, 28 Dec 2022 15:34:22 +0100 Subject: [PATCH 2/2] No duplicate builds for PRs. --- .drone.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 2f0108c..b0a8839 100644 --- a/.drone.yml +++ b/.drone.yml @@ -35,7 +35,6 @@ steps: trigger: event: - push - - pull_request --- kind: pipeline -- 2.34.1