Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions custom/conf/app.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ NAME = gitea
USER = root
; Use PASSWD = `your password` for quoting if you use special characters in the password.
PASSWD =
; For Postgres, schema to use if different from "public"
SCHEMA =
; For Postgres, either "disable" (default), "require", or "verify-full"
; For MySQL, either "false" (default), "true", or "skip-verify"
SSL_MODE = disable
Expand Down
1 change: 1 addition & 0 deletions docs/content/doc/advanced/config-cheat-sheet.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
- `NAME`: **gitea**: Database name.
- `USER`: **root**: Database username.
- `PASSWD`: **\<empty\>**: Database user password. Use \`your password\` for quoting if you use special characters in the password.
- `SCHEMA`: **\<empty\>**: For PostgreSQL only, schema to use if different from "public".
- `SSL_MODE`: **disable**: For PostgreSQL and MySQL only.
- `CHARSET`: **utf8**: For MySQL only, either "utf8" or "utf8mb4", default is "utf8". NOTICE: for "utf8mb4" you must use MySQL InnoDB > 5.6. Gitea is unable to check this.
- `PATH`: **data/gitea.db**: For SQLite3 only, the database file path.
Expand Down
7 changes: 6 additions & 1 deletion models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,12 @@ func getEngine() (*xorm.Engine, error) {
return nil, err
}

return xorm.NewEngine(setting.Database.Type, connStr)
engine, err := xorm.NewEngine(setting.Database.Type, connStr)
if err != nil {
return nil, err
}
engine.SetSchema(setting.Database.Schema)
return engine, nil
}

// NewTestEngine sets a new test xorm.Engine
Expand Down
1 change: 1 addition & 0 deletions modules/auth/user_form.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type InstallForm struct {
SSLMode string
Charset string `binding:"Required;In(utf8,utf8mb4)"`
DbPath string
DbSchema string

AppName string `binding:"Required" locale:"install.app_name"`
RepoRootPath string `binding:"Required"`
Expand Down
2 changes: 2 additions & 0 deletions modules/setting/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var (
Name string
User string
Passwd string
Schema string
SSLMode string
Path string
LogSQL bool
Expand Down Expand Up @@ -75,6 +76,7 @@ func InitDBConfig() {
if len(Database.Passwd) == 0 {
Database.Passwd = sec.Key("PASSWD").String()
}
Database.Schema = sec.Key("SCHEMA").String()
Database.SSLMode = sec.Key("SSL_MODE").MustString("disable")
Database.Charset = sec.Key("CHARSET").In("utf8", []string{"utf8", "utf8mb4"})
Database.Path = sec.Key("PATH").MustString(filepath.Join(AppDataPath, "gitea.db"))
Expand Down
2 changes: 2 additions & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ user = Username
password = Password
db_name = Database Name
db_helper = Note to MySQL users: please use the InnoDB storage engine and if you use "utf8mb4", your InnoDB version must be greater than 5.6 .
db_schema = Schema
db_schema_helper = Leave blank for database default ("public").
ssl_mode = SSL
charset = Charset
path = Path
Expand Down
3 changes: 3 additions & 0 deletions routers/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func Install(ctx *context.Context) {
form.DbPasswd = setting.Database.Passwd
form.DbName = setting.Database.Name
form.DbPath = setting.Database.Path
form.DbSchema = setting.Database.Schema
form.Charset = setting.Database.Charset

ctx.Data["CurDbOption"] = "MySQL"
Expand Down Expand Up @@ -146,6 +147,7 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
setting.Database.User = form.DbUser
setting.Database.Passwd = form.DbPasswd
setting.Database.Name = form.DbName
setting.Database.Schema = form.DbSchema
setting.Database.SSLMode = form.SSLMode
setting.Database.Charset = form.Charset
setting.Database.Path = form.DbPath
Expand Down Expand Up @@ -266,6 +268,7 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
cfg.Section("database").Key("NAME").SetValue(setting.Database.Name)
cfg.Section("database").Key("USER").SetValue(setting.Database.User)
cfg.Section("database").Key("PASSWD").SetValue(setting.Database.Passwd)
cfg.Section("database").Key("SCHEMA").SetValue(setting.Database.Schema)
cfg.Section("database").Key("SSL_MODE").SetValue(setting.Database.SSLMode)
cfg.Section("database").Key("CHARSET").SetValue(setting.Database.Charset)
cfg.Section("database").Key("PATH").SetValue(setting.Database.Path)
Expand Down
5 changes: 5 additions & 0 deletions templates/install.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
</div>
</div>
</div>
<div class="inline field {{if .Err_DbSetting}}error{{end}}">
<label for="db_schema">{{.i18n.Tr "install.db_schema"}}</label>
<input id="db_schema" name="db_schema" value="{{.db_schema}}">
<span class="help">{{.i18n.Tr "install.db_schema_helper"}}</span>
</div>
</div>

<div id="mysql_settings" class="{{if not (eq .CurDbOption "MySQL")}}hide{{end}}">
Expand Down