File size: 473 Bytes
062a991
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
CREATE TABLE `follows` (
	`user_id` text NOT NULL,
	`target_user_id` text NOT NULL,
	`created_at` integer DEFAULT (unixepoch()) NOT NULL,
	PRIMARY KEY(`user_id`, `target_user_id`),
	FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade,
	FOREIGN KEY (`target_user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE INDEX `follows_target_idx` ON `follows` (`target_user_id`,`created_at`);