forked from BRETT/BRETT
Initial Commit
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
CREATE TABLE `comments` (
|
||||
`id` bigint unsigned AUTO_INCREMENT NOT NULL,
|
||||
`upload_id` bigint unsigned NOT NULL,
|
||||
`user_id` bigint unsigned NOT NULL,
|
||||
`content` text NOT NULL,
|
||||
`created_at` timestamp NOT NULL DEFAULT (now()),
|
||||
CONSTRAINT `comments_id` PRIMARY KEY(`id`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `sessions` (
|
||||
`id` varchar(64) NOT NULL,
|
||||
`user_id` bigint unsigned NOT NULL,
|
||||
`expires_at` timestamp NOT NULL,
|
||||
`created_at` timestamp NOT NULL DEFAULT (now()),
|
||||
CONSTRAINT `sessions_id` PRIMARY KEY(`id`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `uploads` (
|
||||
`id` bigint unsigned AUTO_INCREMENT NOT NULL,
|
||||
`user_id` bigint unsigned NOT NULL,
|
||||
`type` enum('image','video') NOT NULL,
|
||||
`file_name` varchar(255) NOT NULL,
|
||||
`original_name` varchar(255) NOT NULL,
|
||||
`mime_type` varchar(100) NOT NULL,
|
||||
`size` bigint unsigned NOT NULL,
|
||||
`title` varchar(255),
|
||||
`created_at` timestamp NOT NULL DEFAULT (now()),
|
||||
CONSTRAINT `uploads_id` PRIMARY KEY(`id`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `users` MODIFY COLUMN `name` varchar(50) NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE `users` MODIFY COLUMN `email` varchar(255);--> statement-breakpoint
|
||||
ALTER TABLE `users` ADD CONSTRAINT `users_name_unique` UNIQUE(`name`);--> statement-breakpoint
|
||||
ALTER TABLE `comments` ADD CONSTRAINT `comments_upload_id_uploads_id_fk` FOREIGN KEY (`upload_id`) REFERENCES `uploads`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `comments` ADD CONSTRAINT `comments_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `sessions` ADD CONSTRAINT `sessions_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `uploads` ADD CONSTRAINT `uploads_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;
|
||||
Reference in New Issue
Block a user