Skip to content

Commit

Permalink
refactor: stuffs
Browse files Browse the repository at this point in the history
  • Loading branch information
sadmann7 committed Mar 8, 2024
1 parent aceba75 commit 7cbbbaa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/db/schema.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
import { pgTable } from "@/db/utils"
import { pgEnum, varchar } from "drizzle-orm/pg-core"

import { databasePrefix } from "@/lib/constants"
import { createId } from "@/lib/utils"

/**
* This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same
* database instance for multiple projects.
*
* @see https://orm.drizzle.team/docs/goodies#multi-project-schema
*/

export const statusEnum = pgEnum("shadcn_status", [
export const statusEnum = pgEnum(`${databasePrefix}_status`, [
"todo",
"in-progress",
"done",
"canceled",
])

export const labelEnum = pgEnum("shadcn_label", [
export const labelEnum = pgEnum(`${databasePrefix}_label`, [
"bug",
"feature",
"enhancement",
"documentation",
])

export const priorityEnum = pgEnum("shadcn_priority", ["low", "medium", "high"])
export const priorityEnum = pgEnum(`${databasePrefix}_priority`, [
"low",
"medium",
"high",
])

export const tasks = pgTable("tasks", {
id: varchar("id", { length: 128 })
Expand Down
6 changes: 6 additions & 0 deletions src/db/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@ import { pgTableCreator } from "drizzle-orm/pg-core"

import { databasePrefix } from "@/lib/constants"

/**
* This lets us use the multi-project schema feature of Drizzle ORM. So the same
* database instance can be used for multiple projects.
*
* @see https://orm.drizzle.team/docs/goodies#multi-project-schema
*/
export const pgTable = pgTableCreator((name) => `${databasePrefix}_${name}`)

0 comments on commit 7cbbbaa

Please sign in to comment.