Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSSQL Restore not working #28470

Open
Drardollan opened this issue Dec 14, 2023 · 1 comment
Open

MSSQL Restore not working #28470

Drardollan opened this issue Dec 14, 2023 · 1 comment
Labels

Comments

@Drardollan
Copy link

Description

Restoring database by using the .sql file created by Gitea dump gives an error:

Msg 8107, Level 16, State 1, Line 12
IDENTITY_INSERT is already ON for table ‘Gitea.dbo.oauth2_application’. Cannot perform SET operation for table ‘oauth2_authorization_code’.

Which is correct, the IDENTITY_INSERT is already to import the oauth2_application table. This should be set to off.

Part of the script generated by the dump command:
/Generated by xorm 2023-12-12 14:06:24, from mssql to mssql/
IF NOT EXISTS (SELECT [name] FROM sys.tables WHERE [name] = ‘[oauth2_application]’ ) CREATE TABLE [oauth2_application] ([id] BIGINT PRIMARY KEY IDENTITY NOT NULL, [uid] BIGINT NULL, [name] NVARCHAR(255) NULL, [client_id] NVARCHAR(255) NULL, [client_secret] NVARCHAR(255) NULL, [confidential_client] BIT DEFAULT 1 NOT NULL, [redirect_uris] NVARCHAR(MAX) NULL, [created_unix] BIGINT NULL, [updated_unix] BIGINT NULL);
SET IDENTITY_INSERT [oauth2_application] ON;
CREATE INDEX [IDX_oauth2_application_created_unix] ON [oauth2_application] ([created_unix]);
CREATE INDEX [IDX_oauth2_application_updated_unix] ON [oauth2_application] ([updated_unix]);
CREATE INDEX [IDX_oauth2_application_uid] ON [oauth2_application] ([uid]);
CREATE UNIQUE INDEX [UQE_oauth2_application_client_id] ON [oauth2_application] ([client_id]);
INSERT INTO [oauth2_application] ([id], [uid], [name], [client_id], [client_secret], [confidential_client], [redirect_uris], [created_unix], [updated_unix])
INSERT INTO [oauth2_application] ([id], [uid], [name], [client_id], [client_secret], [confidential_client], [redirect_uris], [created_unix], [updated_unix])

IF NOT EXISTS (SELECT [name] FROM sys.tables WHERE [name] = ‘[oauth2_authorization_code]’ ) CREATE TABLE [oauth2_authorization_code] ([id] BIGINT PRIMARY KEY IDENTITY NOT NULL, [grant_id] BIGINT NULL, [code] NVARCHAR(255) NULL, [code_challenge] NVARCHAR(255) NULL, [code_challenge_method] NVARCHAR(255) NULL, [redirect_uri] NVARCHAR(255) NULL, [valid_until] BIGINT NULL);
SET IDENTITY_INSERT [oauth2_authorization_code] ON;
CREATE UNIQUE INDEX [UQE_oauth2_authorization_code_code] ON [oauth2_authorization_code] ([code]);
CREATE INDEX [IDX_oauth2_authorization_code_valid_until] ON [oauth2_authorization_code] ([valid_until]);

IF NOT EXISTS (SELECT [name] FROM sys.tables WHERE [name] = ‘[oauth2_grant]’ ) CREATE TABLE [oauth2_grant] ([id] BIGINT PRIMARY KEY IDENTITY NOT NULL, [user_id] BIGINT NULL, [application_id] BIGINT NULL, [counter] BIGINT DEFAULT 1 NOT NULL, [scope] NVARCHAR(MAX) NULL, [nonce] NVARCHAR(MAX) NULL, [created_unix] BIGINT NULL, [updated_unix] BIGINT NULL);
SET IDENTITY_INSERT [oauth2_grant] ON;
CREATE UNIQUE INDEX [UQE_oauth2_grant_user_application] ON [oauth2_grant] ([user_id],[application_id]);
CREATE INDEX [IDX_oauth2_grant_user_id] ON [oauth2_grant] ([user_id]);
CREATE INDEX [IDX_oauth2_grant_application_id] ON [oauth2_grant] ([application_id]);

(I have removed the INSERT values).

I expect the dump to add the needed "SET IDENTITY_INSERT [xxx] OFF;" statements.

Gitea Version

1.21.1

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

I use: "gitea-1.21.1-windows-4.0-amd64.exe", downloaded from the Gitea site.

Database

MSSQL

@Xulunix
Copy link

Xulunix commented Jan 29, 2024

Any updates on this?
Being able to restore a dumped database would be something i consider important

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants