Primary Key restricted to Int64?
Is there any reason to force the primary key to be Int64? Sqlite supports BLOB primary keys which work rather well for UUIDs.
Did you read the documentation on the primaryKey function?
Only the shorthand should be restricted, since the basic use-case is an integer that autoincrements:
db.create(table: users) { t in
t.column(id, primaryKey: true)
}
// CREATE TABLE "users" ("id" INTEGER PRIMARY KEY NOT NULL)
You should be able to create a primary key of any type if you use the primaryKey function:
let uuid = Expression<Blob>("uuid")
db.create(table: users) { t in
t.column(uuid)
t.primaryKey(uuid)
}
// CREATE TABLE "users" ("uuid" BLOB NOT NULL, PRIMARY KEY("uuid"))
Closing for this now. Please let me know if it actually doesn't work for you!
Ok, I obviously didn't pay enough attention. It might be helpful to call this out in the docs.
Thanks!
It might be helpful to call this out in the docs.
Hm...I try to! Here:
primaryKeyadds anINTEGER PRIMARY KEYconstraint to a single column. (See theprimaryKeyfunction under Table Constraints for non-integer primary keys).
— Documented in "Column Constraints"
Any ideas on how to better communicate this?
Honestly, rather than do that I just went ahead and submitted a PR #76 to remove the restriction