Restore database MSSQL fails (IDENTITY_INSERT)
Open
Nobody has claimed this yet.
💊 bug
🗄 database
- Dominant language
- Go
- Stars
- 47.8k
- Forks
- 5.1k
- Avg merge
- 7h 23m
- Merged PRs (30d)
- 5
Description
- Gogs version (or commit ref): 0.11.4
- Git version: 2.8.2.windows.1
- Operating system: Windows Server 2012 R2
- Database (use
[x]):- PostgreSQL
- MySQL
- MSSQL
- SQLite
- Can you reproduce the bug at https://try.gogs.io:
- Yes (provide example URL)
- No
- Not relevant
- Log gist (usually found in
log/gogs.log):
Description
When restoring a database backup (from SQLite) to a MSSQL server the following error is thrown:
gogs.exe restore --database-only --config=conf/app.ini --from="gogs-backup-1491558618.zip"
2017/04/07 14:18:49 [ INFO] Restore backup from: gogs-backup-1491558618.zip
2017/04/07 14:18:49 [FATAL] Fail to import database: fail to insert strcut: mssql: Cannot insert explicit value for identity column in table 'user' when IDENTITY_INSERT is set to OFF.
When in MSSQL you want to insert rows into a table including their identifier (primary key), you need to run the sql command as follow:
SET IDENTITY_INSERT [table] ON
-- execute insert query here
SET IDENTITY_INSERT [table] OFF
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the gogs restore --database-only command and reproduce the SQLite-to-MSSQL database import using the provided backup scenario. Trace the database restore path until the insert fails, then verify that restoring rows with their identifiers completes without the MSSQL IDENTITY_INSERT error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sql, sqlite
- Domain
- database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100