Not Generating Schema Automatically
This is my Implementation
@DoorDatabase(
version = 1,
entities = [
TvmConfiguration::class
]
)
abstract class AtekDatabase : RoomDatabase() {
abstract fun tvmConfigurationDao(): TvmConfigurationDao
companion object {
private lateinit var instance: AtekDatabase
fun getInstance(): AtekDatabase {
if (!this::instance.isInitialized) {
instance = DatabaseBuilder
.databaseBuilder(
AtekDatabase::class,
"jdbc:sqlite:file.sqlite"
).build()
}
return instance
}
}
}
@Entity(
tableName = "TVM_CONFIGURATION",
indices = [
Index(value = ["EQUIPMENT_NUMBER"], unique = true)
]
)
@Serializable
data class TvmConfiguration(
@PrimaryKey(autoGenerate = true)
var id: Long? = null,
@ColumnInfo(name = "EQUIPMENT_NUMBER")
var equipmentNumber: Long = 0,
@ColumnInfo(name = "STATION_NUMBER")
var stationNumber: Long = 0,
@ColumnInfo(name = "STATION_NAME")
var stationName: String = ""
)
but it is giving me an error saying org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (no such table: TvmConfiguration)
any specific reason why? or did do something wrong?
Hi,
Thanks for trying this out! I haven't done much testing where different table names and column names are used yet.
Something I will look into very shortly. Can you try without explicitly setting the tableName and columnInfo names (e.g. just allow it to name those as per the default)?
I think what you did is right as per the Room annotations, but the implementation on Door's side needs to be updated.
I did try that, without explicitly setting the tableName and columnInfo or any extra parameters, but the outcome remains unchanged.