Giter Club home page Giter Club logo

Comments (3)

sadmann7 avatar sadmann7 commented on May 27, 2024

Can you try using planetscale mysql. I heard on twitter that, drizzle orm doesn't work quite well with local mysql if planetscale sql is used.

from shadcn-table.

noxify avatar noxify commented on May 27, 2024

Tested it locally ( OSX with DBngin ) with "mysql2": "3.7.1".
Works without any issues.

// drizzle.config.ts 

import { type Config } from "drizzle-kit"

import { env } from "@/env.mjs"

const uri = [
  "mysql://",
  env.DB_USERNAME,
  ":",
  env.DB_PASSWORD,
  "@",
  env.DB_HOST,
  ":3306/",
  env.DB_NAME,
].join("")

export default {
  schema: "./src/db/schema.ts",
  driver: "mysql2",
  out: "./drizzle",
  dbCredentials: { uri },
  tablesFilter: ["shadcn-table_*"],
} satisfies Config
// src/env.mjs

import { createEnv } from "@t3-oss/env-nextjs"
import { z } from "zod"

export const env = createEnv({
  server: {
    NODE_ENV: z
      .enum(["development", "test", "production"])
      .default("development"),
    DB_USERNAME: z.string(),
    DB_HOST: z.string(),
    DB_NAME: z.string(),
    DB_PASSWORD: z.string(),
  },
  client: {},
  runtimeEnv: {
    NODE_ENV: process.env.NODE_ENV,
    DB_NAME: process.env.DB_NAME,
    DB_HOST: process.env.DB_HOST,
    DB_USERNAME: process.env.DB_USERNAME,
    DB_PASSWORD: process.env.DB_PASSWORD
  },
  skipValidation: !!process.env.SKIP_ENV_VALIDATION,
  emptyStringAsUndefined: true,
})
// src/db/index.ts

import { drizzle } from "drizzle-orm/mysql2"
import mysql from "mysql2/promise"

import { env } from "@/env.mjs"

import * as schema from "./schema"

const connection = await mysql.createConnection({
  host: env.DB_HOST,
  user: env.DB_USERNAME,
  password: env.DB_PASSWORD,
  database: env.DB_NAME,
})


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

from shadcn-table.

sadmann7 avatar sadmann7 commented on May 27, 2024

The project is using neon (via postgressql) now.

So closing the issue.

from shadcn-table.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.