mirror of
https://github.com/bitwarden/server.git
synced 2025-05-29 07:14:50 -05:00
[PM-19282] Update SsoUser ExternalId column size to 300 (#5750)
* [PM-19282] Update SsoUser ExternalId column size to 300 * [PM-19282] Add migration to update SsoUser ExternalId column size to 300 for MySQL, PostgreSQL, and SQLite * [PM-19282] Update SsoUser ExternalId column size conditionally based on existing schema * Bumped date on migration script name
This commit is contained in:
parent
f3e637cf2d
commit
fe0c14e803
@ -8,7 +8,7 @@ public class SsoUser : ITableObject<long>
|
||||
public long Id { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public Guid? OrganizationId { get; set; }
|
||||
[MaxLength(50)]
|
||||
[MaxLength(300)]
|
||||
public string ExternalId { get; set; }
|
||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
@Id BIGINT OUTPUT,
|
||||
@UserId UNIQUEIDENTIFIER,
|
||||
@OrganizationId UNIQUEIDENTIFIER,
|
||||
@ExternalId NVARCHAR(50),
|
||||
@ExternalId NVARCHAR(300),
|
||||
@CreationDate DATETIME2(7)
|
||||
AS
|
||||
BEGIN
|
||||
|
@ -2,7 +2,7 @@
|
||||
@Id BIGINT OUTPUT,
|
||||
@UserId UNIQUEIDENTIFIER,
|
||||
@OrganizationId UNIQUEIDENTIFIER,
|
||||
@ExternalId NVARCHAR(50),
|
||||
@ExternalId NVARCHAR(300),
|
||||
@CreationDate DATETIME2(7)
|
||||
AS
|
||||
BEGIN
|
||||
|
@ -2,7 +2,7 @@
|
||||
[Id] BIGINT IDENTITY (1, 1) NOT NULL,
|
||||
[UserId] UNIQUEIDENTIFIER NOT NULL,
|
||||
[OrganizationId] UNIQUEIDENTIFIER NULL,
|
||||
[ExternalId] NVARCHAR(50) NOT NULL,
|
||||
[ExternalId] NVARCHAR(300) NOT NULL,
|
||||
[CreationDate] DATETIME2 (7) NOT NULL,
|
||||
CONSTRAINT [PK_SsoUser] PRIMARY KEY CLUSTERED ([Id] ASC),
|
||||
CONSTRAINT [FK_SsoUser_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([Id]) ON DELETE CASCADE,
|
||||
|
67
util/Migrator/DbScripts/2025-05-27_00_SsoExternalId.sql
Normal file
67
util/Migrator/DbScripts/2025-05-27_00_SsoExternalId.sql
Normal file
@ -0,0 +1,67 @@
|
||||
IF EXISTS (
|
||||
SELECT 1
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE TABLE_SCHEMA = 'dbo'
|
||||
AND TABLE_NAME = 'SsoUser'
|
||||
AND COLUMN_NAME = 'ExternalId'
|
||||
AND DATA_TYPE = 'nvarchar'
|
||||
AND CHARACTER_MAXIMUM_LENGTH < 300
|
||||
)
|
||||
BEGIN
|
||||
-- Update table ExternalId column size
|
||||
ALTER TABLE [dbo].[SsoUser]
|
||||
ALTER COLUMN [ExternalId] NVARCHAR(300) NOT NULL
|
||||
END
|
||||
GO
|
||||
|
||||
-- Update stored procedures to handle the new ExternalId column size
|
||||
CREATE OR ALTER PROCEDURE [dbo].[SsoUser_Create]
|
||||
@Id BIGINT OUTPUT,
|
||||
@UserId UNIQUEIDENTIFIER,
|
||||
@OrganizationId UNIQUEIDENTIFIER,
|
||||
@ExternalId NVARCHAR(300),
|
||||
@CreationDate DATETIME2(7)
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
INSERT INTO [dbo].[SsoUser]
|
||||
(
|
||||
[UserId],
|
||||
[OrganizationId],
|
||||
[ExternalId],
|
||||
[CreationDate]
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
@UserId,
|
||||
@OrganizationId,
|
||||
@ExternalId,
|
||||
@CreationDate
|
||||
)
|
||||
|
||||
SET @Id = SCOPE_IDENTITY();
|
||||
END
|
||||
GO
|
||||
|
||||
CREATE OR ALTER PROCEDURE [dbo].[SsoUser_Update]
|
||||
@Id BIGINT OUTPUT,
|
||||
@UserId UNIQUEIDENTIFIER,
|
||||
@OrganizationId UNIQUEIDENTIFIER,
|
||||
@ExternalId NVARCHAR(300),
|
||||
@CreationDate DATETIME2(7)
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
UPDATE
|
||||
[dbo].[SsoUser]
|
||||
SET
|
||||
[UserId] = @UserId,
|
||||
[OrganizationId] = @OrganizationId,
|
||||
[ExternalId] = @ExternalId,
|
||||
[CreationDate] = @CreationDate
|
||||
WHERE
|
||||
[Id] = @Id
|
||||
END
|
||||
GO
|
3112
util/MySqlMigrations/Migrations/20250429113731_SsoExternalId.Designer.cs
generated
Normal file
3112
util/MySqlMigrations/Migrations/20250429113731_SsoExternalId.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,43 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Bit.MySqlMigrations.Migrations;
|
||||
|
||||
/// <inheritdoc />
|
||||
public partial class SsoExternalId : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "ExternalId",
|
||||
table: "SsoUser",
|
||||
type: "varchar(300)",
|
||||
maxLength: 300,
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "varchar(50)",
|
||||
oldMaxLength: 50,
|
||||
oldNullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "ExternalId",
|
||||
table: "SsoUser",
|
||||
type: "varchar(50)",
|
||||
maxLength: 50,
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "varchar(300)",
|
||||
oldMaxLength: 300,
|
||||
oldNullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||
}
|
||||
}
|
@ -679,8 +679,8 @@ namespace Bit.MySqlMigrations.Migrations
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("ExternalId")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)");
|
||||
.HasMaxLength(300)
|
||||
.HasColumnType("varchar(300)");
|
||||
|
||||
b.Property<Guid?>("OrganizationId")
|
||||
.HasColumnType("char(36)");
|
||||
|
3118
util/PostgresMigrations/Migrations/20250429113739_SsoExternalId.Designer.cs
generated
Normal file
3118
util/PostgresMigrations/Migrations/20250429113739_SsoExternalId.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,43 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Bit.PostgresMigrations.Migrations;
|
||||
|
||||
/// <inheritdoc />
|
||||
public partial class SsoExternalId : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "ExternalId",
|
||||
table: "SsoUser",
|
||||
type: "character varying(300)",
|
||||
maxLength: 300,
|
||||
nullable: true,
|
||||
collation: "postgresIndetermanisticCollation",
|
||||
oldClrType: typeof(string),
|
||||
oldType: "character varying(50)",
|
||||
oldMaxLength: 50,
|
||||
oldNullable: true,
|
||||
oldCollation: "postgresIndetermanisticCollation");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "ExternalId",
|
||||
table: "SsoUser",
|
||||
type: "character varying(50)",
|
||||
maxLength: 50,
|
||||
nullable: true,
|
||||
collation: "postgresIndetermanisticCollation",
|
||||
oldClrType: typeof(string),
|
||||
oldType: "character varying(300)",
|
||||
oldMaxLength: 300,
|
||||
oldNullable: true,
|
||||
oldCollation: "postgresIndetermanisticCollation");
|
||||
}
|
||||
}
|
@ -682,8 +682,8 @@ namespace Bit.PostgresMigrations.Migrations
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("ExternalId")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("character varying(50)")
|
||||
.HasMaxLength(300)
|
||||
.HasColumnType("character varying(300)")
|
||||
.UseCollation("postgresIndetermanisticCollation");
|
||||
|
||||
b.Property<Guid?>("OrganizationId")
|
||||
|
3101
util/SqliteMigrations/Migrations/20250429113747_SsoExternalId.Designer.cs
generated
Normal file
3101
util/SqliteMigrations/Migrations/20250429113747_SsoExternalId.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,21 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Bit.SqliteMigrations.Migrations;
|
||||
|
||||
/// <inheritdoc />
|
||||
public partial class SsoExternalId : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -668,7 +668,7 @@ namespace Bit.SqliteMigrations.Migrations
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ExternalId")
|
||||
.HasMaxLength(50)
|
||||
.HasMaxLength(300)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid?>("OrganizationId")
|
||||
|
Loading…
x
Reference in New Issue
Block a user