WebsiteBench / tasks /linkedin /environment /reference /clone /drizzle /0004_member_follows.sql
AgPerry's picture
Add files using upload-large-folder tool
062a991 verified
Raw History Blame Contribute Delete
473 Bytes
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`);