Files
mengyastore/mengyastore-backend-go/init.sql

29 lines
1.2 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.
-- ============================================================
-- 萌芽小店 · 数据库初始化脚本
--
-- 用途:创建数据库与用户,表结构由后端 GORM AutoMigrate 自动创建。
-- 使用 root 或有 GRANT 权限的账号执行本脚本:
-- mysql -u root -p < init.sql
-- ============================================================
-- 创建数据库utf8mb4 支持 emoji
CREATE DATABASE IF NOT EXISTS `mengyastore`
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;
-- 创建专用用户并授权(按需修改密码)
CREATE USER IF NOT EXISTS 'mengyastore'@'%' IDENTIFIED BY 'mengyastore';
GRANT ALL PRIVILEGES ON `mengyastore`.* TO 'mengyastore'@'%';
FLUSH PRIVILEGES;
-- ============================================================
-- 说明:
-- 后端首次启动时会自动通过 GORM AutoMigrate 创建以下表:
-- products - 商品信息
-- product_codes - 商品发货码
-- orders - 订单记录
-- site_settings - 站点 KV 配置adminToken、SMTP 等)
-- wishlists - 用户收藏夹
-- chat_messages - 聊天消息
-- ============================================================