1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| -- +goose Up
-- +goose StatementBegin CREATE FUNCTION bin_from_uuid(uuid CHAR(36)) RETURNS BINARY(16) DETERMINISTIC BEGIN RETURN UNHEX(CONCAT(MID(uuid, 25, 12), MID(uuid, 20, 4), MID(uuid, 15, 4), MID(uuid, 10, 4), MID(uuid, 1, 8))); END -- +goose StatementEnd
-- +goose StatementBegin CREATE FUNCTION uuid_from_bin(b BINARY(16)) RETURNS CHAR(36) DETERMINISTIC BEGIN DECLARE hex CHAR(32); SET hex = HEX(b); RETURN LOWER(CONCAT(MID(hex, 25, 8), '-', MID(hex, 21,4), '-', MID(hex, 17,4), '-', MID(hex, 13,4), '-', MID(hex, 1, 12))); END -- +goose StatementEnd
|