Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

feat: don't use xid, use base58 uuid with prefix

Brad Barbin98bb7ab4c3d2
diff --git a/llm/workflows/database-migration.md b/llm/workflows/database-migration.md
index be300c02cb..7176868ab1 100644
--- a/llm/workflows/database-migration.md
+++ b/llm/workflows/database-migration.md
@@ -37,8 +37,8 @@ All tables in Carbon follow these patterns:
##### ID Generation
```sql
--- Always use xid() for primary keys
-"id" TEXT NOT NULL DEFAULT xid()
+-- Always use id() for primary keys
+"id" TEXT NOT NULL DEFAULT id()
```
##### Multi-Tenancy
@@ -70,7 +70,7 @@ CREATE INDEX "tableName_companyId_idx" ON "tableName" ("companyId");
```sql
CREATE TABLE "entityyName" (
- "id" TEXT NOT NULL DEFAULT xid(),
+ "id" TEXT NOT NULL DEFAULT id('entity'),
"companyId" TEXT NOT NULL,
"name" TEXT NOT NULL,
"description" TEXT,
@@ -151,7 +151,7 @@ CREATE POLICY "DELETE" ON "entityName"
#### Common Column Types
-- **IDs**: `TEXT NOT NULL DEFAULT xid()`
+- **IDs**: `TEXT NOT NULL DEFAULT id()`
- **Names**: `TEXT NOT NULL`
- **Financial**: `NUMERIC` or `DECIMAL`
- **Quantities**: `INTEGER`
@@ -209,7 +209,7 @@ export const entityFormValidator = zfd.formData({
## Best Practices
-- Always use `xid()` for primary keys
+- Always use `id()` for primary keys
- Include `companyId` in all business tables
- Use composite primary keys `("id", "companyId")`
- Follow the standardized RLS policy naming (SELECT, INSERT, UPDATE, DELETE)
@@ -234,7 +234,7 @@ export const entityFormValidator = zfd.formData({
## Migration Checklist
- [ ] Migration file created with `npm run db:migrate <name>`
-- [ ] Table includes `id` with `DEFAULT xid()`
+- [ ] Table includes `id` with `DEFAULT id()`
- [ ] Table includes `companyId` with proper foreign key
- [ ] Composite primary key on `("id", "companyId")`
- [ ] Standard audit columns included
diff --git a/packages/database/src/swagger-docs-schema.ts b/packages/database/src/swagger-docs-schema.ts
index d32f315b8b..837a82202e 100644
--- a/packages/database/src/swagger-docs-schema.ts
+++ b/packages/database/src/swagger-docs-schema.ts
@@ -58132,6 +58132,62 @@ export default {
tags: ["(rpc) get_purchasing_planning"],
},
},
+ "/rpc/id": {
+ get: {
+ parameters: [
+ {
+ format: "text",
+ in: "query",
+ name: "_prefix",
+ required: false,
+ type: "string",
+ },
+ ],
+ produces: [
+ "application/json",
+ "application/vnd.pgrst.object+json;nulls=stripped",
+ "application/vnd.pgrst.object+json",
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ },
+ },
+ tags: ["(rpc) id"],
+ },
+ post: {
+ parameters: [
+ {
+ in: "body",
+ name: "args",
+ required: true,
+ schema: {
+ properties: {
+ _prefix: {
+ format: "text",
+ type: "string",
+ },
+ },
+ type: "object",
+ },
+ },
+ {
+ $ref: "#/parameters/preferParams",
+ },
+ ],
+ produces: [
+ "application/json",
+ "application/vnd.pgrst.object+json;nulls=stripped",
+ "application/vnd.pgrst.object+json",
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ },
+ },
+ tags: ["(rpc) id"],
+ },
+ },
"/rpc/get_custom_field_unique_values": {
get: {
parameters: [
@@ -58569,7 +58625,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('actc'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -58632,7 +58688,7 @@ export default {
required: ["id", "name", "companyId", "createdAt", "createdBy"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('nqr'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -58678,7 +58734,7 @@ export default {
required: ["id", "name", "companyId", "createdAt", "createdBy"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('ss'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -58738,6 +58794,7 @@ export default {
],
properties: {
id: {
+ default: "public.id('svc'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -59080,7 +59137,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -59349,7 +59406,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -59461,7 +59518,7 @@ export default {
required: ["id", "customerId", "addressId", "name"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -59507,7 +59564,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('otok'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -59561,7 +59618,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('ncsl'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -59821,7 +59878,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('ncsol'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -59940,7 +59997,7 @@ export default {
required: ["id", "name", "companyId", "createdAt", "createdBy"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('sr'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -59995,7 +60052,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('cusage'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -60293,7 +60350,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -60351,7 +60408,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('make'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -60432,7 +60489,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('shift'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -60718,7 +60775,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('view'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -60834,7 +60891,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('pq'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -60922,7 +60979,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('ncat'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -61013,7 +61070,7 @@ export default {
required: ["id", "companyId", "supplierId"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('si'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -61044,7 +61101,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('rec'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -61180,7 +61237,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('cpg'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -61227,7 +61284,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -61349,7 +61406,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('qo'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -61707,7 +61764,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('inv'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -61765,7 +61822,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('pgp'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -62276,7 +62333,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('mmat'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -62944,6 +63001,7 @@ export default {
required: ["id", "approved", "companyId", "createdBy", "createdAt"],
properties: {
id: {
+ default: "public.id('mat'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -63152,7 +63210,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('qoa'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -63589,7 +63647,7 @@ export default {
required: ["id", "name", "companyId", "createdBy", "createdAt"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('dept'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -63732,7 +63790,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('il'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -63852,7 +63910,7 @@ export default {
required: ["id", "name", "active", "companyId", "createdAt", "createdBy"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('sterm'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -63916,7 +63974,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('ncat'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -64195,7 +64253,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('cp'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -64278,7 +64336,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('ncrl'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -64451,7 +64509,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('si'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -64685,7 +64743,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('plan'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -64751,7 +64809,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('loc'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -64959,7 +65017,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('pr'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -65052,7 +65110,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('pgi'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -65345,7 +65403,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('ncc'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -65441,7 +65499,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('so'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -65612,7 +65670,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('jot'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -65754,7 +65812,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('ea'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -65955,7 +66013,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('jmm'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -66049,7 +66107,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -66158,7 +66216,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('ful'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -66428,7 +66486,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -66672,7 +66730,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('acts'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -66838,7 +66896,7 @@ export default {
required: ["id", "employeeId", "shiftId"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('eshift'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -66924,7 +66982,7 @@ export default {
required: ["id", "name", "code", "materialSubstanceId", "materialFormId"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('mtype'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -66972,7 +67030,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('ppay'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -67050,7 +67108,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('uom'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -67175,7 +67233,7 @@ export default {
required: ["id", "name", "materialSubstanceId"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('finish'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -67203,7 +67261,7 @@ export default {
required: ["id", "name", "version", "status", "createdAt", "createdBy"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('pro'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -67373,7 +67431,7 @@ export default {
required: ["id", "documentId", "type", "userId", "createdAt"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -67430,7 +67488,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('job'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -67622,7 +67680,7 @@ export default {
required: ["id", "email", "companyId", "isCustomer"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('con'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -67781,7 +67839,7 @@ export default {
required: ["id", "startDate", "endDate", "periodType", "createdAt"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('per'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -67852,7 +67910,7 @@ export default {
required: ["id", "purchaseOrderId", "status", "createdAt", "createdBy"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -67906,7 +67964,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('ncw'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -68010,7 +68068,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('pgs'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -68251,7 +68309,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -68705,7 +68763,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('wh'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -68941,6 +68999,7 @@ export default {
],
properties: {
id: {
+ default: "public.id('sh'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -69018,7 +69077,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('smeth'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -69100,7 +69159,7 @@ export default {
],
properties: {
id: {
- default: "extensions.uuid_generate_v4()",
+ default: "public.id('doc'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -69439,7 +69498,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('pi'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -69625,7 +69684,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('uatr'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -69703,7 +69762,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('jnote'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -69767,7 +69826,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('acct'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -69888,7 +69947,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('jo'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -70147,7 +70206,7 @@ export default {
required: ["id", "name", "createdAt", "createdBy"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('uatc'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -70576,7 +70635,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('qmat'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -70703,7 +70762,7 @@ export default {
required: ["id", "name", "companyId", "createdAt", "createdBy"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('cs'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -70797,7 +70856,7 @@ export default {
required: ["id", "customerId", "contactId"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -70914,7 +70973,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('ocod'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -70973,7 +71032,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -71170,7 +71229,7 @@ export default {
required: ["id", "name", "createdBy", "createdAt", "code"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('shape'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -71560,7 +71619,7 @@ export default {
required: ["id", "supplierId", "contactId"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -71613,7 +71672,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('ocli'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -71706,7 +71765,7 @@ export default {
required: ["id", "location", "feedback"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('fb'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -72014,7 +72073,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('sh'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -72357,7 +72416,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -72470,7 +72529,7 @@ export default {
required: ["id", "name", "customFields", "createdAt", "createdBy"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('gt'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -72530,7 +72589,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -72667,7 +72726,7 @@ export default {
required: ["id", "salesOrderId", "status", "createdAt", "createdBy"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -72724,7 +72783,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('sq'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -72898,7 +72957,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('ncr'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -72962,6 +73021,7 @@ export default {
required: ["id", "companyId", "employeeTypeId", "active"],
properties: {
id: {
+ default: "public.id('emp'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -72990,7 +73050,7 @@ export default {
required: ["id", "userAttributeId", "userId", "createdAt", "createdBy"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('uatv'::text)",
format: "text",
type: "string",
},
@@ -73112,7 +73172,7 @@ export default {
required: ["id", "invoiceId", "status", "createdAt"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -73158,7 +73218,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('ap'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -73250,7 +73310,7 @@ export default {
required: ["id", "name", "companyId", "createdAt", "taxPercent"],
properties: {
id: {
- default: "extensions.uuid_generate_v4()",
+ default: "public.id('cust'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -73376,7 +73436,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('po'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -73877,7 +73937,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('cplan'::text)",
description:
"Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",
format: "text",
@@ -74089,7 +74149,7 @@ export default {
required: ["id", "rfqId", "revisionId", "status", "rfqDate", "companyId"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('srfq'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -74369,7 +74429,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('curr'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -74437,7 +74497,7 @@ export default {
required: ["id", "companyId"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('addr'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -74656,7 +74716,7 @@ export default {
required: ["id", "modelPath", "companyId", "createdBy"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('model'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -74728,7 +74788,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('cl'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -74861,7 +74921,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('jl'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -75123,7 +75183,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -75223,7 +75283,7 @@ export default {
required: ["id", "procedureId", "key", "value", "createdAt", "createdBy"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -75401,7 +75461,7 @@ export default {
required: ["id", "name", "createdAt", "createdBy", "customFields"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('nct'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -75527,7 +75587,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('abil'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -75610,7 +75670,7 @@ export default {
type: "string",
},
id: {
- default: "public.xid()",
+ default: "public.id('cp'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -75631,7 +75691,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('qot'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -76320,7 +76380,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('mop'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -76525,7 +76585,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('jmat'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -76803,7 +76863,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('bp'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -76946,7 +77006,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('ncpol'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -77016,7 +77076,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('ncit'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -77338,7 +77398,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -77678,7 +77738,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -77896,7 +77956,7 @@ export default {
required: ["id", "name", "baseCurrencyCode"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -78233,7 +78293,7 @@ export default {
required: ["id", "supplierId", "addressId", "name"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -78446,7 +78506,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('pterm'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -78665,7 +78725,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('ncte'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -78716,7 +78776,7 @@ export default {
required: ["id"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('tm'::text)",
description:
"Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",
format: "text",
@@ -78878,7 +78938,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('ncs'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -78929,7 +78989,7 @@ export default {
required: ["id", "materialFormId", "name", "isMetric"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('mdim'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -79193,7 +79253,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('nc'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -79353,7 +79413,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('gcr'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -79428,7 +79488,7 @@ export default {
required: ["id", "invoiceId", "paymentId"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('pipr'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -79716,7 +79776,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('ncjo'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -79850,7 +79910,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -80111,7 +80171,7 @@ export default {
required: ["id", "name", "key", "companyId", "createdBy", "createdAt"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('api'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -80253,7 +80313,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('n'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -80302,7 +80362,7 @@ export default {
required: ["id", "name", "createdBy", "createdAt", "code"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('sub'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -80369,7 +80429,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('qmm'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -80743,7 +80803,7 @@ export default {
required: ["id", "name", "companyId", "createdAt", "taxPercent"],
properties: {
id: {
- default: "extensions.uuid_generate_v4()",
+ default: "public.id('sup'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -81098,7 +81158,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('supl'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -81168,7 +81228,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('qop'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -81229,7 +81289,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('i'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -81542,7 +81602,7 @@ export default {
required: ["id", "purchaseOrderId", "type", "userId", "createdAt"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -81792,7 +81852,7 @@ export default {
required: ["id", "name", "date", "companyId", "createdBy", "createdAt"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('hol'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -81860,7 +81920,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('pe'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -81953,7 +82013,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('hook'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -82051,7 +82111,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('wc'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -82169,7 +82229,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('g'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -82295,7 +82355,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('sp'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -82366,7 +82426,7 @@ export default {
required: ["id", "name", "active", "companyId", "createdBy", "createdAt"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('ipg'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -82512,7 +82572,7 @@ export default {
required: ["id", "companyId", "customerId"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('opp'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -82553,7 +82613,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('cf'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -82694,7 +82754,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('quote'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -82897,7 +82957,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -83089,7 +83149,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -83232,7 +83292,7 @@ export default {
required: ["id", "materialSubstanceId", "name"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('grade'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -83340,6 +83400,7 @@ export default {
required: ["id", "approved", "companyId", "createdBy", "createdAt"],
properties: {
id: {
+ default: "public.id('part'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -83503,7 +83564,7 @@ export default {
required: ["id", "salesOrderId", "type", "userId", "createdAt"],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id()",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 0bd3437338..af883923b5 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -5787,7 +5787,7 @@ export type Database = {
active?: boolean
companyId: string
employeeTypeId: string
- id: string
+ id?: string
}
Update: {
active?: boolean
@@ -11942,7 +11942,7 @@ export type Database = {
externalId?: Json | null
finishId?: string | null
gradeId?: string | null
- id: string
+ id?: string
materialFormId?: string | null
materialSubstanceId?: string | null
materialTypeId?: string | null
@@ -17219,7 +17219,7 @@ export type Database = {
customFields?: Json | null
externalId?: Json | null
fromDate?: string | null
- id: string
+ id?: string
tags?: string[] | null
toDate?: string | null
updatedAt?: string | null
@@ -28134,7 +28134,7 @@ export type Database = {
createdBy: string
customFields?: Json | null
fromDate?: string | null
- id: string
+ id?: string
itemId?: string | null
serviceType: Database["public"]["Enums"]["serviceType"]
tags?: string[] | null
@@ -28350,7 +28350,7 @@ export type Database = {
createdAt?: string
createdBy: string
customFields?: Json | null
- id: string
+ id?: string
locationId: string
name: string
tags?: string[] | null
@@ -46590,6 +46590,12 @@ export type Database = {
}
Returns: boolean
}
+ id: {
+ Args: {
+ _prefix?: string
+ }
+ Returns: string
+ }
increment_webhook_error: {
Args: {
webhook_id: string
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 0bd3437338..af883923b5 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -5787,7 +5787,7 @@ export type Database = {
active?: boolean
companyId: string
employeeTypeId: string
- id: string
+ id?: string
}
Update: {
active?: boolean
@@ -11942,7 +11942,7 @@ export type Database = {
externalId?: Json | null
finishId?: string | null
gradeId?: string | null
- id: string
+ id?: string
materialFormId?: string | null
materialSubstanceId?: string | null
materialTypeId?: string | null
@@ -17219,7 +17219,7 @@ export type Database = {
customFields?: Json | null
externalId?: Json | null
fromDate?: string | null
- id: string
+ id?: string
tags?: string[] | null
toDate?: string | null
updatedAt?: string | null
@@ -28134,7 +28134,7 @@ export type Database = {
createdBy: string
customFields?: Json | null
fromDate?: string | null
- id: string
+ id?: string
itemId?: string | null
serviceType: Database["public"]["Enums"]["serviceType"]
tags?: string[] | null
@@ -28350,7 +28350,7 @@ export type Database = {
createdAt?: string
createdBy: string
customFields?: Json | null
- id: string
+ id?: string
locationId: string
name: string
tags?: string[] | null
@@ -46590,6 +46590,12 @@ export type Database = {
}
Returns: boolean
}
+ id: {
+ Args: {
+ _prefix?: string
+ }
+ Returns: string
+ }
increment_webhook_error: {
Args: {
webhook_id: string
diff --git a/packages/database/supabase/migrations/20250728114226_xid-to-uuid.sql b/packages/database/supabase/migrations/20250728114226_xid-to-uuid.sql
new file mode 100644
index 0000000000..6598c05bbb
--- /dev/null
+++ b/packages/database/supabase/migrations/20250728114226_xid-to-uuid.sql
@@ -0,0 +1,555 @@
+-- Function to convert UUID to base58 encoded string
+CREATE OR REPLACE FUNCTION uuid_to_base58(_uuid UUID)
+ RETURNS TEXT
+ LANGUAGE plpgsql
+AS
+$$
+DECLARE
+ _alphabet TEXT := '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
+ _bytes BYTEA;
+ _num NUMERIC := 0;
+ _result TEXT := '';
+ _remainder INT;
+ _i INT;
+BEGIN
+ -- Convert UUID to bytes
+ _bytes := decode(replace(_uuid::TEXT, '-', ''), 'hex');
+
+ -- Convert bytes to big integer
+ FOR _i IN 0..15 LOOP
+ _num := _num * 256 + get_byte(_bytes, _i);
+ END LOOP;
+
+ -- Handle zero case
+ IF _num = 0 THEN
+ RETURN substring(_alphabet, 1, 1);
+ END IF;
+
+ -- Convert to base58
+ WHILE _num > 0 LOOP
+ _remainder := (_num % 58)::INT;
+ _result := substring(_alphabet, _remainder + 1, 1) || _result;
+ _num := floor(_num / 58);
+ END LOOP;
+
+ RETURN _result;
+END;
+$$;
+
+
+CREATE OR REPLACE FUNCTION id(_prefix TEXT DEFAULT NULL)
+ RETURNS TEXT
+ LANGUAGE plpgsql
+AS
+$$
+DECLARE
+ _uuid TEXT;
+BEGIN
+ -- Generate UUID v4 and remove hyphens
+ _uuid := REPLACE(uuid_to_base58(uuid_generate_v4()), '-', '');
+
+ -- If prefix is provided, prepend it with underscore
+ IF _prefix IS NOT NULL THEN
+ RETURN _prefix || '_' || _uuid;
+ ELSE
+ RETURN _uuid;
+ END IF;
+END;
+$$;
+
+
+-- Core system tables
+ALTER TABLE "company" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "company" ALTER COLUMN "id" SET DEFAULT id();
+
+
+ALTER TABLE "location" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "location" ALTER COLUMN "id" SET DEFAULT id('loc');
+
+-- Contact and address tables
+ALTER TABLE "contact" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "contact" ALTER COLUMN "id" SET DEFAULT id('con');
+
+ALTER TABLE "address" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "address" ALTER COLUMN "id" SET DEFAULT id('addr');
+
+-- Customer tables
+ALTER TABLE "customer" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "customer" ALTER COLUMN "id" SET DEFAULT id('cust');
+
+ALTER TABLE "customerContact" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "customerContact" ALTER COLUMN "id" SET DEFAULT id();
+
+ALTER TABLE "customerLocation" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "customerLocation" ALTER COLUMN "id" SET DEFAULT id();
+
+ALTER TABLE "customerStatus" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "customerStatus" ALTER COLUMN "id" SET DEFAULT id('cs');
+
+ALTER TABLE "customerPartToItem" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "customerPartToItem" ALTER COLUMN "id" SET DEFAULT id('cp');
+
+-- Supplier tables
+ALTER TABLE "supplier" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "supplier" ALTER COLUMN "id" SET DEFAULT id('sup');
+
+ALTER TABLE "supplierContact" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "supplierContact" ALTER COLUMN "id" SET DEFAULT id();
+
+ALTER TABLE "supplierLocation" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "supplierLocation" ALTER COLUMN "id" SET DEFAULT id();
+
+ALTER TABLE "supplierStatus" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "supplierStatus" ALTER COLUMN "id" SET DEFAULT id('ss');
+
+ALTER TABLE "supplierProcess" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "supplierProcess" ALTER COLUMN "id" SET DEFAULT id('sp');
+
+ALTER TABLE "supplierQuote" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "supplierQuote" ALTER COLUMN "id" SET DEFAULT id('sq');
+
+ALTER TABLE "supplierQuoteLine" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "supplierQuoteLine" ALTER COLUMN "id" SET DEFAULT id();
+
+ALTER TABLE "supplierInteraction" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "supplierInteraction" ALTER COLUMN "id" SET DEFAULT id('si');
+
+-- Item and inventory tables
+ALTER TABLE "item" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "item" ALTER COLUMN "id" SET DEFAULT id('item');
+
+
+
+ALTER TABLE "itemPostingGroup" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "itemPostingGroup" ALTER COLUMN "id" SET DEFAULT id('ipg');
+
+ALTER TABLE "unitOfMeasure" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "unitOfMeasure" ALTER COLUMN "id" SET DEFAULT id('uom');
+
+ALTER TABLE "warehouse" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "warehouse" ALTER COLUMN "id" SET DEFAULT id('wh');
+
+ALTER TABLE "shelf" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "shelf" ALTER COLUMN "id" SET DEFAULT id('sh');
+
+-- Parts and materials
+ALTER TABLE "part" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "part" ALTER COLUMN "id" SET DEFAULT id('part');
+
+ALTER TABLE "material" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "material" ALTER COLUMN "id" SET DEFAULT id('mat');
+
+ALTER TABLE "materialForm" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "materialForm" ALTER COLUMN "id" SET DEFAULT id('shape');
+
+ALTER TABLE "materialSubstance" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "materialSubstance" ALTER COLUMN "id" SET DEFAULT id('sub');
+
+ALTER TABLE "materialFinish" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "materialFinish" ALTER COLUMN "id" SET DEFAULT id('finish');
+
+ALTER TABLE "materialGrade" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "materialGrade" ALTER COLUMN "id" SET DEFAULT id('grade');
+
+ALTER TABLE "materialType" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "materialType" ALTER COLUMN "id" SET DEFAULT id('mtype');
+
+ALTER TABLE "materialDimension" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "materialDimension" ALTER COLUMN "id" SET DEFAULT id('mdim');
+
+
+-- Sales tables
+ALTER TABLE "salesOrder" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "salesOrder" ALTER COLUMN "id" SET DEFAULT id('so');
+
+ALTER TABLE "salesOrderLine" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "salesOrderLine" ALTER COLUMN "id" SET DEFAULT id();
+
+ALTER TABLE "salesOrderStatusHistory" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "salesOrderStatusHistory" ALTER COLUMN "id" SET DEFAULT id();
+
+ALTER TABLE "salesOrderTransaction" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "salesOrderTransaction" ALTER COLUMN "id" SET DEFAULT id();
+
+ALTER TABLE "salesRfq" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "salesRfq" ALTER COLUMN "id" SET DEFAULT id('srfq');
+
+ALTER TABLE "salesRfqLine" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "salesRfqLine" ALTER COLUMN "id" SET DEFAULT id();
+
+ALTER TABLE "salesInvoice" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "salesInvoice" ALTER COLUMN "id" SET DEFAULT id('si');
+
+ALTER TABLE "salesInvoiceLine" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "salesInvoiceLine" ALTER COLUMN "id" SET DEFAULT id();
+
+-- Purchase tables
+ALTER TABLE "purchaseOrder" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "purchaseOrder" ALTER COLUMN "id" SET DEFAULT id('po');
+
+ALTER TABLE "purchaseOrderLine" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "purchaseOrderLine" ALTER COLUMN "id" SET DEFAULT id();
+
+ALTER TABLE "purchaseOrderStatusHistory" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "purchaseOrderStatusHistory" ALTER COLUMN "id" SET DEFAULT id();
+
+ALTER TABLE "purchaseOrderTransaction" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "purchaseOrderTransaction" ALTER COLUMN "id" SET DEFAULT id();
+
+ALTER TABLE "purchaseInvoice" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "purchaseInvoice" ALTER COLUMN "id" SET DEFAULT id('pi');
+
+ALTER TABLE "purchaseInvoiceLine" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "purchaseInvoiceLine" ALTER COLUMN "id" SET DEFAULT id();
+
+ALTER TABLE "purchaseInvoiceStatusHistory" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "purchaseInvoiceStatusHistory" ALTER COLUMN "id" SET DEFAULT id();
+
+ALTER TABLE "purchaseInvoicePriceChange" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "purchaseInvoicePriceChange" ALTER COLUMN "id" SET DEFAULT id();
+
+ALTER TABLE "purchasePayment" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "purchasePayment" ALTER COLUMN "id" SET DEFAULT id('ppay');
+
+ALTER TABLE "purchaseInvoicePaymentRelation" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "purchaseInvoicePaymentRelation" ALTER COLUMN "id" SET DEFAULT id('pipr');
+
+ALTER TABLE "paymentTerm" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "paymentTerm" ALTER COLUMN "id" SET DEFAULT id('pterm');
+
+-- Quote tables
+ALTER TABLE "quote" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "quote" ALTER COLUMN "id" SET DEFAULT id('quote');
+
+ALTER TABLE "quoteLine" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "quoteLine" ALTER COLUMN "id" SET DEFAULT id();
+
+ALTER TABLE "quoteMaterial" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "quoteMaterial" ALTER COLUMN "id" SET DEFAULT id('qmat');
+
+ALTER TABLE "quoteMakeMethod" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "quoteMakeMethod" ALTER COLUMN "id" SET DEFAULT id('qmm');
+
+ALTER TABLE "quoteOperation" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "quoteOperation" ALTER COLUMN "id" SET DEFAULT id('qo');
+
+ALTER TABLE "quoteOperationTool" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "quoteOperationTool" ALTER COLUMN "id" SET DEFAULT id('qot');
+
+ALTER TABLE "quoteOperationAttribute" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "quoteOperationAttribute" ALTER COLUMN "id" SET DEFAULT id('qoa');
+
+ALTER TABLE "quoteOperationParameter" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "quoteOperationParameter" ALTER COLUMN "id" SET DEFAULT id('qop');
+
+-- Manufacturing tables
+ALTER TABLE "job" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "job" ALTER COLUMN "id" SET DEFAULT id('job');
+
+ALTER TABLE "jobMaterial" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "jobMaterial" ALTER COLUMN "id" SET DEFAULT id('jmat');
+
+ALTER TABLE "jobOperation" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "jobOperation" ALTER COLUMN "id" SET DEFAULT id('jo');
+
+ALTER TABLE "jobMakeMethod" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "jobMakeMethod" ALTER COLUMN "id" SET DEFAULT id('jmm');
+
+ALTER TABLE "jobOperationNote" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "jobOperationNote" ALTER COLUMN "id" SET DEFAULT id('jnote');
+
+ALTER TABLE "jobOperationTool" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "jobOperationTool" ALTER COLUMN "id" SET DEFAULT id('jot');
+
+ALTER TABLE "jobOperationAttribute" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "jobOperationAttribute" ALTER COLUMN "id" SET DEFAULT id();
+
+ALTER TABLE "jobOperationParameter" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "jobOperationParameter" ALTER COLUMN "id" SET DEFAULT id();
+
+ALTER TABLE "makeMethod" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "makeMethod" ALTER COLUMN "id" SET DEFAULT id('make');
+
+ALTER TABLE "methodOperation" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "methodOperation" ALTER COLUMN "id" SET DEFAULT id('mop');
+
+ALTER TABLE "methodMaterial" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "methodMaterial" ALTER COLUMN "id" SET DEFAULT id('mmat');
+
+ALTER TABLE "methodOperationTool" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "methodOperationTool" ALTER COLUMN "id" SET DEFAULT id();
+
+ALTER TABLE "methodOperationAttribute" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "methodOperationAttribute" ALTER COLUMN "id" SET DEFAULT id();
+
+ALTER TABLE "methodOperationParameter" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "methodOperationParameter" ALTER COLUMN "id" SET DEFAULT id();
+
+-- Production tables
+ALTER TABLE "productionEvent" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "productionEvent" ALTER COLUMN "id" SET DEFAULT id('pe');
+
+ALTER TABLE "productionQuantity" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "productionQuantity" ALTER COLUMN "id" SET DEFAULT id('pq');
+
+-- Work center and equipment tables
+ALTER TABLE "workCenter" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "workCenter" ALTER COLUMN "id" SET DEFAULT id('wc');
+
+
+
+ALTER TABLE "process" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "process" ALTER COLUMN "id" SET DEFAULT id('pr');
+
+ALTER TABLE "department" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "department" ALTER COLUMN "id" SET DEFAULT id('dept');
+
+
+
+-- Employee and HR tables
+ALTER TABLE "employee" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "employee" ALTER COLUMN "id" SET DEFAULT id('emp');
+
+ALTER TABLE "employeeShift" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "employeeShift" ALTER COLUMN "id" SET DEFAULT id('eshift');
+
+ALTER TABLE "employeeAbility" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "employeeAbility" ALTER COLUMN "id" SET DEFAULT id('ea');
+
+ALTER TABLE "shift" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "shift" ALTER COLUMN "id" SET DEFAULT id('shift');
+
+ALTER TABLE "ability" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "ability" ALTER COLUMN "id" SET DEFAULT id('abil');
+
+ALTER TABLE "holiday" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "holiday" ALTER COLUMN "id" SET DEFAULT id('hol');
+
+-- Accounting tables
+ALTER TABLE "account" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "account" ALTER COLUMN "id" SET DEFAULT id('acct');
+
+ALTER TABLE "accountCategory" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "accountCategory" ALTER COLUMN "id" SET DEFAULT id('actc');
+
+ALTER TABLE "accountSubcategory" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "accountSubcategory" ALTER COLUMN "id" SET DEFAULT id('acts');
+
+ALTER TABLE "accountingPeriod" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "accountingPeriod" ALTER COLUMN "id" SET DEFAULT id('ap');
+
+ALTER TABLE "currency" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "currency" ALTER COLUMN "id" SET DEFAULT id('curr');
+
+ALTER TABLE "journalLine" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "journalLine" ALTER COLUMN "id" SET DEFAULT id('jl');
+
+ALTER TABLE "costLedger" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "costLedger" ALTER COLUMN "id" SET DEFAULT id('cl');
+
+ALTER TABLE "itemLedger" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "itemLedger" ALTER COLUMN "id" SET DEFAULT id('il');
+
+ALTER TABLE "supplierLedger" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "supplierLedger" ALTER COLUMN "id" SET DEFAULT id('supl');
+
+ALTER TABLE "postingGroupInventory" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "postingGroupInventory" ALTER COLUMN "id" SET DEFAULT id('pgi');
+
+ALTER TABLE "postingGroupPurchasing" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "postingGroupPurchasing" ALTER COLUMN "id" SET DEFAULT id('pgp');
+
+ALTER TABLE "postingGroupSales" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "postingGroupSales" ALTER COLUMN "id" SET DEFAULT id('pgs');
+
+-- Receipt and shipping tables
+ALTER TABLE "receipt" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "receipt" ALTER COLUMN "id" SET DEFAULT id('rec');
+
+ALTER TABLE "receiptLine" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "receiptLine" ALTER COLUMN "id" SET DEFAULT id();
+
+ALTER TABLE "shipment" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "shipment" ALTER COLUMN "id" SET DEFAULT id('sh');
+
+ALTER TABLE "shipmentLine" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "shipmentLine" ALTER COLUMN "id" SET DEFAULT id();
+
+ALTER TABLE "shippingMethod" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "shippingMethod" ALTER COLUMN "id" SET DEFAULT id('smeth');
+
+ALTER TABLE "shippingTerm" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "shippingTerm" ALTER COLUMN "id" SET DEFAULT id('sterm');
+
+-- Document tables
+ALTER TABLE "document" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "document" ALTER COLUMN "id" SET DEFAULT id('doc');
+
+ALTER TABLE "documentTransaction" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "documentTransaction" ALTER COLUMN "id" SET DEFAULT id();
+
+ALTER TABLE "modelUpload" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "modelUpload" ALTER COLUMN "id" SET DEFAULT id('model');
+
+-- Service tables
+ALTER TABLE "service" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "service" ALTER COLUMN "id" SET DEFAULT id('svc');
+
+
+-- Note and attribute tables
+ALTER TABLE "note" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "note" ALTER COLUMN "id" SET DEFAULT id('n');
+
+ALTER TABLE "userAttribute" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "userAttribute" ALTER COLUMN "id" SET DEFAULT id('uatr');
+
+ALTER TABLE "userAttributeCategory" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "userAttributeCategory" ALTER COLUMN "id" SET DEFAULT id('uatc');
+
+ALTER TABLE "userAttributeValue" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "userAttributeValue" ALTER COLUMN "id" SET DEFAULT id('uatv');
+
+ALTER TABLE "customField" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "customField" ALTER COLUMN "id" SET DEFAULT id('cf');
+
+-- API and OAuth tables
+ALTER TABLE "apiKey" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "apiKey" ALTER COLUMN "id" SET DEFAULT id('api');
+
+ALTER TABLE "oauthClient" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "oauthClient" ALTER COLUMN "id" SET DEFAULT id('ocli');
+
+ALTER TABLE "oauthCode" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "oauthCode" ALTER COLUMN "id" SET DEFAULT id('ocod');
+
+ALTER TABLE "oauthToken" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "oauthToken" ALTER COLUMN "id" SET DEFAULT id('otok');
+
+-- Quality tables
+ALTER TABLE "nonConformance" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "nonConformance" ALTER COLUMN "id" SET DEFAULT id('nc');
+
+ALTER TABLE "nonConformanceType" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "nonConformanceType" ALTER COLUMN "id" SET DEFAULT id('nct');
+
+ALTER TABLE "nonConformanceWorkflow" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "nonConformanceWorkflow" ALTER COLUMN "id" SET DEFAULT id('ncw');
+
+ALTER TABLE "nonConformanceSupplier" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "nonConformanceSupplier" ALTER COLUMN "id" SET DEFAULT id('ncs');
+
+ALTER TABLE "nonConformanceCustomer" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "nonConformanceCustomer" ALTER COLUMN "id" SET DEFAULT id('ncc');
+
+ALTER TABLE "nonConformanceJobOperation" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "nonConformanceJobOperation" ALTER COLUMN "id" SET DEFAULT id('ncjo');
+
+ALTER TABLE "nonConformancePurchaseOrderLine" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "nonConformancePurchaseOrderLine" ALTER COLUMN "id" SET DEFAULT id('ncpol');
+
+ALTER TABLE "nonConformanceSalesOrderLine" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "nonConformanceSalesOrderLine" ALTER COLUMN "id" SET DEFAULT id('ncsol');
+
+ALTER TABLE "nonConformanceReceiptLine" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "nonConformanceReceiptLine" ALTER COLUMN "id" SET DEFAULT id('ncrl');
+
+ALTER TABLE "nonConformanceTrackedEntity" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "nonConformanceTrackedEntity" ALTER COLUMN "id" SET DEFAULT id('ncte');
+
+ALTER TABLE "nonConformanceShipmentLine" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "nonConformanceShipmentLine" ALTER COLUMN "id" SET DEFAULT id('ncsl');
+
+ALTER TABLE "nonConformanceInvestigationTask" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "nonConformanceInvestigationTask" ALTER COLUMN "id" SET DEFAULT id('ncit');
+
+ALTER TABLE "nonConformanceActionTask" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "nonConformanceActionTask" ALTER COLUMN "id" SET DEFAULT id('ncat');
+
+ALTER TABLE "nonConformanceApprovalTask" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "nonConformanceApprovalTask" ALTER COLUMN "id" SET DEFAULT id('ncat');
+
+ALTER TABLE "nonConformanceReviewer" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "nonConformanceReviewer" ALTER COLUMN "id" SET DEFAULT id('ncr');
+
+ALTER TABLE "gauge" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "gauge" ALTER COLUMN "id" SET DEFAULT id('g');
+
+ALTER TABLE "gaugeType" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "gaugeType" ALTER COLUMN "id" SET DEFAULT id('gt');
+
+ALTER TABLE "gaugeCalibrationRecord" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "gaugeCalibrationRecord" ALTER COLUMN "id" SET DEFAULT id('gcr');
+
+ALTER TABLE "scrapReason" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "scrapReason" ALTER COLUMN "id" SET DEFAULT id('sr');
+
+ALTER TABLE "noQuoteReason" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "noQuoteReason" ALTER COLUMN "id" SET DEFAULT id('nqr');
+
+-- Billing and plan tables
+ALTER TABLE "plan" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "plan" ALTER COLUMN "id" SET DEFAULT id('plan');
+
+ALTER TABLE "companyPlan" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "companyPlan" ALTER COLUMN "id" SET DEFAULT id('cplan');
+
+ALTER TABLE "companyUsage" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "companyUsage" ALTER COLUMN "id" SET DEFAULT id('cusage');
+
+ALTER TABLE "batchProperty" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "batchProperty" ALTER COLUMN "id" SET DEFAULT id('bp');
+
+
+
+-- Procedure tables
+ALTER TABLE "procedure" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "procedure" ALTER COLUMN "id" SET DEFAULT id('pro');
+
+ALTER TABLE "procedureAttribute" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "procedureAttribute" ALTER COLUMN "id" SET DEFAULT id();
+
+ALTER TABLE "procedureParameter" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "procedureParameter" ALTER COLUMN "id" SET DEFAULT id();
+
+-- Configuration tables
+ALTER TABLE "configurationParameter" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "configurationParameter" ALTER COLUMN "id" SET DEFAULT id('cp');
+
+ALTER TABLE "configurationParameterGroup" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "configurationParameterGroup" ALTER COLUMN "id" SET DEFAULT id('cpg');
+
+-- System tables
+ALTER TABLE "webhook" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "webhook" ALTER COLUMN "id" SET DEFAULT id('hook');
+
+ALTER TABLE "tableView" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "tableView" ALTER COLUMN "id" SET DEFAULT id('view');
+
+
+ALTER TABLE "invite" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "invite" ALTER COLUMN "id" SET DEFAULT id('inv');
+
+ALTER TABLE "feedback" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "feedback" ALTER COLUMN "id" SET DEFAULT id('fb');
+
+ALTER TABLE "terms" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "terms" ALTER COLUMN "id" SET DEFAULT id('tm');
+
+ALTER TABLE "opportunity" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "opportunity" ALTER COLUMN "id" SET DEFAULT id('opp');
+
+ALTER TABLE "fulfillment" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "fulfillment" ALTER COLUMN "id" SET DEFAULT id('ful');
+
+ALTER TABLE "period" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "period" ALTER COLUMN "id" SET DEFAULT id('per');
+
+ALTER TABLE "supplierPart" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "supplierPart" ALTER COLUMN "id" SET DEFAULT id('sp');
+
+ALTER TABLE "supplierPartToItem" ALTER COLUMN "id" DROP DEFAULT;
+ALTER TABLE "supplierPartToItem" ALTER COLUMN "id" SET DEFAULT id();
+
+
+
+-- DROP FUNCTION xid(TIMESTAMPTZ);
\ No newline at end of file
diff --git a/packages/database/supabase/migrations/20250728131922_readable-id-index.sql b/packages/database/supabase/migrations/20250728131922_readable-id-index.sql
new file mode 100644
index 0000000000..fb6828d671
--- /dev/null
+++ b/packages/database/supabase/migrations/20250728131922_readable-id-index.sql
@@ -0,0 +1 @@
+CREATE INDEX "item_readableId_idx" ON "item" USING btree ("readableId", "companyId");
\ No newline at end of file