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]: IF NOT EXISTS in Migrations leads to inconsistencies #2356

Open
mothershipper opened this issue May 20, 2024 · 0 comments
Open

[BUG]: IF NOT EXISTS in Migrations leads to inconsistencies #2356

mothershipper opened this issue May 20, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@mothershipper
Copy link

mothershipper commented May 20, 2024

What version of drizzle-orm are you using?

0.30.10

What version of drizzle-kit are you using?

0.21.2

Describe the Bug

When generating postgres migrations, drizzle is adding IF NOT EXISTS to the CREATE statement:

Ex:

CREATE TABLE IF NOT EXISTS "rates" (
	"id" text PRIMARY KEY NOT NULL,
	"created_at" timestamp DEFAULT now() NOT NULL,
	"updated_at" timestamp DEFAULT now() NOT NULL,
	"deleted_at" timestamp,
);

As a result, name collisions on tables do not error, and the migration applies "successfully" despite no changes. This punts detection of the issue further down the line and not during development/deployment.

Expected behavior

I'd expect an error to be thrown and the migration aborted if I have table naming collisions. It's much easier to catch these mistakes early than waiting for errors like "unknown column YYYY in table XXXX" to be thrown from the app at runtime.

Environment & setup

postgres, create two tables with the same name

@mothershipper mothershipper added the bug Something isn't working label May 20, 2024
@AndriiSherman AndriiSherman added enhancement New feature or request and removed bug Something isn't working labels May 22, 2024
@AndriiSherman AndriiSherman self-assigned this May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants