Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Push only works on first push (drizzle with mysql) #2310

Closed
Dadangdut33 opened this issue May 13, 2024 · 1 comment
Closed

[BUG]: Push only works on first push (drizzle with mysql) #2310

Dadangdut33 opened this issue May 13, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Dadangdut33
Copy link

Dadangdut33 commented May 13, 2024

What version of drizzle-orm are you using?

0.30.10

What version of drizzle-kit are you using?

0.21.1

Describe the Bug

I'm using drizzle with mysql, and i'm trying to make development easy by using the push command as stated in the docs

I'm trying to sync my schema with the database using drizzle-kit push but the problem is that it only works when there is no data in the database. I have also tried using drizzle-kit migrate but it also won't work because the table have been created.

So what is wrong here, am i just using drizzle the wrong way or is it a bug? because i was previously using prisma and in there you can sync between the schema and the db using push command.

Also here is the error that i get:
image

drizzle config:

// env.mjs
import { createEnv } from "@t3-oss/env-nextjs";
import { z } from "zod";
import "dotenv/config";

export const env = createEnv({
  server: {
    NODE_ENV: z
      .enum(["development", "test", "production"])
      .default("development"),
    DATABASE_URL: z.string().min(1),
    DATABASE_NAME: z.string().min(1),
  },
});

// drizzle.config.ts
import { env } from "@/lib/env.mjs";
import { defineConfig } from "drizzle-kit";

export default defineConfig({
  schema: "./src/lib/db/schema",
  dialect: "mysql",
  dbCredentials: {
    url: (env.DATABASE_URL as string) ?? "",
  },
});

Expected behavior

It should sync between the database and the schema without any problem

Environment & setup

development environment i guess

@Dadangdut33 Dadangdut33 added the bug Something isn't working label May 13, 2024
@AndriiSherman
Copy link
Member

This should be fixed in drizzle-kit@0.21.3. If the issue persists, feel free to reopen it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants