Skip to content

Commit 025dc7f

Browse files
authored
feat(sql): 表文件更新 (#2)
* feat(sql): 表文件更新 * chore: GitHub actions 更新 * chore: GitHub actions 更新 * feat(sql): 文件更新 * feat(sql): 短链访问信息表 多余的索引
1 parent 1a80bb7 commit 025dc7f

6 files changed

Lines changed: 84 additions & 103 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ jobs:
1616
- name: Set up Go
1717
uses: actions/setup-go@v6
1818
with:
19-
go-version: '1.20' # 设置 Go 版本为 1.20
19+
go-version: '1.24'
20+
cache: true
2021

2122
- name: Install gf-tool
22-
run: |
23-
wget -O gf https://github.com/gogf/gf/releases/latest/download/gf_$(go env GOOS)_$(go env GOARCH)
24-
chmod +x gf
25-
./gf install -y
26-
rm ./gf
23+
run: wget -O gf https://github.com/gogf/gf/releases/latest/download/gf_$(go env GOOS)_$(go env GOARCH) && chmod +x gf && ./gf install -y && rm ./gf
2724

2825
- name: Build Go application
2926
run: gf build
3027

28+
- name: Output build directory
29+
run: ls
30+
3131
- name: Setup SSH
3232
run: |
3333
mkdir -p ~/.ssh

manifest/deploy/sql/short_url.sql

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
create table short_url
2-
(
3-
id int auto_increment comment '唯一标识,自增长整数'
4-
primary key,
5-
shortUrl varchar(20) not null comment '短链,唯一,不能为空',
6-
rawUrl varchar(500) not null comment '原始 url 不能为空',
7-
expirationTime timestamp null comment '过期时间',
8-
userId varchar(40) null comment '用户id',
9-
created_at timestamp default CURRENT_TIMESTAMP null comment '创建时间,默认为当前时间戳',
10-
title varchar(100) not null comment '短链标题',
11-
group_id int null comment '短链分组id',
12-
constraint shortUrl
13-
unique (shortUrl)
14-
);
1+
CREATE TABLE `short_url` (
2+
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '唯一标识,自增长整数',
3+
`shortUrl` varchar(20) NOT NULL COMMENT '短链,唯一,不能为空',
4+
`rawUrl` varchar(500) NOT NULL COMMENT '原始 url 不能为空',
5+
`expirationTime` timestamp NULL DEFAULT NULL COMMENT '过期时间',
6+
`userId` varchar(40) DEFAULT NULL COMMENT '用户id',
7+
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间,默认为当前时间戳',
8+
`title` varchar(100) NOT NULL COMMENT '短链标题',
9+
`group_id` int(11) DEFAULT NULL COMMENT '短链分组id',
10+
PRIMARY KEY (`id`),
11+
UNIQUE KEY `shortUrl` (`shortUrl`)
12+
) COMMENT '短链列表';
Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
create table short_url_code
2-
(
3-
id int auto_increment comment '唯一标识,自增长整数'
4-
primary key,
5-
code varchar(20) not null comment '短链,唯一,不能为空',
6-
status tinyint(1) not null comment '是否使用',
7-
created_at timestamp default CURRENT_TIMESTAMP null comment '创建时间,默认为当前时间戳',
8-
constraint code
9-
unique (code)
10-
);
11-
1+
CREATE TABLE `short_url_code` (
2+
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '唯一标识,自增长整数',
3+
`code` varchar(20) NOT NULL COMMENT '短链,唯一,不能为空',
4+
`status` tinyint(1) NOT NULL COMMENT '是否使用',
5+
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间,默认为当前时间戳',
6+
PRIMARY KEY (`id`),
7+
UNIQUE KEY `code` (`code`)
8+
) COMMENT '预生成的短链 code';
Lines changed: 31 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,31 @@
1-
-- auto-generated definition
2-
create table short_url_visits
3-
(
4-
id bigint unsigned auto_increment
5-
primary key,
6-
user_id varchar(40) not null comment '用户id',
7-
short_url varchar(20) not null comment '短链,唯一,不能为空',
8-
raw_url varchar(500) not null comment '原始 url 不能为空',
9-
user_agent varchar(255) not null comment '用户代理字符串,存储提供的完整用户代理',
10-
browser_name varchar(50) null comment '浏览器名称',
11-
browser_version varchar(50) null comment '浏览器版本',
12-
device_model varchar(50) null comment '设备型号',
13-
engine_name varchar(50) null comment '浏览器引擎名称',
14-
engine_version varchar(50) null comment '浏览器引擎版本',
15-
os_name varchar(50) null comment '操作系统名称',
16-
os_version varchar(50) null comment '操作系统版本',
17-
ip varchar(45) not null comment 'ip 不能为空',
18-
continent varchar(50) null comment '大洲名称',
19-
continent_code varchar(10) null comment '大洲代码',
20-
country varchar(50) null comment '国家名称',
21-
country_code varchar(10) null comment '国家代码',
22-
region varchar(10) null comment '地区或州的短代码(FIPS或ISO)',
23-
region_name varchar(50) null comment '地区或州名称',
24-
city varchar(50) null comment '城市名称',
25-
district varchar(50) null comment '位置的区(郡)',
26-
lat double null comment '纬度',
27-
lon double null comment '经度',
28-
created_at timestamp default CURRENT_TIMESTAMP null comment '创建时间,默认为当前时间戳',
29-
updated_at timestamp null comment '更新时间',
30-
deleted_at timestamp null comment '删除时间',
31-
constraint id_unique
32-
unique (id)
33-
);
34-
35-
create index idx_short_url_visits_on_created_at
36-
on short_url_visits (created_at);
37-
38-
create index idx_short_url_visits_on_short_url
39-
on short_url_visits (short_url);
40-
1+
CREATE TABLE `short_url_visits` (
2+
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
3+
`user_id` varchar(40) NOT NULL COMMENT '用户id',
4+
`short_url` varchar(20) NOT NULL COMMENT '短链,唯一,不能为空',
5+
`raw_url` varchar(500) NOT NULL COMMENT '原始 url 不能为空',
6+
`user_agent` varchar(255) NOT NULL COMMENT '用户代理字符串,存储提供的完整用户代理',
7+
`browser_name` varchar(50) DEFAULT NULL COMMENT '浏览器名称',
8+
`browser_version` varchar(50) DEFAULT NULL COMMENT '浏览器版本',
9+
`device_model` varchar(50) DEFAULT NULL COMMENT '设备型号',
10+
`engine_name` varchar(50) DEFAULT NULL COMMENT '浏览器引擎名称',
11+
`engine_version` varchar(50) DEFAULT NULL COMMENT '浏览器引擎版本',
12+
`os_name` varchar(50) DEFAULT NULL COMMENT '操作系统名称',
13+
`os_version` varchar(50) DEFAULT NULL COMMENT '操作系统版本',
14+
`ip` varchar(45) NOT NULL COMMENT 'ip 不能为空',
15+
`continent` varchar(50) DEFAULT NULL COMMENT '大洲名称',
16+
`continent_code` varchar(10) DEFAULT NULL COMMENT '大洲代码',
17+
`country` varchar(50) DEFAULT NULL COMMENT '国家名称',
18+
`country_code` varchar(10) DEFAULT NULL COMMENT '国家代码',
19+
`region` varchar(10) DEFAULT NULL COMMENT '地区或州的短代码(FIPS或ISO)',
20+
`region_name` varchar(50) DEFAULT NULL COMMENT '地区或州名称',
21+
`city` varchar(50) DEFAULT NULL COMMENT '城市名称',
22+
`district` varchar(50) DEFAULT NULL COMMENT '位置的区(郡)',
23+
`lat` double DEFAULT NULL COMMENT '纬度',
24+
`lon` double DEFAULT NULL COMMENT '经度',
25+
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间,默认为当前时间戳',
26+
`updated_at` timestamp NULL DEFAULT NULL COMMENT '更新时间',
27+
`deleted_at` timestamp NULL DEFAULT NULL COMMENT '删除时间',
28+
PRIMARY KEY (`id`),
29+
KEY `idx_short_url_visits_on_created_at` (`created_at`),
30+
KEY `idx_short_url_visits_on_short_url` (`short_url`)
31+
) COMMENT '短链访问信息表';

manifest/deploy/sql/user.sql

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1-
create table user
2-
(
3-
id varchar(32) not null comment '唯一标识'
4-
primary key,
5-
email varchar(50) null comment '邮箱,唯一',
6-
wxId varchar(50) null comment '小程序id,唯一',
7-
password varchar(200) null comment '密码, 小程序登录无密码',
8-
nickName varchar(20) not null comment '昵称, 创建默认生成',
9-
accountType varchar(4) default '01' not null comment '账号类型: 01 邮箱 02 小程序',
10-
role varchar(4) default '01' not null comment '角色: 00 admin 01 普通用户 02 vip',
11-
deleted_at timestamp null comment '删除时间',
12-
updated_at timestamp null comment '更新时间',
13-
created_at timestamp default CURRENT_TIMESTAMP null comment '创建时间',
14-
salt varchar(12) not null comment '用户盐值',
15-
avatar varchar(300) null comment '用户头像',
16-
constraint email
17-
unique (email),
18-
constraint wxId
19-
unique (wxId)
20-
);
1+
CREATE TABLE `user`(
2+
`id` varchar(32) NOT NULL COMMENT '唯一标识',
3+
`email` varchar(50) DEFAULT NULL COMMENT '邮箱,唯一',
4+
`password` varchar(200) DEFAULT NULL COMMENT '密码, 小程序登录无密码',
5+
`nickName` varchar(20) NOT NULL COMMENT '昵称, 创建默认生成',
6+
`accountType` varchar(4) NOT NULL DEFAULT '01' COMMENT '账号类型: 01 邮箱 02 小程序',
7+
`role` varchar(4) NOT NULL DEFAULT '01' COMMENT '角色: 00 admin 01 普通用户 02 vip',
8+
`deleted_at` timestamp NULL DEFAULT NULL COMMENT '删除时间',
9+
`updated_at` timestamp NULL DEFAULT NULL COMMENT '更新时间',
10+
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
11+
`salt` varchar(12) DEFAULT NULL COMMENT '用户盐值',
12+
`avatar` varchar(300) DEFAULT NULL COMMENT '用户头像',
13+
PRIMARY KEY (`id`),
14+
UNIQUE KEY `email` (`email`)
15+
) COMMENT '用户表';
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
create table verification_codes
2-
(
3-
id int auto_increment primary key,
4-
email varchar(100) not null comment '邮箱',
5-
type tinyint not null comment '验证码类型: 1注册 2登录 3重置密码',
6-
code varchar(10) not null comment '验证码',
7-
used tinyint(1) default 0 comment '是否已使用: 0未使用 1已使用',
8-
expired_at timestamp not null comment '过期时间',
9-
created_at timestamp default current_timestamp comment '创建时间',
10-
index idx_email_type_created (email, type, created_at),
11-
index idx_expired_at (expired_at)
12-
) comment '邮箱验证码表';
1+
CREATE TABLE `verification_codes` (
2+
`id` int(11) NOT NULL AUTO_INCREMENT,
3+
`email` varchar(100) NOT NULL COMMENT '邮箱',
4+
`type` tinyint(4) DEFAULT '1' COMMENT '验证码类型: 目前只有一种用途',
5+
`CODE` varchar(10) NOT NULL COMMENT '验证码',
6+
`used` tinyint(1) DEFAULT '0' COMMENT '是否已使用: 0未使用 1已使用',
7+
`expired_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '过期时间',
8+
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
9+
PRIMARY KEY (`id`),
10+
KEY `idx_email_type_created` (`email`,`type`,`created_at`),
11+
KEY `idx_expired_at` (`expired_at`)
12+
) COMMENT '邮箱验证码表';

0 commit comments

Comments
 (0)