Skip to content

Commit 18ea426

Browse files
authored
Database Schema and Table Creation (#3)
1 parent c62d97b commit 18ea426

2 files changed

Lines changed: 31 additions & 9 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Tracking progress on key features and tasks for the project.
9494

9595
Just finished up the database connection, next steps:
9696

97-
- [ ] Update schema to show files and folders
98-
- [ ] Manually insert examples
97+
- [x] Update schema to show files and folders
98+
- [x] Manually insert examples
9999
- [ ] Render them in the UI
100100
- [ ] Push and make sure it all works

src/server/db/schema.ts

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,34 @@
11
import {
22
int,
3-
bigint,
3+
index,
44
text,
5-
singlestoreTable,
5+
singlestoreTableCreator,
6+
bigint,
67
} from "drizzle-orm/singlestore-core";
78

8-
export const users = singlestoreTable("users_table", {
9-
id: bigint("id", { mode: "bigint" }).primaryKey().autoincrement(),
10-
name: text("name"),
11-
age: int("age"),
12-
});
9+
const createTable = singlestoreTableCreator((name) => `drive_tutorial_${name}`);
10+
11+
export const files = createTable(
12+
"files",
13+
{
14+
id: bigint("id", { mode: "number", unsigned: true })
15+
.primaryKey()
16+
.autoincrement(),
17+
name: text("name").notNull(),
18+
size: int("size").notNull(),
19+
parent: bigint("parent", { mode: "number", unsigned: true }),
20+
},
21+
(table) => [index("parent_index").on(table.parent)],
22+
);
23+
24+
export const folders = createTable(
25+
"folders",
26+
{
27+
id: bigint("id", { mode: "number", unsigned: true })
28+
.primaryKey()
29+
.autoincrement(),
30+
name: text("name").notNull(),
31+
parent: bigint("parent", { mode: "number", unsigned: true }),
32+
},
33+
(table) => [index("parent_index").on(table.parent)],
34+
);

0 commit comments

Comments
 (0)