-
Notifications
You must be signed in to change notification settings - Fork 5k
Description
- Gogs version (or commit ref): 0.11.79
- Git version: Not applicable
- Operating system: Debian 9 (Arm)
- Database (replace
[ ]
with[x]
):- PostgreSQL
- MySQL
- MSSQL
- SQLite
- Can you reproduce the bug at https://try.gogs.io:
- Yes: provide example URL
- No: explain why
- Log gist (usually found in
log/gogs.log
):
I'm trying to restore my gogs database and repositories from my old system using a SQLite database to my new system using an MySQL 8.0.14 database.
During restore i get the following error:
2019/01/27 15:39:31 [ERROR] [...ogs/models/models.go:371 ImportDatabase()] Failed to reset 'created_unix': Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'release SET created_unix=? WHERE id=?' at line 1
I've been searching for the reason for this error and i have found it, in the lines 372 and 379 of the file 'models/models.go' back tics are missing around the table name.
During restore the script tries to update fields in the table with the name 'restore', but as the term 'restore' also seems to be a reserved command this fails if you just state: UPDATE restore WHERE ....
If you change this to UPDATE `restore` WHERE ....
it is solved and the restore executes normally.
So change line 372 from:
if _, err = x.Exec("UPDATE "+rawTableName+" SET created_unix=? WHERE id=?", meta["CreatedUnix"], meta["ID"]); err != nil {
to
if _, err = x.Exec("UPDATE `"+rawTableName+"` SET created_unix=? WHERE id=?", meta["CreatedUnix"], meta["ID"]); err != nil {
And also the same for line 379.
Thanks for the great product!
Klaas Eenkhoorn