-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.ts
More file actions
49 lines (45 loc) · 1.32 KB
/
schema.ts
File metadata and controls
49 lines (45 loc) · 1.32 KB
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
import {
int,
index,
text,
singlestoreTableCreator,
bigint,
timestamp,
} from "drizzle-orm/singlestore-core";
const createTable = singlestoreTableCreator((name) => `drive_tutorial_${name}`);
export const files_table = createTable(
"files",
{
id: bigint("id", { mode: "number", unsigned: true })
.primaryKey()
.autoincrement(),
ownerId: text("owner_id").notNull(),
name: text("name").notNull(),
url: text("url").notNull(),
size: int("size").notNull(),
parent: bigint("parent", { mode: "number", unsigned: true }).notNull(),
createdAt: timestamp("created_at").notNull().defaultNow(),
},
(table) => [
index("owner_id_index").on(table.ownerId),
index("parent_index").on(table.parent),
],
);
export const folders_table = createTable(
"folders",
{
id: bigint("id", { mode: "number", unsigned: true })
.primaryKey()
.autoincrement(),
ownerId: text("owner_id").notNull(),
name: text("name").notNull(),
parent: bigint("parent", { mode: "number", unsigned: true }),
createdAt: timestamp("created_at").notNull().defaultNow(),
},
(table) => [
index("owner_id_index").on(table.ownerId),
index("parent_index").on(table.parent),
],
);
export type File = typeof files_table.$inferSelect;
export type Folder = typeof folders_table.$inferSelect;