Skip to content

Commit 5b98645

Browse files
committed
meow
1 parent 9f4fd34 commit 5b98645

File tree

16 files changed

+1093
-267
lines changed

16 files changed

+1093
-267
lines changed

.github/workflows/db.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,6 @@ jobs:
4444
4545
- name: Initialize Drizzle
4646
run: pnpm run drizzle:dev:init
47+
48+
- name: Seed DB
49+
run: pnpm run drizzle:seed
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
CREATE TABLE `asset` (
2+
`id` text PRIMARY KEY NOT NULL,
3+
`name` text NOT NULL,
4+
`game_id` text NOT NULL,
5+
`category_id` text NOT NULL,
6+
`created_at` integer NOT NULL,
7+
`uploaded_by` text NOT NULL,
8+
`download_count` integer DEFAULT 0 NOT NULL,
9+
`view_count` integer DEFAULT 0 NOT NULL,
10+
`is_suggestive` integer DEFAULT false NOT NULL,
11+
`status` text DEFAULT 'pending' NOT NULL,
12+
`hash` text NOT NULL,
13+
`size` integer NOT NULL,
14+
`extension` text NOT NULL,
15+
FOREIGN KEY (`game_id`) REFERENCES `game`(`id`) ON UPDATE no action ON DELETE cascade,
16+
FOREIGN KEY (`category_id`) REFERENCES `category`(`id`) ON UPDATE no action ON DELETE cascade,
17+
FOREIGN KEY (`uploaded_by`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
18+
);
19+
--> statement-breakpoint
20+
CREATE TABLE `asset_link` (
21+
`id` text PRIMARY KEY NOT NULL,
22+
`asset_id` text NOT NULL,
23+
`to_asset_id` text NOT NULL,
24+
`created_at` integer NOT NULL,
25+
FOREIGN KEY (`asset_id`) REFERENCES `asset`(`id`) ON UPDATE no action ON DELETE cascade,
26+
FOREIGN KEY (`to_asset_id`) REFERENCES `asset`(`id`) ON UPDATE no action ON DELETE cascade
27+
);
28+
--> statement-breakpoint
29+
CREATE TABLE `asset_to_tag` (
30+
`id` text PRIMARY KEY NOT NULL,
31+
`asset_id` text NOT NULL,
32+
`tag_id` text NOT NULL,
33+
FOREIGN KEY (`asset_id`) REFERENCES `asset`(`id`) ON UPDATE no action ON DELETE cascade,
34+
FOREIGN KEY (`tag_id`) REFERENCES `tag`(`id`) ON UPDATE no action ON DELETE cascade
35+
);
36+
--> statement-breakpoint
37+
CREATE TABLE `download_history` (
38+
`id` text PRIMARY KEY NOT NULL,
39+
`user_id` text NOT NULL,
40+
`created_at` integer NOT NULL,
41+
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
42+
);
43+
--> statement-breakpoint
44+
CREATE TABLE `download_history_to_asset` (
45+
`id` text PRIMARY KEY NOT NULL,
46+
`download_history_id` text NOT NULL,
47+
`asset_id` text NOT NULL,
48+
FOREIGN KEY (`download_history_id`) REFERENCES `download_history`(`id`) ON UPDATE no action ON DELETE no action,
49+
FOREIGN KEY (`asset_id`) REFERENCES `asset`(`id`) ON UPDATE no action ON DELETE no action
50+
);
51+
--> statement-breakpoint
52+
CREATE TABLE `saved_asset` (
53+
`id` text PRIMARY KEY NOT NULL,
54+
`user_id` text NOT NULL,
55+
`asset_id` text NOT NULL,
56+
`created_at` integer NOT NULL,
57+
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade,
58+
FOREIGN KEY (`asset_id`) REFERENCES `asset`(`id`) ON UPDATE no action ON DELETE cascade
59+
);
60+
--> statement-breakpoint
61+
CREATE TABLE `tag` (
62+
`id` text PRIMARY KEY NOT NULL,
63+
`name` text NOT NULL,
64+
`slug` text NOT NULL,
65+
`color` text
66+
);
67+
--> statement-breakpoint
68+
CREATE UNIQUE INDEX `tag_slug_unique` ON `tag` (`slug`);--> statement-breakpoint
69+
CREATE TABLE `category` (
70+
`id` text PRIMARY KEY NOT NULL,
71+
`name` text NOT NULL,
72+
`slug` text NOT NULL
73+
);
74+
--> statement-breakpoint
75+
CREATE UNIQUE INDEX `category_slug_unique` ON `category` (`slug`);--> statement-breakpoint
76+
CREATE TABLE `game` (
77+
`id` text PRIMARY KEY NOT NULL,
78+
`slug` text NOT NULL,
79+
`name` text NOT NULL,
80+
`last_updated` integer NOT NULL,
81+
`asset_count` integer DEFAULT 0 NOT NULL
82+
);
83+
--> statement-breakpoint
84+
CREATE UNIQUE INDEX `game_slug_unique` ON `game` (`slug`);--> statement-breakpoint
85+
CREATE TABLE `account` (
86+
`id` text PRIMARY KEY NOT NULL,
87+
`account_id` text NOT NULL,
88+
`provider_id` text NOT NULL,
89+
`user_id` text NOT NULL,
90+
`access_token` text,
91+
`refresh_token` text,
92+
`id_token` text,
93+
`access_token_expires_at` integer,
94+
`refresh_token_expires_at` integer,
95+
`scope` text,
96+
`password` text,
97+
`created_at` integer NOT NULL,
98+
`updated_at` integer NOT NULL,
99+
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
100+
);
101+
--> statement-breakpoint
102+
CREATE TABLE `session` (
103+
`id` text PRIMARY KEY NOT NULL,
104+
`expires_at` integer NOT NULL,
105+
`token` text NOT NULL,
106+
`user_id` text NOT NULL,
107+
`ip_address` text,
108+
`user_agent` text,
109+
`created_at` integer NOT NULL,
110+
`updated_at` integer NOT NULL,
111+
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
112+
);
113+
--> statement-breakpoint
114+
CREATE UNIQUE INDEX `session_token_unique` ON `session` (`token`);--> statement-breakpoint
115+
CREATE TABLE `user` (
116+
`id` text PRIMARY KEY NOT NULL,
117+
`name` text NOT NULL,
118+
`username` text,
119+
`email` text NOT NULL,
120+
`email_verified` integer DEFAULT false NOT NULL,
121+
`image` text,
122+
`created_at` integer NOT NULL,
123+
`updated_at` integer NOT NULL,
124+
`role` text DEFAULT 'user' NOT NULL
125+
);
126+
--> statement-breakpoint
127+
CREATE UNIQUE INDEX `user_username_unique` ON `user` (`username`);--> statement-breakpoint
128+
CREATE UNIQUE INDEX `user_email_unique` ON `user` (`email`);--> statement-breakpoint
129+
CREATE TABLE `verification` (
130+
`id` text PRIMARY KEY NOT NULL,
131+
`identifier` text NOT NULL,
132+
`value` text NOT NULL,
133+
`expires_at` integer NOT NULL,
134+
`created_at` integer NOT NULL,
135+
`updated_at` integer NOT NULL
136+
);

0 commit comments

Comments
 (0)