- DB 마이그레이션으로 기존 알람 데이터 보존 - 연차 저장 문제 수정 (원래대로/연차 설정 시 updateRemainingAnnualLeave 호출) - 달력 5행 스크롤 없이 표시 (85dp 높이) - 알람 편집/월년 선택 다크모드 지원 - 설정 앱정보 버전 동기화 표시 Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
50 lines
1.7 KiB
Kotlin
50 lines
1.7 KiB
Kotlin
package com.example.shiftalarm
|
|
|
|
import android.content.Context
|
|
import androidx.room.Database
|
|
import androidx.room.Room
|
|
import androidx.room.RoomDatabase
|
|
import androidx.room.migration.Migration
|
|
import androidx.sqlite.db.SupportSQLiteDatabase
|
|
|
|
@Database(entities = [ShiftOverride::class, DailyMemo::class, CustomAlarm::class, AnnualLeave::class], version = 4, exportSchema = false)
|
|
abstract class AppDatabase : RoomDatabase() {
|
|
abstract fun shiftDao(): ShiftDao
|
|
|
|
companion object {
|
|
@Volatile
|
|
private var INSTANCE: AppDatabase? = null
|
|
|
|
// Migration from version 3 to 4: Add AnnualLeave table
|
|
private val MIGRATION_3_4 = object : Migration(3, 4) {
|
|
override fun migrate(database: SupportSQLiteDatabase) {
|
|
// Create AnnualLeave table
|
|
database.execSQL(
|
|
"""
|
|
CREATE TABLE IF NOT EXISTS annual_leave (
|
|
id INTEGER PRIMARY KEY NOT NULL,
|
|
totalDays REAL NOT NULL,
|
|
remainingDays REAL NOT NULL,
|
|
updatedAt INTEGER NOT NULL
|
|
)
|
|
""".trimIndent()
|
|
)
|
|
}
|
|
}
|
|
|
|
fun getDatabase(context: Context): AppDatabase {
|
|
return INSTANCE ?: synchronized(this) {
|
|
val instance = Room.databaseBuilder(
|
|
context.applicationContext,
|
|
AppDatabase::class.java,
|
|
"shift_database"
|
|
)
|
|
.addMigrations(MIGRATION_3_4)
|
|
.build()
|
|
INSTANCE = instance
|
|
instance
|
|
}
|
|
}
|
|
}
|
|
}
|