forked from goplus/builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(spx-backend): implement Community API
Fixes goplus#920 Signed-off-by: Aofei Sheng <aofei@aofeisheng.com>
- Loading branch information
Showing
1 changed file
with
127 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,130 @@ | ||
SET NAMES utf8mb4; | ||
SET FOREIGN_KEY_CHECKS = 0; | ||
SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
||
-- ---------------------------- | ||
-- Table structure for asset | ||
-- ---------------------------- | ||
DROP TABLE IF EXISTS `asset`; | ||
CREATE TABLE `asset` ( | ||
`id` int NOT NULL AUTO_INCREMENT, | ||
`c_time` datetime NULL DEFAULT NULL, | ||
`u_time` datetime NULL DEFAULT NULL, | ||
`display_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, | ||
`owner` varchar(255) NULL DEFAULT NULL, | ||
`category` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, | ||
`asset_type` int NULL DEFAULT NULL, | ||
`files` json NULL, | ||
`files_hash` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, | ||
`preview` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL, | ||
`click_count` int NULL DEFAULT 0, | ||
`is_public` tinyint NULL DEFAULT NULL, | ||
`status` int NULL DEFAULT NULL, | ||
PRIMARY KEY (`id`) USING BTREE | ||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC; | ||
|
||
-- ---------------------------- | ||
-- | ||
-- Table structure for user | ||
-- | ||
CREATE TABLE `user` ( | ||
`id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, | ||
`c_time` DATETIME NOT NULL, | ||
`u_time` DATETIME NOT NULL, | ||
|
||
`username` TEXT, | ||
`description` TEXT, | ||
|
||
`follower_count` BIGINT, | ||
`following_count` BIGINT, | ||
|
||
`project_count` BIGINT, | ||
`public_project_count` BIGINT, | ||
`liked_project_count` BIGINT, | ||
|
||
UNIQUE KEY `idx_user_username` (`username`) | ||
) CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci; | ||
|
||
-- | ||
-- Table structure for user relationship | ||
-- | ||
CREATE TABLE `user_relationship` ( | ||
`id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, | ||
`c_time` DATETIME NOT NULL, | ||
`u_time` DATETIME NOT NULL, | ||
|
||
`user_id` BIGINT, | ||
`target_user_id` BIGINT, | ||
|
||
`followed_at` DATETIME, | ||
|
||
UNIQUE KEY `idx_user_relationship_user_id_target_user_id` (`user_id`, `target_user_id`) | ||
) CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci; | ||
|
||
-- | ||
-- Table structure for project | ||
-- ---------------------------- | ||
DROP TABLE IF EXISTS `project`; | ||
-- | ||
CREATE TABLE `project` ( | ||
`id` int UNSIGNED NOT NULL AUTO_INCREMENT, | ||
`c_time` datetime NULL DEFAULT NULL, | ||
`u_time` datetime NULL DEFAULT NULL, | ||
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, | ||
`owner` varchar(255) NULL DEFAULT NULL, | ||
`version` int NOT NULL DEFAULT 1, | ||
`files` json NULL, | ||
`is_public` tinyint NULL DEFAULT NULL, | ||
`status` int NULL DEFAULT NULL, | ||
PRIMARY KEY (`id`) USING BTREE | ||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC; | ||
|
||
SET FOREIGN_KEY_CHECKS = 1; | ||
`id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, | ||
`c_time` DATETIME NOT NULL, | ||
`u_time` DATETIME NOT NULL, | ||
|
||
-- TODO: legacy fields, remove after migration | ||
`owner` TEXT, -- TODO: migrate to `owner_id` | ||
|
||
`owner_id` BIGINT, | ||
`remixed_from_release_id` BIGINT, | ||
|
||
`name` TEXT, | ||
`version` INT, | ||
`files` JSON, | ||
`is_public` TINYINT, | ||
`status` TINYINT, | ||
`description` TEXT, | ||
`instructions` TEXT, | ||
`thumbnail` TEXT, | ||
|
||
`view_count` BIGINT, | ||
`like_count` BIGINT, | ||
`release_count` BIGINT, | ||
`remix_count` BIGINT | ||
) CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci; | ||
|
||
-- | ||
-- Table structure for user project relationship | ||
-- | ||
CREATE TABLE `user_project_relationship` ( | ||
`id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, | ||
`c_time` DATETIME NOT NULL, | ||
`u_time` DATETIME NOT NULL, | ||
|
||
`user_id` BIGINT, | ||
`project_id` BIGINT, | ||
|
||
`view_count` BIGINT, | ||
`last_viewed_at` DATETIME, | ||
`liked_at` DATETIME, | ||
|
||
UNIQUE KEY `idx_user_project_relationship_user_id_project_id` (`user_id`, `project_id`) | ||
) CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci; | ||
|
||
-- | ||
-- Table structure for project release | ||
-- | ||
CREATE TABLE `project_release` ( | ||
`id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, | ||
`c_time` DATETIME NOT NULL, | ||
`u_time` DATETIME NOT NULL, | ||
|
||
`project_id` BIGINT, | ||
|
||
`name` TEXT, | ||
`description` TEXT, | ||
`files` JSON, | ||
`thumbnail` TEXT, | ||
|
||
`remix_count` BIGINT, | ||
|
||
UNIQUE KEY `idx_project_release_project_id_name` (`project_id`, `name`) | ||
) CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci; | ||
|
||
-- | ||
-- Table structure for asset | ||
-- | ||
CREATE TABLE `asset` ( | ||
`id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, | ||
`c_time` DATETIME NOT NULL, | ||
`u_time` DATETIME NOT NULL, | ||
|
||
-- TODO: legacy fields, remove after migration | ||
`owner` TEXT, -- TODO: migrate to `owner_id` | ||
|
||
`owner_id` BIGINT, | ||
|
||
`display_name` TEXT, | ||
`category` TEXT, | ||
`asset_type` TINYINT, | ||
`files` JSON, | ||
`files_hash` TEXT, | ||
`preview` TEXT, | ||
`is_public` TINYINT, | ||
`status` TINYINT, | ||
|
||
`click_count` BIGINT | ||
) CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci; |