t3-oss / create-t3-turbo

Clean and simple starter repo using the T3 Stack along with Expo React Native

Home Page:https://turbo.t3.gg

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

quesiton: using mysql2 instead of planetscale

toddjudd opened this issue · comments

Just trying to learn through trial and error testing out the repo, ultimately want to replace an old project with this and sst.

Ran into a issue when trying to use a local mysql database instead of planetscale. the same issue was mentioned by Akash in this thread. https://www.answeroverflow.com/m/1201502158051352607.

Here they mention needing "to set up MySQL2 as external package in nextjs config. Or something like that"

I have no clue what that means. I'm happy to read doc's but the only thing I can find is serverComponentsExternalPackages
which doesn't appear to be what I'm looking for, but I could be wrong.

Would appreciate it if any one could point me in the right direction.

Just install the mysql2 package and use it instead of the Planetscale one

Something like this should work

import { drizzle } from 'drizzle-orm/mysql2';
import { createConnection } from 'mysql2/promise';

import * as auth from './schema/auth';
import * as post from './schema/post';

export const schema = { ...auth, ...post };

export { mySqlTable as tableCreator } from "./schema/_table";

export * from "drizzle-orm";

const mySql = await createConnection({
  host: process.env.DB_HOST!,
  user: process.env.DB_USERNAME!,
  password: process.env.DB_PASSWORD!,
  database: process.env.DB_NAME!,
});

export const db = drizzle(mySql, { schema, mode: "default" });

Just install the mysql2 package and use it instead of the Planetscale one

As long as you disable any edge runtime, yes

Yep that solves it. Thanks!