Files
whale-town-end-v2/src/core/db/player_assets/create-player-assets-tables.sql
2026-07-22 13:41:28 +08:00

30 lines
1.7 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
CREATE TABLE IF NOT EXISTS `user_assets` (
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`user_id` BIGINT NOT NULL COMMENT '关联users.id',
`asset_type` VARCHAR(40) NOT NULL COMMENT '资产类型skin/room_decor/item/badge等',
`asset_id` VARCHAR(100) NOT NULL COMMENT '资产ID',
`source` VARCHAR(50) NOT NULL DEFAULT 'system' COMMENT '发放来源',
`metadata` JSON NULL COMMENT '资产扩展数据',
`acquired_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '获得时间',
PRIMARY KEY (`id`),
UNIQUE KEY `idx_user_assets_user_type_asset_unique` (`user_id`, `asset_type`, `asset_id`),
KEY `idx_user_assets_user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS `room_decor_placements` (
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`user_id` BIGINT NOT NULL COMMENT '关联users.id',
`decor_id` VARCHAR(100) NOT NULL COMMENT '房间摆件ID',
`placed` BOOLEAN NOT NULL DEFAULT FALSE COMMENT '是否已摆放',
`position_x` FLOAT NULL COMMENT '房间内X坐标',
`position_y` FLOAT NULL COMMENT '房间内Y坐标',
`scale` FLOAT NOT NULL DEFAULT 1 COMMENT '摆件缩放',
`rotation_degrees` FLOAT NOT NULL DEFAULT 0 COMMENT '摆件旋转角度',
`z_index` INT NOT NULL DEFAULT 0 COMMENT '摆放层级',
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `idx_room_decor_placements_user_decor_unique` (`user_id`, `decor_id`),
KEY `idx_room_decor_placements_user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;