importing into schema.ts file

Hi, I am using turborepo and I have defined my schema in packages/schema/user.ts and in my main API application apps/api/schema.ts I import the user schema. I believe I have everything setup correctly in terms of package.json setup. My problem is that when using running migrations only tables explicitly defined in schema.ts seem to work.
import {
users as _users,
} from "@company/schema";

// I tried an explicit export here, just to be sure
export const users = _users;

export const workingUsers = pgTable("users", {
id: serial("id").primaryKey(),
name: text("name").notNull(),
email: text("email").notNull(),
role: text("role", { enum: ["admin", "user"] }).notNull(),
createdAt: timestamp("created_at").notNull().defaultNow(),
});

// Both of these seem to log the same thing, but only workingUsers works to generate a .sql file
console.log(users);
console.log(workingUsers);
import {
users as _users,
} from "@company/schema";

// I tried an explicit export here, just to be sure
export const users = _users;

export const workingUsers = pgTable("users", {
id: serial("id").primaryKey(),
name: text("name").notNull(),
email: text("email").notNull(),
role: text("role", { enum: ["admin", "user"] }).notNull(),
createdAt: timestamp("created_at").notNull().defaultNow(),
});

// Both of these seem to log the same thing, but only workingUsers works to generate a .sql file
console.log(users);
console.log(workingUsers);
(The above is just an example I've been trying with other tables, etc) Any help appreciated. The drizzle.config.ts lives in the API
2 Replies
edgahan
edgahanOP2y ago
@Dan Kochetov This has fixed my issue, now my schema.ts file simply has export * from "@company/schema"; which is defined in my schema package (in turborepo) <root>/packages/schema/index.ts
Want results from more Discord servers?
Add your server