mirror of
https://github.com/casdoor/casdoor.git
synced 2025-09-07 02:20:28 +08:00
fix: Add a configuration that can set the table prefix. There is no prefix by default (#432)
* fix: Add a configuration that can set the table prefix. There is no prefix by default * fix: Add a configuration that can set the table prefix. There is no prefix by default
This commit is contained in:
@@ -6,6 +6,7 @@ copyrequestbody = true
|
|||||||
driverName = mysql
|
driverName = mysql
|
||||||
dataSourceName = root:123456@tcp(localhost:3306)/
|
dataSourceName = root:123456@tcp(localhost:3306)/
|
||||||
dbName = casdoor
|
dbName = casdoor
|
||||||
|
tableNamePrefix=
|
||||||
showSql = false
|
showSql = false
|
||||||
redisEndpoint =
|
redisEndpoint =
|
||||||
defaultStorageProvider =
|
defaultStorageProvider =
|
||||||
|
@@ -17,6 +17,7 @@ package object
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"xorm.io/core"
|
||||||
|
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
"github.com/casbin/casdoor/conf"
|
"github.com/casbin/casdoor/conf"
|
||||||
@@ -113,6 +114,10 @@ func (a *Adapter) createTable() {
|
|||||||
showSql, _ := beego.AppConfig.Bool("showSql")
|
showSql, _ := beego.AppConfig.Bool("showSql")
|
||||||
a.Engine.ShowSQL(showSql)
|
a.Engine.ShowSQL(showSql)
|
||||||
|
|
||||||
|
tableNamePrefix := beego.AppConfig.String("tableNamePrefix")
|
||||||
|
tbMapper := core.NewPrefixMapper(core.SnakeMapper{}, tableNamePrefix)
|
||||||
|
a.Engine.SetTableMapper(tbMapper)
|
||||||
|
|
||||||
err := a.Engine.Sync2(new(Organization))
|
err := a.Engine.Sync2(new(Organization))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
Reference in New Issue
Block a user