Drizzle Kit + Planetscale example?

I was hoping there would be an example of how to integrate the two. Planetscales docs are just OK, so I'm wondering if anyone has done this before and would be willing to share some code,
4 Replies
Ahmed
Ahmed2y ago
It's similar to the config used for mysql2 here's my config file:
import type { Config } from 'drizzle-kit';
import 'dotenv/config';

export default {
schema: './app/services/db/schema.server.ts',
out: './drizzle',
driver: 'mysql2',
dbCredentials: {
connectionString: process.env.DATABASE_URL,
},
} satisfies Config;
import type { Config } from 'drizzle-kit';
import 'dotenv/config';

export default {
schema: './app/services/db/schema.server.ts',
out: './drizzle',
driver: 'mysql2',
dbCredentials: {
connectionString: process.env.DATABASE_URL,
},
} satisfies Config;
I use Remix and whenever I start the dev server, the migrations applies against the planetscale db.
SteveS
SteveSOP2y ago
Wow, that's pretty simple. Thanks for the example.
Ahmed
Ahmed2y ago
And you can use push also
SteveS
SteveSOP2y ago
If anyone comes across this in the future, you can easily create a connectionString by going to settings -> passwords -> get connection strings and in the dropdown select prisma. Then, for drizzle kit to work, replace ?sslaccept=strict on the end of the string with ?ssl={"rejectUnauthorized":true} Make sure to put in the correct password as well.

Did you find this page helpful?