edgahan
edgahan
DTDrizzle Team
Created by edgahan on 5/29/2023 in #help
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
3 replies