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

ALTER TABLE and CREATE INDEX statements do not add schema to table name. #40

Closed
erwinkn opened this issue Apr 28, 2023 · 2 comments
Closed

Comments

@erwinkn
Copy link

erwinkn commented Apr 28, 2023

Reproduction:

  1. Define the following schema:
import { integer, pgSchema, serial, text, uniqueIndex } from "drizzle-orm/pg-core";

export const mySchema = pgSchema("my_schema");

export const table1 = mySchema.table(
  "table1",
  {
    id: serial("id").primaryKey(),
    text: text("text").notNull(),
  },
  (table1) => {
    return {
      uniqueIdx: uniqueIndex().on(table1.text),
    };
  }
);

export const table2 = mySchema.table("table2", {
  id: serial("id").primaryKey(),
  fk: integer("fk").references(() => table1.id),
});
  1. Run drizzle-kit generate:pg
  2. The ALTER TABLE statement for the foreign key and the CREATE UNIQUE INDEX statement reference table1 and table2 without appending the schema name.

Expected behavior
All table references in the generated migration include the schema name.

Package versions
drizzle-orm: 0.25.3
drizzle-kit: 0.17.6

@AdditionAddict
Copy link

AdditionAddict commented Apr 28, 2023

Commenting to track, facing same issue

Duplicate of #18

@AndriiSherman
Copy link
Member

Fixed in drizzle-kit@0.18.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants