Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
64d026fc
authored
Jun 22, 2023
by
JustSong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: only master node can migrate database
parent
b90b8a9d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
0 deletions
+6
-0
common/constants.go
+3
-0
model/main.go
+3
-0
No files found.
common/constants.go
View file @
64d026fc
package
common
package
common
import
(
import
(
"os"
"sync"
"sync"
"time"
"time"
...
@@ -67,6 +68,8 @@ var PreConsumedQuota = 500
...
@@ -67,6 +68,8 @@ var PreConsumedQuota = 500
var
RootUserEmail
=
""
var
RootUserEmail
=
""
var
IsMasterNode
=
os
.
Getenv
(
"SYNC_FREQUENCY"
)
==
""
const
(
const
(
RoleGuestUser
=
0
RoleGuestUser
=
0
RoleCommonUser
=
1
RoleCommonUser
=
1
...
...
model/main.go
View file @
64d026fc
...
@@ -55,6 +55,9 @@ func InitDB() (err error) {
...
@@ -55,6 +55,9 @@ func InitDB() (err error) {
}
}
if
err
==
nil
{
if
err
==
nil
{
DB
=
db
DB
=
db
if
!
common
.
IsMasterNode
{
return
nil
}
err
:=
db
.
AutoMigrate
(
&
Channel
{})
err
:=
db
.
AutoMigrate
(
&
Channel
{})
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment