-
Notifications
You must be signed in to change notification settings - Fork 9
/
schema.ts
43 lines (39 loc) · 953 Bytes
/
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
import type { InferModel } from "drizzle-orm";
import {
integer,
sqliteTable,
text,
uniqueIndex,
} from "drizzle-orm/sqlite-core";
export const users = sqliteTable(
"users",
{
id: integer("id").primaryKey({
autoIncrement: true,
}),
email: text("email").notNull(),
password: text("password"),
avatar: text("avatar"),
name: text("name"),
},
(users) => ({
emailIdx: uniqueIndex("emailIdx").on(users.email),
})
);
export type User = InferModel<typeof users>;
export type NewUser = InferModel<typeof users, "insert">;
export const teams = sqliteTable("teams", {
id: integer("id").primaryKey({
autoIncrement: true,
}),
name: text("name").notNull(),
avatar: text("avatar"),
});
export const usersToTeams = sqliteTable("usersToTeams", {
userId: integer("userId")
.notNull()
.references(() => users.id),
teamId: integer("teamId")
.notNull()
.references(() => teams.id),
});