forked from BRETT/BRETT
Initial Commit
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
CREATE TABLE `thread_subscriptions` (
|
||||
`upload_id` varchar(8) NOT NULL,
|
||||
`user_id` bigint unsigned NOT NULL,
|
||||
`enabled` boolean NOT NULL DEFAULT true,
|
||||
`created_at` timestamp NOT NULL DEFAULT (now()),
|
||||
CONSTRAINT `thread_subscriptions_upload_id_user_id_pk` PRIMARY KEY(`upload_id`,`user_id`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `thread_subscriptions` ADD CONSTRAINT `thread_subscriptions_upload_id_uploads_id_fk` FOREIGN KEY (`upload_id`) REFERENCES `uploads`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `thread_subscriptions` ADD CONSTRAINT `thread_subscriptions_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;
|
||||
--> statement-breakpoint
|
||||
INSERT INTO `thread_subscriptions` (`upload_id`, `user_id`)
|
||||
SELECT `id`, `user_id` FROM `uploads`
|
||||
UNION
|
||||
SELECT `upload_id`, `user_id` FROM `comments`
|
||||
UNION
|
||||
SELECT `upload_id`, `user_id` FROM `favorites`
|
||||
UNION
|
||||
SELECT `upload_id`, `user_id` FROM `upload_reactions`;
|
||||
Reference in New Issue
Block a user