When using cloudflare D1 and drizzle, how can I do data migrations (in addition to schema migrations
When using cloudflare D1 and drizzle, how can I do data migrations (in addition to schema migrations)
Specifically, I have a table like this
export const users = sqliteTable("users", {
id: text("id")
.primaryKey()
.$defaultFn(() => prefixID("user")),
googleId: text("google_id").notNull().unique().default(""),
email: text("email").notNull().unique(),
name: text("name").notNull(),
avatarUrl: text("avatar_url"),
createdAt: integer("created_at", { mode: "timestamp" }).$defaultFn(() => new Date())
});
I want to now break out the googleId into a separate table that maps external Id (google ID) to internal user ID. But I want to migrate all values
What are my options?
Just stick that data migration into a SQL file?
Specifically, I have a table like this
export const users = sqliteTable("users", {
id: text("id")
.primaryKey()
.$defaultFn(() => prefixID("user")),
googleId: text("google_id").notNull().unique().default(""),
email: text("email").notNull().unique(),
name: text("name").notNull(),
avatarUrl: text("avatar_url"),
createdAt: integer("created_at", { mode: "timestamp" }).$defaultFn(() => new Date())
});
I want to now break out the googleId into a separate table that maps external Id (google ID) to internal user ID. But I want to migrate all values
What are my options?
Just stick that data migration into a SQL file?




