Update m20220509 to new caqti syntax
This commit is contained in:
parent
bca4c80127
commit
bfc4e5e64f
1 changed files with 18 additions and 18 deletions
|
@ -3,6 +3,8 @@ and identifier = "2022-05-09"
|
||||||
and migrate_doc = "switch uuid encoding to hex"
|
and migrate_doc = "switch uuid encoding to hex"
|
||||||
and rollback_doc = "switch uuid encoding back to binary"
|
and rollback_doc = "switch uuid encoding back to binary"
|
||||||
|
|
||||||
|
open Grej.Infix
|
||||||
|
|
||||||
let old_uuid_rep =
|
let old_uuid_rep =
|
||||||
let encode uuid = Ok (Uuidm.to_bytes uuid) in
|
let encode uuid = Ok (Uuidm.to_bytes uuid) in
|
||||||
let decode s =
|
let decode s =
|
||||||
|
@ -12,34 +14,32 @@ let old_uuid_rep =
|
||||||
Caqti_type.custom ~encode ~decode Caqti_type.string
|
Caqti_type.custom ~encode ~decode Caqti_type.string
|
||||||
|
|
||||||
let uuids_byte_encoded_q =
|
let uuids_byte_encoded_q =
|
||||||
Caqti_request.collect ~oneshot:true
|
Caqti_type.unit ->*
|
||||||
Caqti_type.unit
|
Caqti_type.tup2 (Builder_db.Rep.id (`build : [`build])) old_uuid_rep @@
|
||||||
(Caqti_type.tup2 (Builder_db.Rep.id (`build : [`build])) old_uuid_rep)
|
"SELECT id, uuid FROM build"
|
||||||
"SELECT id, uuid FROM build"
|
|
||||||
|
|
||||||
let uuids_hex_encoded_q =
|
let uuids_hex_encoded_q =
|
||||||
Caqti_request.collect ~oneshot:true
|
Caqti_type.unit ->*
|
||||||
Caqti_type.unit
|
Caqti_type.tup2 (Builder_db.Rep.id (`build : [`build])) Builder_db.Rep.uuid @@
|
||||||
(Caqti_type.tup2 (Builder_db.Rep.id (`build : [`build])) Builder_db.Rep.uuid)
|
"SELECT id, uuid FROM build"
|
||||||
"SELECT id, uuid FROM build"
|
|
||||||
|
|
||||||
let migrate_q =
|
let migrate_q =
|
||||||
Caqti_request.exec ~oneshot:true
|
Caqti_type.tup2 (Builder_db.Rep.id (`build : [`build])) Builder_db.Rep.uuid ->.
|
||||||
(Caqti_type.tup2 (Builder_db.Rep.id (`build : [`build])) Builder_db.Rep.uuid)
|
Caqti_type.unit @@
|
||||||
"UPDATE build SET uuid = $2 WHERE id = $1"
|
"UPDATE build SET uuid = $2 WHERE id = $1"
|
||||||
|
|
||||||
let rollback_q =
|
let rollback_q =
|
||||||
Caqti_request.exec ~oneshot:true
|
Caqti_type.tup2 (Builder_db.Rep.id (`build : [`build])) old_uuid_rep ->.
|
||||||
(Caqti_type.tup2 (Builder_db.Rep.id (`build : [`build])) old_uuid_rep)
|
Caqti_type.unit @@
|
||||||
"UPDATE build SET uuid = $2 WHERE id = $1"
|
"UPDATE build SET uuid = $2 WHERE id = $1"
|
||||||
|
|
||||||
let create_index =
|
let create_index =
|
||||||
Caqti_request.exec Caqti_type.unit
|
Caqti_type.unit ->. Caqti_type.unit @@
|
||||||
"CREATE INDEX idx_build_uuid ON build(uuid);"
|
"CREATE INDEX idx_build_uuid ON build(uuid);"
|
||||||
|
|
||||||
let drop_index =
|
let drop_index =
|
||||||
Caqti_request.exec Caqti_type.unit
|
Caqti_type.unit ->. Caqti_type.unit @@
|
||||||
"DROP INDEX idx_build_uuid;"
|
"DROP INDEX idx_build_uuid;"
|
||||||
|
|
||||||
let migrate _datadir (module Db : Caqti_blocking.CONNECTION) =
|
let migrate _datadir (module Db : Caqti_blocking.CONNECTION) =
|
||||||
let open Grej.Infix in
|
let open Grej.Infix in
|
||||||
|
|
Loading…
Reference in a new issue