mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-25 09:41:04 +01:00
Part 1 of the opt-in indexed history draft series. Validated at the integrated tip; activation remains disabled by default. Co-Authored-By: Paperclip <noreply@paperclip.ing>
10 lines
466 B
TypeScript
10 lines
466 B
TypeScript
import { customType } from "drizzle-orm/pg-core";
|
|
|
|
/** Historical serial identities retain their exact value. New identities are
|
|
* random UUIDs; the abandoned serial sequence is never advanced again. */
|
|
export const eventIdentity = customType<{ data: string | number; driverData: string }>({
|
|
dataType: () => "text",
|
|
toDriver: value => String(value),
|
|
fromDriver: value => /^\d+$/.test(value) && Number.isSafeInteger(Number(value)) ? Number(value) : value,
|
|
});
|