Hayato
Hayato
DTDrizzle Team
Created by Raiyan on 6/12/2023 in #help
Planetscale migration error
5 replies
DTDrizzle Team
Created by Raiyan on 6/12/2023 in #help
Planetscale migration error
Problem is that you did not put --> statement-breakpoint between SQL statements. For example, not this.
sql:0000_closed_wolf_cub.sql
CREATE TABLE `posts` (
`id` serial AUTO_INCREMENT PRIMARY KEY NOT NULL,
`title` text NOT NULL,
`content` text NOT NULL,
`published` boolean NOT NULL,
`author_id` int NOT NULL);

CREATE TABLE `users` (
`id` serial AUTO_INCREMENT PRIMARY KEY NOT NULL,
`email` text NOT NULL,
`name` text NOT NULL);

CREATE INDEX `authorId_idx` ON `posts` (`author_id`);
sql:0000_closed_wolf_cub.sql
CREATE TABLE `posts` (
`id` serial AUTO_INCREMENT PRIMARY KEY NOT NULL,
`title` text NOT NULL,
`content` text NOT NULL,
`published` boolean NOT NULL,
`author_id` int NOT NULL);

CREATE TABLE `users` (
`id` serial AUTO_INCREMENT PRIMARY KEY NOT NULL,
`email` text NOT NULL,
`name` text NOT NULL);

CREATE INDEX `authorId_idx` ON `posts` (`author_id`);
this works.
sql:0000_closed_wolf_cub.sql
CREATE TABLE `posts` (
`id` serial AUTO_INCREMENT PRIMARY KEY NOT NULL,
`title` text NOT NULL,
`content` text NOT NULL,
`published` boolean NOT NULL,
`author_id` int NOT NULL);
--> statement-breakpoint
CREATE TABLE `users` (
`id` serial AUTO_INCREMENT PRIMARY KEY NOT NULL,
`email` text NOT NULL,
`name` text NOT NULL);
--> statement-breakpoint
CREATE INDEX `authorId_idx` ON `posts` (`author_id`);
sql:0000_closed_wolf_cub.sql
CREATE TABLE `posts` (
`id` serial AUTO_INCREMENT PRIMARY KEY NOT NULL,
`title` text NOT NULL,
`content` text NOT NULL,
`published` boolean NOT NULL,
`author_id` int NOT NULL);
--> statement-breakpoint
CREATE TABLE `users` (
`id` serial AUTO_INCREMENT PRIMARY KEY NOT NULL,
`email` text NOT NULL,
`name` text NOT NULL);
--> statement-breakpoint
CREATE INDEX `authorId_idx` ON `posts` (`author_id`);
In order to geneerate --> statement-breakpoint when you execute generate command, you need to add breakpoints: true, in your drizzle.config.ts.
import type { Config } from "drizzle-kit";

const drizzleConfig = {
schema: "./src/db/schema.ts",
out: "./src/db/migrations",
breakpoints: true,
} satisfies Config;

export default drizzleConfig;
import type { Config } from "drizzle-kit";

const drizzleConfig = {
schema: "./src/db/schema.ts",
out: "./src/db/migrations",
breakpoints: true,
} satisfies Config;

export default drizzleConfig;
Here is my command.
$ pnpm drizzle-kit generate:mysql --config drizzle.config.ts
$ pnpm drizzle-kit generate:mysql --config drizzle.config.ts
If you run generate command, you should have sql with --> statement-breakpoint
5 replies
DTDrizzle Team
Created by Hayato on 6/8/2023 in #help
Relational queries (PlanetScale)
@Dan Kochetov Thank you for your response. I have tried using relational queries with PlanetScale, and it worked!!! 🙂 I created a GitHub repository for anyone who might have the same questions regarding the use of relational queries with PlanetScale. https://github.com/hayato94087/nextjs-planetscale-drizzle-20230609-test The main problem I encountered was forgetting to include {schema} as a parameter in drizzle.
const db = drizzle(connection, { schema });
const db = drizzle(connection, { schema });
Thank you for your time.
9 replies
DTDrizzle Team
Created by Hayato on 6/8/2023 in #help
Relational queries (PlanetScale)
Hello, thank you for your response. I've examined the link you provided, and it appears to be primarily concerned with output formatting. From what I understand, currently, Drizzle requires an additional step to produce user-friendly outputs in MySQL compared to Prisma. I'm currently using Vercel at the edge and specifically targeting the Tokyo region, hence I've been seeking a suitable database for this setup. PlanetScale, with its Tokyo region availability, was appealing to me. However, considering the support for relational queries, I'm also exploring PostgreSQL databases like Supabase, which likewise offers a Tokyo region. I appreciate your assistance in clarifying this situation.
9 replies