update: move the fk column below id

This commit is contained in:
percyfikri 2024-08-05 20:28:37 +07:00
parent dd712ff061
commit 0c8dbba12c

View File

@ -1,18 +1,14 @@
import { createId } from "@paralleldrive/cuid2"; import { createId } from "@paralleldrive/cuid2";
import { import { pgTable, timestamp, varchar } from "drizzle-orm/pg-core";
pgTable,
timestamp,
varchar,
} from "drizzle-orm/pg-core";
import { aspects } from "./aspects"; import { aspects } from "./aspects";
export const subAspects = pgTable("sub_aspects", { export const subAspects = pgTable("sub_aspects", {
id: varchar("id", { length: 50 }) id: varchar("id", { length: 50 })
.primaryKey() .primaryKey()
.$defaultFn(() => createId()), .$defaultFn(() => createId()),
aspectId: varchar("aspectId").references(() => aspects.id),
name: varchar("name", { length: 255 }).notNull(), name: varchar("name", { length: 255 }).notNull(),
createdAt: timestamp("createdAt", { mode: "date" }).defaultNow(), createdAt: timestamp("createdAt", { mode: "date" }).defaultNow(),
updatedAt: timestamp("updatedAt", { mode: "date" }).defaultNow(), updatedAt: timestamp("updatedAt", { mode: "date" }).defaultNow(),
deletedAt: timestamp("deletedAt", { mode: "date" }), deletedAt: timestamp("deletedAt", { mode: "date" }),
aspectId: varchar("aspectId").references(() => aspects.id)
}); });