diff options
Diffstat (limited to 'models')
-rw-r--r-- | models/models.go | 9 | ||||
-rw-r--r-- | models/models_tidb.go | 16 |
2 files changed, 25 insertions, 0 deletions
diff --git a/models/models.go b/models/models.go index b446dcde16..be5f335115 100644 --- a/models/models.go +++ b/models/models.go @@ -72,6 +72,7 @@ var ( } EnableSQLite3 bool + EnableTidb bool ) func init() { @@ -143,6 +144,14 @@ func getEngine() (*xorm.Engine, error) { return nil, fmt.Errorf("Fail to create directories: %v", err) } cnnstr = "file:" + DbCfg.Path + "?cache=shared&mode=rwc" + case "tidb": + if !EnableTidb { + return nil, fmt.Errorf("Unknown database type: %s", DbCfg.Type) + } + if err := os.MkdirAll(path.Dir(DbCfg.Path), os.ModePerm); err != nil { + return nil, fmt.Errorf("Fail to create directories: %v", err) + } + cnnstr = "goleveldb://" + DbCfg.Path default: return nil, fmt.Errorf("Unknown database type: %s", DbCfg.Type) } diff --git a/models/models_tidb.go b/models/models_tidb.go new file mode 100644 index 0000000000..20d9819706 --- /dev/null +++ b/models/models_tidb.go @@ -0,0 +1,16 @@ +// +build tidb + +// Copyright 2015 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package models + +import ( + _ "github.com/go-xorm/tidb" + _ "github.com/pingcap/tidb" +) + +func init() { + EnableTidb = true +} |