forked from CaliCastle/cali.so
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.ts
55 lines (51 loc) · 1.53 KB
/
schema.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import {
bigint,
datetime,
index,
json,
mysqlTable,
serial,
text,
timestamp,
varchar,
} from 'drizzle-orm/mysql-core'
export const subscribers = mysqlTable('subscribers', {
id: serial('id').primaryKey(),
email: varchar('email', { length: 120 }),
token: varchar('token', { length: 50 }),
subscribedAt: datetime('subscribed_at'),
unsubscribedAt: datetime('unsubscribed_at'),
updatedAt: timestamp('updated_at').defaultNow(),
})
export const newsletters = mysqlTable('newsletters', {
id: serial('id').primaryKey(),
subject: varchar('subject', { length: 200 }),
body: text('body'),
sentAt: datetime('sent_at'),
createdAt: timestamp('created_at').defaultNow(),
updatedAt: timestamp('updated_at').defaultNow(),
})
export const comments = mysqlTable(
'comments',
{
id: serial('id').primaryKey(),
userId: varchar('user_id', { length: 200 }).notNull(),
userInfo: json('user_info'),
postId: varchar('post_id', { length: 100 }).notNull(),
parentId: bigint('parent_id', { mode: 'bigint' }),
body: json('body'),
createdAt: timestamp('created_at').defaultNow(),
updatedAt: timestamp('updated_at').defaultNow(),
},
(table) => ({
postIdx: index('post_idx').on(table.postId),
})
)
export const guestbook = mysqlTable('guestbook', {
id: serial('id').primaryKey(),
userId: varchar('user_id', { length: 200 }).notNull(),
userInfo: json('user_info'),
message: text('message').notNull(),
createdAt: timestamp('created_at').defaultNow(),
updatedAt: timestamp('updated_at').defaultNow(),
})