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
9cd256fc
authored
Mar 12, 2024
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: drop idx_channels_key on start
parent
90117f70
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
0 deletions
+5
-0
common/database.go
+1
-0
model/main.go
+4
-0
No files found.
common/database.go
View file @
9cd256fc
...
...
@@ -2,5 +2,6 @@ package common
var
UsingSQLite
=
false
var
UsingPostgreSQL
=
false
var
UsingMySQL
=
false
var
SQLitePath
=
"one-api.db?_busy_timeout=5000"
model/main.go
View file @
9cd256fc
...
...
@@ -62,6 +62,7 @@ func chooseDB() (*gorm.DB, error) {
dsn
+=
"?parseTime=true"
}
}
common
.
UsingMySQL
=
true
return
gorm
.
Open
(
mysql
.
Open
(
dsn
),
&
gorm
.
Config
{
PrepareStmt
:
true
,
// precompile SQL
})
...
...
@@ -92,6 +93,9 @@ func InitDB() (err error) {
if
!
common
.
IsMasterNode
{
return
nil
}
if
common
.
UsingMySQL
{
_
,
_
=
sqlDB
.
Exec
(
"DROP INDEX idx_channels_key ON channels;"
)
// TODO: delete this line when most users have upgraded
}
common
.
SysLog
(
"database migration started"
)
err
=
db
.
AutoMigrate
(
&
Channel
{})
if
err
!=
nil
{
...
...
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