diff --git a/packages/schema/src/res/stdlib.zmodel b/packages/schema/src/res/stdlib.zmodel index a0a0a41f8..dd92ff0ae 100644 --- a/packages/schema/src/res/stdlib.zmodel +++ b/packages/schema/src/res/stdlib.zmodel @@ -94,7 +94,7 @@ function uuid(version: Int?): String { /** * Generates a globally unique identifier based on the CUID spec. */ -function cuid(): String { +function cuid(version: Int?): String { } @@@expressionContext([DefaultValue]) /** @@ -103,6 +103,12 @@ function cuid(): String { function nanoid(length: Int?): String { } @@@expressionContext([DefaultValue]) +/** + * Generates an identifier based on the ulid spec. + */ +function ulid(): String { +} @@@expressionContext([DefaultValue]) + /** * Creates a sequence of integers in the underlying database and assign the incremented * values to the ID values of the created records based on the sequence. diff --git a/packages/schema/tests/generator/prisma-generator.test.ts b/packages/schema/tests/generator/prisma-generator.test.ts index b4f58dcf1..05f4b907f 100644 --- a/packages/schema/tests/generator/prisma-generator.test.ts +++ b/packages/schema/tests/generator/prisma-generator.test.ts @@ -164,6 +164,9 @@ describe('Prisma generator test', () => { x String @default(nanoid()) y String @default(dbgenerated("gen_random_uuid()")) z String @default(auth().id) + cuid String @default(cuid()) + cuid2 String @default(cuid(2)) + ulid String @default(ulid()) } `); @@ -183,6 +186,9 @@ describe('Prisma generator test', () => { expect(content).toContain('@default(nanoid())'); expect(content).toContain('@default(dbgenerated("gen_random_uuid()"))'); expect(content).not.toContain('@default(auth().id)'); + expect(content).toContain('@default(cuid())'); + expect(content).toContain('@default(cuid(2))'); + expect(content).toContain('@default(ulid())'); }); it('triple slash comments', async () => {