I have a table defined as:
@Table(name = "Rooms")
@Entity
interface IRooms : Persistable {
@get:Column(nullable = false)
@get:Key
var roomJid: String
@get:Column(name = "gameId", nullable = false)
@get:ManyToOne
var game: IGames
@get:Column(name = "creatorJid", nullable = false)
@get:ManyToOne
var creator: IProfiles
@get:Column(nullable = false)
@get:OneToMany(cascade = arrayOf(CascadeAction.DELETE, CascadeAction.SAVE))
val players: MutableList<IPlayers>
@get:JunctionTable
@get:ManyToMany(cascade = arrayOf(CascadeAction.DELETE, CascadeAction.SAVE))
val invitedContacts: MutableList<IInvitedContacts>
@get:Column(nullable = false)
var lastModified: Long
@get:Column(nullable = false)
var isLocked: Boolean
var nextPlayerJid: String?
@get:Column(nullable = false)
var hasGameEnded: Boolean
@get:Column(nullable = false)
var isSoloRoom: Boolean
}
What I want to do is to delete isSoloRoom
column and add another column matchType
defined as:
@get:Convert(MatchType.RequeryConverter::class)
var matchType: MatchType?
Now, I want to write migration script to remove isSoloRoom
column and if isSoloRoom
value is True
set matchType
to SOLO else null
.
What I tried:
- I removed
isSoloRoom
column from the Schema above and inonUpgrade
method I wrote:
db?.execSQL("UPDATE Rooms SET ('matchType') = ('SOLO') WHERE soloRoom = 1")
The matchType
column is successfully added with desired effect but isSoloRoom
is not removed.
What should I do in order to remove the isSoloRoom
column and add matchType
column. Should I remove it from Schema too and from onUpgrade
script too via sqlite (which would be very hectic to write entire create table) or does requery provides some alternative to it?