drizzle-team / drizzle-team/drizzle-orm
[BUG]: "migrate" command fails when schema already exists: Failed query CREATE SCHEMA "example"
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Report hasn't been filed before.
- [x] I have verified that the bug I'm about to report hasn't been filed before.
### What version of `drizzle-orm` are you using?
Beta 11
### What version of `drizzle-kit` are you using?
Beta 11
### Other packages
_No response_
### Describe the Bug
I'm running Drizzle with a self-hosted Supabase DB, where I have created schema "example" in advance and made my DB user the owner of it. I then run `drizzle-kit migrate` and get the following error: `Failed query CREATE SCHEMA "example"`. It's unsurprising that this command would fail, since the schema already exists. This should either have `IF NOT EXISTS` or there should be a config option to prevent creating the schema.
My config:
```ts
export default defineConfig({
out: "./server/db/drizzle",
schema: "./server/db/schema",
schemaFilter: ["example"],
migrations: { schema: "example" },
dialect: "postgresql",
dbCredentials: { url: process.env.DATABASE_URL },
casing: "snake_case",
strict: true,
});
```
I have checked this is not a connection issue, since `drizzle-kit push` runs just fine.
Contributor guide
Assessment
This issue has not been assessed yet.