diff options
| author | Bertrand Yuan <bert.yuan@outlook.com> | 2025-12-15 23:48:10 +0800 |
|---|---|---|
| committer | Bertrand Yuan <bert.yuan@outlook.com> | 2025-12-15 23:48:10 +0800 |
| commit | 5b7ccf0b671e2999b62befc729a3e517a0433728 (patch) | |
| tree | 8bf476dc7c75914c221042546840dc76267366df /src/server/db/schema/comments.ts | |
initial commit -- the front-end prototype
The initial code is base on Anirudh's work.
More to see at:
https://github.com/techwithanirudh/shadcn-blog
Therefore, the code in this commit is under MIT license.
Diffstat (limited to 'src/server/db/schema/comments.ts')
| -rw-r--r-- | src/server/db/schema/comments.ts | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/server/db/schema/comments.ts b/src/server/db/schema/comments.ts new file mode 100644 index 0000000..9c0626b --- /dev/null +++ b/src/server/db/schema/comments.ts @@ -0,0 +1,43 @@ +import { + boolean, + index, + integer, + json, + primaryKey, + serial, + timestamp, + varchar, +} from 'drizzle-orm/pg-core'; +import { pgTableCreator } from 'drizzle-orm/pg-core'; + +const createTable = pgTableCreator((name) => `blog_${name}`); + +export const roles = createTable('roles', { + userId: varchar('userId', { length: 256 }).primaryKey(), + name: varchar('name', { length: 256 }).notNull(), + canDelete: boolean('canDelete').notNull(), +}); + +export const comments = createTable('comments', { + id: serial('id').primaryKey().notNull(), + page: varchar('page', { length: 256 }).notNull(), + thread: integer('thread'), + author: varchar('author', { length: 256 }).notNull(), + content: json('content').notNull(), + timestamp: timestamp('timestamp', { withTimezone: true }) + .defaultNow() + .notNull(), +}); + +export const rates = createTable( + 'rates', + { + userId: varchar('userId', { length: 256 }).notNull(), + commentId: integer('commentId').notNull(), + like: boolean('like').notNull(), + }, + (table) => [ + primaryKey({ columns: [table.userId, table.commentId] }), + index('comment_idx').on(table.commentId), + ], +); |
