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
ac06e9a4
authored
Apr 08, 2025
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: Add CheckSetup function call in main to ensure proper initialization #942
parent
97be874c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
main.go
+3
-0
model/main.go
+1
-2
No files found.
main.go
View file @
ac06e9a4
...
@@ -52,6 +52,9 @@ func main() {
...
@@ -52,6 +52,9 @@ func main() {
if
err
!=
nil
{
if
err
!=
nil
{
common
.
FatalLog
(
"failed to initialize database: "
+
err
.
Error
())
common
.
FatalLog
(
"failed to initialize database: "
+
err
.
Error
())
}
}
model
.
CheckSetup
()
// Initialize SQL Database
// Initialize SQL Database
err
=
model
.
InitLogDB
()
err
=
model
.
InitLogDB
()
if
err
!=
nil
{
if
err
!=
nil
{
...
...
model/main.go
View file @
ac06e9a4
...
@@ -56,7 +56,7 @@ func createRootAccountIfNeed() error {
...
@@ -56,7 +56,7 @@ func createRootAccountIfNeed() error {
return
nil
return
nil
}
}
func
c
heckSetup
()
{
func
C
heckSetup
()
{
setup
:=
GetSetup
()
setup
:=
GetSetup
()
if
setup
==
nil
{
if
setup
==
nil
{
// No setup record exists, check if we have a root user
// No setup record exists, check if we have a root user
...
@@ -244,7 +244,6 @@ func migrateDB() error {
...
@@ -244,7 +244,6 @@ func migrateDB() error {
}
}
err
=
DB
.
AutoMigrate
(
&
Setup
{})
err
=
DB
.
AutoMigrate
(
&
Setup
{})
common
.
SysLog
(
"database migrated"
)
common
.
SysLog
(
"database migrated"
)
checkSetup
()
//err = createRootAccountIfNeed()
//err = createRootAccountIfNeed()
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