mirror of
https://github.com/documize/community.git
synced 2025-07-19 21:29:42 +02:00
mark follower instances with prefix of "-" on the db username
This commit is contained in:
parent
a6873f807c
commit
66dfc8c6ca
4 changed files with 659 additions and 724 deletions
|
@ -50,8 +50,16 @@ func init() {
|
|||
var err error
|
||||
|
||||
environment.GetString(&connectionString, "db", true,
|
||||
`"username:password@protocol(hostname:port)/databasename" for example "fred:bloggs@tcp(localhost:3306)/documize"`,
|
||||
`'username:password@protocol(hostname:port)/databasename" for example "fred:bloggs@tcp(localhost:3306)/documize", or if a follower instance "-fred:bloggs@tcp(localhost:3306)/documize"`,
|
||||
func(*string, string) bool {
|
||||
isLeader := true
|
||||
followerPrefix := "-"
|
||||
if strings.HasPrefix(connectionString, followerPrefix) {
|
||||
isLeader = false
|
||||
connectionString = strings.TrimPrefix(connectionString, followerPrefix)
|
||||
log.Info("This is a follower instance, no DB schema updates will be performed")
|
||||
}
|
||||
|
||||
Db, err = sqlx.Open("mysql", stdConn(connectionString))
|
||||
|
||||
if err != nil {
|
||||
|
@ -73,7 +81,7 @@ func init() {
|
|||
// go into setup mode if required
|
||||
if web.SiteMode != web.SiteModeOffline {
|
||||
if database.Check(Db, connectionString) {
|
||||
if err := database.Migrate(true /* the config table exists */); err != nil {
|
||||
if err := database.Migrate(true /* the config table exists */, isLeader); err != nil {
|
||||
log.Error("Unable to run database migration: ", err)
|
||||
os.Exit(2)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue