feat: 完善广场功能

This commit is contained in:
2026-04-26 19:17:15 +08:00
parent 3e8e2353f0
commit eff52f6063
16 changed files with 833 additions and 23 deletions
@@ -0,0 +1,21 @@
CREATE TABLE `plaza_posts` (
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`image_generation_id` BIGINT UNSIGNED NOT NULL,
`user_id` INT NOT NULL,
`status` ENUM('PUBLIC', 'HIDDEN', 'REMOVED') NOT NULL DEFAULT 'PUBLIC',
`published_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`hidden_at` DATETIME(3) NULL,
`removed_at` DATETIME(3) NULL,
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`updated_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
PRIMARY KEY (`id`),
UNIQUE INDEX `plaza_posts_image_generation_id_key` (`image_generation_id`),
INDEX `plaza_posts_status_published_at_idx` (`status`, `published_at`),
INDEX `plaza_posts_user_id_published_at_idx` (`user_id`, `published_at`),
CONSTRAINT `plaza_posts_image_generation_id_fkey`
FOREIGN KEY (`image_generation_id`) REFERENCES `image_generations` (`id`)
ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `plaza_posts_user_id_fkey`
FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;