From 1a281d8354622a3606360f9f9a7fe4bb7d6a2c3a Mon Sep 17 00:00:00 2001
From: cloudroam <cloudroam>
Date: 星期日, 27 四月 2025 13:22:26 +0800
Subject: [PATCH] fix 短信
---
app/src/main/java/com/example/firstapp/database/AppDatabase.kt | 55 +++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 43 insertions(+), 12 deletions(-)
diff --git a/app/src/main/java/com/example/firstapp/database/AppDatabase.kt b/app/src/main/java/com/example/firstapp/database/AppDatabase.kt
index b520136..99792b8 100644
--- a/app/src/main/java/com/example/firstapp/database/AppDatabase.kt
+++ b/app/src/main/java/com/example/firstapp/database/AppDatabase.kt
@@ -7,38 +7,36 @@
import androidx.room.TypeConverters
import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase
-import com.example.firstapp.dao.PackageDao
import com.example.firstapp.database.dao.CodeDao
import com.example.firstapp.database.dao.KeywordDao
import com.example.firstapp.database.dao.MsgDao
-import com.example.firstapp.database.dao.ReminderDao
import com.example.firstapp.database.entity.Code
import com.example.firstapp.database.entity.KeywordEntity
import com.example.firstapp.database.entity.Msg
-import com.example.firstapp.database.entity.Reminder
import com.example.firstapp.utils.DATABASE_NAME
-import com.example.firstapp.utils.SettingUtils
-import com.example.firstapp.utils.TAG_LIST
import com.example.firstapp.database.ext.ConvertersDate
-import com.example.firstapp.model.PackageInfo
import com.example.firstapp.model.CourierStat
import com.example.firstapp.model.DailyStat
+import com.example.firstapp.database.dao.ReminderDao
+import com.example.firstapp.database.dao.ReminderRecordDao
+import com.example.firstapp.database.entity.Reminder
+import com.example.firstapp.database.entity.ReminderRecord
@Database(
entities = [
Msg::class,
Code::class,
- KeywordEntity::class,
- Reminder::class,
- PackageInfo::class
+ KeywordEntity::class,
+ Reminder::class,
+ ReminderRecord::class
],
views = [
CourierStat::class,
DailyStat::class
],
- version = 20,
+ version = 21,
exportSchema = false
)
@TypeConverters(ConvertersDate::class)
@@ -47,7 +45,7 @@
abstract fun codeDao(): CodeDao
abstract fun keywordDao(): KeywordDao
abstract fun reminderDao(): ReminderDao
- abstract fun packageDao(): PackageDao
+ abstract fun reminderRecordDao(): ReminderRecordDao
companion object {
@Volatile
@@ -68,8 +66,8 @@
}
}).addMigrations(
-
MIGRATION_MSG,
+ MIGRATION_20_21
)
/*if (BuildConfig.DEBUG) {
@@ -143,6 +141,39 @@
}
}
+ private val MIGRATION_20_21 = object : Migration(20, 21) {
+ override fun migrate(database: SupportSQLiteDatabase) {
+ // 创建 reminders 表
+ database.execSQL(
+ """
+ CREATE TABLE IF NOT EXISTS reminders (
+ id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
+ categoryId INTEGER NOT NULL,
+ categoryName TEXT NOT NULL,
+ notificationMethod TEXT NOT NULL,
+ isEnabled INTEGER NOT NULL DEFAULT 1,
+ createdAt INTEGER NOT NULL DEFAULT (strftime('%s','now') * 1000)
+ )
+ """
+ )
+
+ // 创建 reminder_records 表
+ database.execSQL(
+ """
+ CREATE TABLE IF NOT EXISTS reminder_records (
+ id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
+ categoryId INTEGER NOT NULL,
+ categoryName TEXT NOT NULL,
+ content TEXT NOT NULL,
+ notificationMethod TEXT NOT NULL,
+ status INTEGER NOT NULL DEFAULT 0,
+ createdAt INTEGER NOT NULL DEFAULT (strftime('%s','now') * 1000)
+ )
+ """
+ )
+ }
+ }
+
}
}
--
Gitblit v1.9.3