I wonder I don't get reply_to_id in my tables after I migrate and push

export const Comment = pgTable(
"comments",
{
id: serial("id").primaryKey(),
content: text("content").notNull(),
postId: integer("post_id").references(() => Post.id),
authorId: integer("author_id").references(() => Profile.id),
createdAt: timestamp("created_at").notNull().defaultNow(),
updatedAt: timestamp("updated_at").notNull().defaultNow(),
},
(t) => [index("reply_to_id").on(t.id)]
);
export const Comment = pgTable(
"comments",
{
id: serial("id").primaryKey(),
content: text("content").notNull(),
postId: integer("post_id").references(() => Post.id),
authorId: integer("author_id").references(() => Profile.id),
createdAt: timestamp("created_at").notNull().defaultNow(),
updatedAt: timestamp("updated_at").notNull().defaultNow(),
},
(t) => [index("reply_to_id").on(t.id)]
);
No description
No description
1 Reply
neal
nealOP4d ago
it works now with this
import {
AnyPgColumn,// this needs to avoid type ERROR
integer,
pgTable,
serial,
text,
timestamp,
} from "drizzle-orm/pg-core";


export const Comment = pgTable("comments", {
id: serial("id").primaryKey(),
content: text("content").notNull(),
postId: integer("post_id").references(() => Post.id),
authorId: integer("author_id").references(() => Profile.id),
createdAt: timestamp("created_at").notNull().defaultNow(),
updatedAt: timestamp("updated_at").notNull().defaultNow(),
replyToId: integer("reply_to_id").references((): AnyPgColumn => Comment.id),
});
import {
AnyPgColumn,// this needs to avoid type ERROR
integer,
pgTable,
serial,
text,
timestamp,
} from "drizzle-orm/pg-core";


export const Comment = pgTable("comments", {
id: serial("id").primaryKey(),
content: text("content").notNull(),
postId: integer("post_id").references(() => Post.id),
authorId: integer("author_id").references(() => Profile.id),
createdAt: timestamp("created_at").notNull().defaultNow(),
updatedAt: timestamp("updated_at").notNull().defaultNow(),
replyToId: integer("reply_to_id").references((): AnyPgColumn => Comment.id),
});

Did you find this page helpful?