1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 07:36:14 -05:00

[PM-5519] [PM-5526] [PM-5624] [PM-5600] More Grant SQL fixes (#3668)

* SQLite scripts to apply autoincrementing Id key

* Drop erroneous Id column if created
This commit is contained in:
Matt Bishop
2024-01-16 09:08:55 -05:00
committed by GitHub
parent c12c09897b
commit b97a1a9ed2
6 changed files with 119 additions and 92 deletions

View File

@ -72,7 +72,22 @@ public partial class GrantIdWithIndexes : Migration
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.Sql("ALTER TABLE `Grant` ADD COLUMN `Id` INT AUTO_INCREMENT UNIQUE;");
migrationBuilder.Sql(@"
DROP PROCEDURE IF EXISTS GrantSchemaChange;
CREATE PROCEDURE GrantSchemaChange()
BEGIN
IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Grant' AND COLUMN_NAME = 'Id') THEN
ALTER TABLE `Grant` DROP COLUMN `Id`;
END IF;
ALTER TABLE `Grant` ADD COLUMN `Id` INT AUTO_INCREMENT UNIQUE;
END;
CALL GrantSchemaChange();
DROP PROCEDURE GrantSchemaChange;"
);
migrationBuilder.AddPrimaryKey(
name: "PK_Grant",