mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 15:42:48 -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:
@ -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",
|
||||
|
Reference in New Issue
Block a user