You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into crashes with Exposed when creating the same table with indices across different Postgres schemas. I think this might be related to #797, except that this affects indices instead of tables.
This can be reproduced with the following code and steps below:
packagereproimportorg.jetbrains.exposed.dao.id.LongIdTableimportorg.jetbrains.exposed.sql.Databaseimportorg.jetbrains.exposed.sql.SchemaUtilsimportorg.jetbrains.exposed.sql.transactions.transactionobject Users : LongIdTable() {
val firebaseId = varchar("firebase_id", 36).uniqueIndex()
val chatId = long("chat").nullable().index()
}
funmain() {
val db =Database.connect("jdbc:postgresl://database url here?currentSchema=someSchema")
transaction(db) {
SchemaUtils.createMissingTablesAndColumns(Users)
}
}
Run the repro on one postgres schema
Create another schema in postgres
Change the code so that currentSchema points to the new schema
Run it once. As expected, this outputs:
2020-09-01 15:43:27.735 [main] INFO Exposed - Preparing create tables statements took 53ms
2020-09-01 15:43:27.756 [main] DEBUG Exposed - CREATE TABLE IF NOT EXISTS users (id BIGSERIAL PRIMARY KEY, firebase_id VARCHAR(36) NOT NULL, chat BIGINT NULL)
2020-09-01 15:43:27.766 [main] DEBUG Exposed - ALTER TABLE users ADD CONSTRAINT users_firebase_id_unique UNIQUE (firebase_id)
2020-09-01 15:43:27.774 [main] DEBUG Exposed - CREATE INDEX users_chat ON users (chat)
However, it also outputs:
2020-09-01 15:43:28.231 [main] WARN Exposed - Indices missed from database (will be created):
2020-09-01 15:43:28.231 [main] WARN Exposed - Unique Index 'users_firebase_id_unique' for 'users' on columns repro.Users.firebase_id
2020-09-01 15:43:28.231 [main] WARN Exposed - Indices exist in database and not mapped in code on class 'users':
2020-09-01 15:43:28.231 [main] WARN Exposed - Unique Index 'users_firebase_id_unique' for 'users' on columns repro.Users.firebase_id, repro.Users.firebase_id
Run the snippet again, it now crashes because it attempts to create indices that already exist:
I ran into crashes with Exposed when creating the same table with indices across different Postgres schemas. I think this might be related to #797, except that this affects indices instead of tables.
This can be reproduced with the following code and steps below:
currentSchema
points to the new schemaHowever, it also outputs:
The text was updated successfully, but these errors were encountered: