diff --git a/packages/db-sqlite/src/columnToCodeConverter.ts b/packages/db-sqlite/src/columnToCodeConverter.ts index 7bbad9a9177..bdcdba6129c 100644 --- a/packages/db-sqlite/src/columnToCodeConverter.ts +++ b/packages/db-sqlite/src/columnToCodeConverter.ts @@ -98,7 +98,7 @@ export const columnToCodeConverter: ColumnToCodeConverter = ({ if (column.type === 'jsonb' || column.type === 'geometry') { sanitizedDefault = `'${JSON.stringify(column.default)}'` } else if (typeof column.default === 'string' || column.type === 'numeric') { - sanitizedDefault = `'${column.default}'` + sanitizedDefault = JSON.stringify(column.default) } code = `${code}.default(${sanitizedDefault})` diff --git a/packages/drizzle/src/postgres/columnToCodeConverter.ts b/packages/drizzle/src/postgres/columnToCodeConverter.ts index 18b1d1143c5..1c23f104cf6 100644 --- a/packages/drizzle/src/postgres/columnToCodeConverter.ts +++ b/packages/drizzle/src/postgres/columnToCodeConverter.ts @@ -67,9 +67,9 @@ export const columnToCodeConverter: ColumnToCodeConverter = ({ } else if (column.type === 'jsonb') { sanitizedDefault = `sql\`'${JSON.stringify(column.default)}'::jsonb\`` } else if (column.type === 'numeric') { - sanitizedDefault = `sql\`${column.default}\`` - } else if (typeof column.default === 'string') { sanitizedDefault = `'${column.default}'` + } else if (typeof column.default === 'string') { + sanitizedDefault = `${JSON.stringify(column.default)}` } code = `${code}.default(${sanitizedDefault})`