gengx
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
CREATE TABLE IF NOT EXISTS media_assets (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
owner_user_id BIGINT UNSIGNED NOT NULL,
|
||||
media_type VARCHAR(20) NOT NULL,
|
||||
storage_provider VARCHAR(20) NOT NULL DEFAULT 'local',
|
||||
bucket VARCHAR(100) NOT NULL DEFAULT '',
|
||||
object_key VARCHAR(500) NOT NULL DEFAULT '',
|
||||
public_url VARCHAR(500) NOT NULL DEFAULT '',
|
||||
mime_type VARCHAR(100) NOT NULL DEFAULT '',
|
||||
file_size BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
width INT UNSIGNED NULL,
|
||||
height INT UNSIGNED NULL,
|
||||
duration_ms INT UNSIGNED NULL,
|
||||
moderation_status TINYINT UNSIGNED NOT NULL DEFAULT 1,
|
||||
status TINYINT UNSIGNED NOT NULL DEFAULT 1,
|
||||
created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
deleted_at DATETIME(3) NULL,
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS posts (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
user_id BIGINT UNSIGNED NOT NULL,
|
||||
content VARCHAR(2000) NOT NULL DEFAULT '',
|
||||
visibility TINYINT UNSIGNED NOT NULL DEFAULT 1,
|
||||
city_code VARCHAR(20) NOT NULL DEFAULT '',
|
||||
location_text VARCHAR(100) NOT NULL DEFAULT '',
|
||||
status TINYINT UNSIGNED NOT NULL DEFAULT 1,
|
||||
moderation_status TINYINT UNSIGNED NOT NULL DEFAULT 1,
|
||||
like_count INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
comment_count INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
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),
|
||||
deleted_at DATETIME(3) NULL,
|
||||
PRIMARY KEY (id),
|
||||
KEY idx_posts_status_created (status, created_at),
|
||||
KEY idx_posts_user_created (user_id, created_at)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS post_media (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
post_id BIGINT UNSIGNED NOT NULL,
|
||||
media_id BIGINT UNSIGNED NULL,
|
||||
media_url VARCHAR(500) NOT NULL DEFAULT '',
|
||||
media_type VARCHAR(20) NOT NULL DEFAULT 'image',
|
||||
sort_order INT NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (id),
|
||||
KEY idx_post_media_post (post_id, sort_order)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS post_likes (
|
||||
post_id BIGINT UNSIGNED NOT NULL,
|
||||
user_id BIGINT UNSIGNED NOT NULL,
|
||||
created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
PRIMARY KEY (post_id, user_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS post_comments (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
post_id BIGINT UNSIGNED NOT NULL,
|
||||
user_id BIGINT UNSIGNED NOT NULL,
|
||||
parent_comment_id BIGINT UNSIGNED NULL,
|
||||
reply_user_id BIGINT UNSIGNED NULL,
|
||||
content VARCHAR(1000) NOT NULL,
|
||||
status TINYINT UNSIGNED NOT NULL DEFAULT 1,
|
||||
moderation_status TINYINT UNSIGNED NOT NULL DEFAULT 1,
|
||||
created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
deleted_at DATETIME(3) NULL,
|
||||
PRIMARY KEY (id),
|
||||
KEY idx_comments_post_created (post_id, created_at)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
Reference in New Issue
Block a user