Skip to content

Commit

Permalink
drizzle-trpc: post import
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusmarminge committed Sep 11, 2023
1 parent 5e45d86 commit 21af68b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
protectedProcedure,
publicProcedure,
} from "~/server/api/trpc";
import { posts } from "~/server/db/schema";

export const createPost = publicProcedure
.input(z.object({ text: z.string().min(1) }))
Expand Down
10 changes: 6 additions & 4 deletions cli/template/extras/src/server/db/drizzle-schema-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,20 @@ import { type AdapterAccount } from "next-auth/adapters";
*/
export const mysqlTable = mysqlTableCreator((name) => `project1_${name}`);

export const example = mysqlTable(
"example",
export const posts = mysqlTable(
"post",
{
id: bigint("id", { mode: "number" }).primaryKey().autoincrement(),
name: varchar("name", { length: 256 }),
text: varchar("name", { length: 256 }),
createdById: varchar("createdById", { length: 255 }).notNull(),
createdAt: timestamp("created_at")
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updatedAt: timestamp("updatedAt").onUpdateNow(),
},
(example) => ({
nameIndex: uniqueIndex("name_idx").on(example.name),
createdByIdIdx: index("createdById_idx").on(example.createdById),
textIndex: uniqueIndex("text_idx").on(example.text),
})
);

Expand Down

0 comments on commit 21af68b

Please sign in to comment.