SQL string could not be parsed: non-terminated block comment at ...

Hi all, I am using Turso and I added two properties to my users table created_at and updated_at. I successfully generated a migration file, which looks like this:
ALTER TABLE `users` ADD `created_at` text DEFAULT (current_timestamp) NOT NULL;--> statement-breakpoint
ALTER TABLE `users` ADD `updated_at` text DEFAULT (current_timestamp) NOT NULL;
ALTER TABLE `users` ADD `created_at` text DEFAULT (current_timestamp) NOT NULL;--> statement-breakpoint
ALTER TABLE `users` ADD `updated_at` text DEFAULT (current_timestamp) NOT NULL;
This is my schema:
import { sql } from 'drizzle-orm';
import { boolean } from 'drizzle-orm/mysql-core';
import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core';
import { createInsertSchema, createSelectSchema } from 'drizzle-zod';

export const users = sqliteTable('users', {
id: text('id').primaryKey(),
name: text('name').notNull(),
email: text('email').unique().notNull(),
subscribed: integer('subscribed', { mode: "boolean"}).notNull(), // Store subscription type
google_id: text('google_id').unique().notNull(), // Store Google ID for authentication
created_at: text('created_at').notNull().default(sql`(current_timestamp)`), <--- NEW
updated_at: text('updated_at').notNull().default(sql`(current_timestamp)`), <--- NEW
});

export const sessions = sqliteTable('sessions', {
id: text('id').primaryKey(),
expires_at: integer('expires_at').notNull(),
user_id: text('user_id').notNull().references(() => users.id),
});

export type InsertUser = typeof users.$inferInsert;
export const zInsertUser = createInsertSchema(users);
export type SelectUser = typeof users.$inferSelect;
import { sql } from 'drizzle-orm';
import { boolean } from 'drizzle-orm/mysql-core';
import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core';
import { createInsertSchema, createSelectSchema } from 'drizzle-zod';

export const users = sqliteTable('users', {
id: text('id').primaryKey(),
name: text('name').notNull(),
email: text('email').unique().notNull(),
subscribed: integer('subscribed', { mode: "boolean"}).notNull(), // Store subscription type
google_id: text('google_id').unique().notNull(), // Store Google ID for authentication
created_at: text('created_at').notNull().default(sql`(current_timestamp)`), <--- NEW
updated_at: text('updated_at').notNull().default(sql`(current_timestamp)`), <--- NEW
});

export const sessions = sqliteTable('sessions', {
id: text('id').primaryKey(),
expires_at: integer('expires_at').notNull(),
user_id: text('user_id').notNull().references(() => users.id),
});

export type InsertUser = typeof users.$inferInsert;
export const zInsertUser = createInsertSchema(users);
export type SelectUser = typeof users.$inferSelect;
When running the migration, i get the following error:
[⣯] applying migrations...LibsqlError: SQL_PARSE_ERROR: SQL string could not be parsed: non-terminated block comment at (3, 1)
at mapHranaError (file:///home/ubuntu/reap-checker/node_modules/@libsql/client/lib-esm/hrana.js:257:16)
at HttpClient.batch (file:///home/ubuntu/reap-checker/node_modules/@libsql/client/lib-esm/http.js:82:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at LibSQLSession.batch (/home/ubuntu/reap-checker/node_modules/src/libsql/session.ts:75:24)
at migrate (/home/ubuntu/reap-checker/node_modules/src/libsql/migrator.ts:50:2) {
code: 'SQL_PARSE_ERROR',
rawCode: undefined,
[cause]: [ResponseError: SQL string could not be parsed: non-terminated block comment at (3, 1)] {
code: 'SQL_PARSE_ERROR',
proto: {
message: 'SQL string could not be parsed: non-terminated block comment at (3, 1)',
code: 'SQL_PARSE_ERROR'
}
}
}
[⣯] applying migrations...LibsqlError: SQL_PARSE_ERROR: SQL string could not be parsed: non-terminated block comment at (3, 1)
at mapHranaError (file:///home/ubuntu/reap-checker/node_modules/@libsql/client/lib-esm/hrana.js:257:16)
at HttpClient.batch (file:///home/ubuntu/reap-checker/node_modules/@libsql/client/lib-esm/http.js:82:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at LibSQLSession.batch (/home/ubuntu/reap-checker/node_modules/src/libsql/session.ts:75:24)
at migrate (/home/ubuntu/reap-checker/node_modules/src/libsql/migrator.ts:50:2) {
code: 'SQL_PARSE_ERROR',
rawCode: undefined,
[cause]: [ResponseError: SQL string could not be parsed: non-terminated block comment at (3, 1)] {
code: 'SQL_PARSE_ERROR',
proto: {
message: 'SQL string could not be parsed: non-terminated block comment at (3, 1)',
code: 'SQL_PARSE_ERROR'
}
}
}
Any idea what's going on? This is a super simple migration, just adding 2 columns, so not sure what to do... Thanks
4 Replies
Nicolas
NicolasOP5mo ago
Using the following packages/version:
"drizzle-kit": "^0.23.1",
"drizzle-orm": "^0.32.1",
"drizzle-zod": "^0.5.1",
"drizzle-kit": "^0.23.1",
"drizzle-orm": "^0.32.1",
"drizzle-zod": "^0.5.1",
Mario564
Mario5645mo ago
Hi Nick, can you try removing the statement breakpoint comment and see if the migration applies?
Nicolas
NicolasOP5mo ago
Hi Mario, I tried that but still received the same error, thanks for the suggestion. The error was I had another migration file that was pulled from the introspection and it was commented out... by having it commented out I thought it woudln't inter unless uncommented but it did...
Mario564
Mario5645mo ago
Ah alright, glad you got it sorted out
Want results from more Discord servers?
Add your server