forked from BRETT/BRETT
Initial Commit
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
CREATE TABLE `tags` (
|
||||
`id` bigint unsigned AUTO_INCREMENT NOT NULL,
|
||||
`name` varchar(64) NOT NULL,
|
||||
`created_at` timestamp NOT NULL DEFAULT (now()),
|
||||
CONSTRAINT `tags_id` PRIMARY KEY(`id`),
|
||||
CONSTRAINT `tags_name_unique` UNIQUE(`name`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `upload_tags` (
|
||||
`upload_id` varchar(8) NOT NULL,
|
||||
`tag_id` bigint unsigned NOT NULL,
|
||||
CONSTRAINT `upload_tags_upload_id_tag_id_pk` PRIMARY KEY(`upload_id`,`tag_id`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `upload_tags` ADD CONSTRAINT `upload_tags_upload_id_uploads_id_fk` FOREIGN KEY (`upload_id`) REFERENCES `uploads`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `upload_tags` ADD CONSTRAINT `upload_tags_tag_id_tags_id_fk` FOREIGN KEY (`tag_id`) REFERENCES `tags`(`id`) ON DELETE cascade ON UPDATE no action;
|
||||
Reference in New Issue
Block a user