bugfix:PostgreSQL initdb (#1953)

* bugfix:postgresql增加显示指定template

---------

Co-authored-by: PiexlMax(奇淼 <165128580+pixelmaxQm@users.noreply.github.com>
This commit is contained in:
Qing Liang 2024-12-08 15:43:54 +08:00 committed by GitHub
parent f2fa601e0b
commit ae183d7c97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 20 additions and 7 deletions

View File

@ -15,6 +15,7 @@ type InitDB struct {
Password string `json:"password"` // 数据库密码 Password string `json:"password"` // 数据库密码
DBName string `json:"dbName" binding:"required"` // 数据库名 DBName string `json:"dbName" binding:"required"` // 数据库名
DBPath string `json:"dbPath"` // sqlite数据库文件路径 DBPath string `json:"dbPath"` // sqlite数据库文件路径
Template string `json:"template"` // postgresql指定template
} }
// MysqlEmptyDsn msyql 空数据库 建库链接 // MysqlEmptyDsn msyql 空数据库 建库链接

View File

@ -54,7 +54,12 @@ func (h PgsqlInitHandler) EnsureDB(ctx context.Context, conf *request.InitDB) (n
} // 如果没有数据库名, 则跳出初始化数据 } // 如果没有数据库名, 则跳出初始化数据
dsn := conf.PgsqlEmptyDsn() dsn := conf.PgsqlEmptyDsn()
createSql := fmt.Sprintf("CREATE DATABASE %s;", c.Dbname) var createSql string
if conf.Template != "" {
createSql = fmt.Sprintf("CREATE DATABASE %s WITH TEMPLATE %s;", c.Dbname, conf.Template)
} else {
createSql = fmt.Sprintf("CREATE DATABASE %s;", c.Dbname)
}
if err = createDatabase(dsn, "pgx", createSql); err != nil { if err = createDatabase(dsn, "pgx", createSql); err != nil {
return nil, err return nil, err
} // 创建数据库 } // 创建数据库

View File

@ -111,6 +111,12 @@
placeholder="请输入sqlite数据库文件存放路径" placeholder="请输入sqlite数据库文件存放路径"
/> />
</el-form-item> </el-form-item>
<el-form-item v-if="form.dbType === 'pgsql'" label="template">
<el-input
v-model="form.template"
placeholder="请输入postgresql指定template"
/>
</el-form-item>
<el-form-item> <el-form-item>
<div style="text-align: right"> <div style="text-align: right">
<el-button type="primary" @click="onSubmit">立即初始化</el-button> <el-button type="primary" @click="onSubmit">立即初始化</el-button>
@ -192,7 +198,8 @@
userName: 'postgres', userName: 'postgres',
password: '', password: '',
dbName: 'gva', dbName: 'gva',
dbPath: '' dbPath: '',
template: 'template0'
}) })
break break
case 'oracle': case 'oracle':

View File

@ -9,7 +9,7 @@
> >
<template #prefix> <template #prefix>
<el-icon> <el-icon>
<component :is="value" /> <component v-if="value" :is="value" />
</el-icon> </el-icon>
</template> </template>
<el-option <el-option
@ -21,7 +21,7 @@
> >
<span class="gva-icon" style="padding: 3px 0 0" :class="item.label"> <span class="gva-icon" style="padding: 3px 0 0" :class="item.label">
<el-icon> <el-icon>
<component :is="item.label" /> <component v-if="item.label" :is="item.label" />
</el-icon> </el-icon>
</span> </span>
<span style="text-align: left">{{ item.key }}</span> <span style="text-align: left">{{ item.key }}</span>

View File

@ -704,7 +704,7 @@
<el-upload <el-upload
class="flex items-center" class="flex items-center"
:before-upload="importJson" :before-upload="importJson"
show-file-list="false" :show-file-list="false"
accept=".json" accept=".json"
> >
<el-button type="primary" class="mx-2" :disabled="isAdd" <el-button type="primary" class="mx-2" :disabled="isAdd"

View File

@ -310,8 +310,8 @@
<el-form-item label="字符长度"> <el-form-item label="字符长度">
<el-input-number <el-input-number
v-model="config.captcha['key-long']" v-model="config.captcha['key-long']"
min="4" :min="4"
max="6" :max="6"
/> />
</el-form-item> </el-form-item>
<el-form-item label="图片宽度"> <el-form-item label="图片宽度">