Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not Generating Schema Automatically #8

Open
GtechGovind opened this issue Jan 12, 2024 · 2 comments
Open

Not Generating Schema Automatically #8

GtechGovind opened this issue Jan 12, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@GtechGovind
Copy link

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?

@mikedawson
Copy link
Member

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.

@mikedawson mikedawson added the bug Something isn't working label Jan 12, 2024
@GtechGovind
Copy link
Author

I did try that, without explicitly setting the tableName and columnInfo or any extra parameters, but the outcome remains unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants