I have a couple of tables with UUID
as the type of their columns.
I want to convert those columns to String
rather than UUID
as debugging is just pain in the arse (e.g. browsing the sqlite file using DB Browser for SQLite requires me to do SQL query just to convert the UUID
objects to String
s to see the id values.
Going back to the question, what's the most practical way to do this?
I am thinking, and about to do, but I want to ask this first:
- in the
registerMigration
, create a new table. - new table has the String columns now.
- loop through the rows o the old table, and move those rows to the new table BUT making sure that the ids are now in
String
s and notUUID
s. - drop old table
- rename new table to the old table's name.
registerMigration("UUIDMigrationToString") { db in
try db.create(table: "new_table") { table in
table.autoIncrementedPrimaryKey("id")
table.column("someIdStuff", .text).notNull()
}
// loop through the old table...
// move the rows from the old table to the new table but with string Ids.
// drop old table, and rename new table.
}