Skip to content

Commit

Permalink
add v0.1.3 changelog and upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
phachon committed Jun 2, 2019
1 parent 7b8cac1 commit e4fab15
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 6 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,26 @@

## v0.1.3 (2018-12)
### Fix Bug & Add Feature
#### 修复bug
1. 修复启动命令不支持绝对路径问题
2. 安装向导页面优化
3. 修复首页快捷链接没有按排序号排序问题
4. 代码 go fmt
5. 更新 copyright
6. 修改系统权限 #55
7. 修复私有文档未授权访问漏洞 #55
8. 修复文档导出漏洞 #66
9. 新建文档可回车提交 #43
10. 修复文档编辑窗口过短问题 #46
11. 安装的最小环境限制 #45
11. 空间名修改后没有更新 #53

#### 新增功能
1. 新增附件上传,附件列表查看,附件删除功能
2. 图片上传分目录存储,可查看图片列表并删除
3. 分页增加每一页数量控制功能
4. 导出文件同时导出附件和图片
5. 下载文件同时下载所有的图片和附件

### Upgrade
1. 下载新版本到部署该项目的根目录
Expand Down
8 changes: 7 additions & 1 deletion app/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ var (

StartTime = int64(0)

RootDir = ""

DocumentAbsDir = ""

MarkdownAbsDir = ""
Expand Down Expand Up @@ -97,7 +99,11 @@ func initConfig() {
beego.BConfig.AppName = beego.AppConfig.String("sys.name")
beego.BConfig.ServerName = beego.AppConfig.String("sys.name")

RootDir, _ := filepath.Abs(filepath.Dir(os.Args[0]))
RootDir, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {
log.Println("init config error: "+err.Error())
os.Exit(1)
}

// set static path
beego.SetStaticPath("/static/", filepath.Join(RootDir, "./static"))
Expand Down
46 changes: 41 additions & 5 deletions app/models/upgrade.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package models

import (
"database/sql"
"errors"
"fmt"
"github.com/astaxie/beego"
"mm-wiki/app/utils"
)
Expand All @@ -26,8 +28,8 @@ var (
func (up *Upgrade) initHandleFunc() {
// v0 ~ v0.1.2
upgradeMap = append(upgradeMap, &upgradeHandle{Version: "v0.1.2", Func: up.v0ToV012})
// v0.1.2 ~ v0.1.8
//upgradeMap = append(upgradeMap, &upgradeHandle{Version: "v0.1.8", Func: up.v012ToV018})
// v0.1.2 ~ v0.1.3
upgradeMap = append(upgradeMap, &upgradeHandle{Version: "v0.1.3", Func: up.v012ToV013})
// v0.1.8 ~ v0.2.1
//upgradeMap = append(upgradeMap, &upgradeHandle{Version: "v0.2.1", Func: up.v018ToV021})
// v0.2.1 ~ v0.2.7
Expand Down Expand Up @@ -98,9 +100,25 @@ func (up *Upgrade) v0ToV012() (err error) {
return
}

// upgrade v0.1.2 ~ v0.1.8
func (up *Upgrade) v012ToV018() error {
return nil
// upgrade v0.1.2 ~ v0.1.3
func (up *Upgrade) v012ToV013() error {

// create attachment table
sql := "DROP TABLE IF EXISTS `mw_attachment`;" +
"CREATE TABLE `mw_attachment` (" +
"`attachment_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '附件 id'," +
"`user_id` int(10) NOT NULL DEFAULT '0' COMMENT '创建用户id'," +
"`document_id` int(10) NOT NULL DEFAULT '0' COMMENT '所属文档id'," +
"`name` varchar(50) NOT NULL DEFAULT '' COMMENT '附件名称'," +
"`path` varchar(100) NOT NULL DEFAULT '' COMMENT '附件路径'," +
"`source` tinyint(1) NOT NULL DEFAULT '0' COMMENT '附件来源, 0 默认是附件 1 图片'," +
"`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间'," +
"`update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间'," +
"PRIMARY KEY (`attachment_id`)," +
"KEY (`document_id`, `source`)" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='附件信息表';"

return up.createTable(sql)
}

// upgrade v0.1.8 ~ v0.2.1
Expand All @@ -118,6 +136,24 @@ func (up *Upgrade) v027ToV033() error {
return nil
}

func (up *Upgrade) createTable(sqlTable string) error {
host := beego.AppConfig.String("db::host")
port, _ := beego.AppConfig.Int("db::port")
user := beego.AppConfig.String("db::user")
pass := beego.AppConfig.String("db::pass")
name := beego.AppConfig.String("db::name")
db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8&multiStatements=true", user, pass, host, port, name))
if err != nil {
return err
}
defer db.Close()
_, err = db.Exec(sqlTable)
if err != nil {
return err
}
return nil
}

func (up *Upgrade) upgradeAfter(version string) (err error) {
// update system version
config, err := ConfigModel.GetConfigByKey(Config_Key_SystemVersion)
Expand Down

0 comments on commit e4fab15

Please sign in to comment.