mirror of
https://github.com/bitwarden/server.git
synced 2025-07-15 22:57:44 -05:00
PM-23030 adding migration script (#6009)
* PM-23030 adding migration script * PM-23030 fixing store procedure sql file * PM-23030 fixing syntax error * PM-23030 fixing migration * PM-23030 fixing sql script * PM-23030 fixing migration order * PM_23030 fixing migrations * PM-23030 fixing migration script validation error * PM-23030 fixing migration * PM-23030 trying to fix validation error * PM-23030 fixing migration script * PM-23030 updating sql scripts to change data type * PM-23030 adding report key to organization application * PM-23030 adding report key migration scripts * PM-23030 adding migration scripts * PM-23030 changing key column name
This commit is contained in:
@ -12,6 +12,7 @@ public class OrganizationApplication : ITableObject<Guid>, IRevisable
|
||||
public string Applications { get; set; } = string.Empty;
|
||||
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
|
||||
public DateTime RevisionDate { get; set; } = DateTime.UtcNow;
|
||||
public string ContentEncryptionKey { get; set; } = string.Empty;
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
|
@ -13,6 +13,8 @@ public class OrganizationReport : ITableObject<Guid>
|
||||
public string ReportData { get; set; } = string.Empty;
|
||||
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public string ContentEncryptionKey { get; set; } = string.Empty;
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
|
@ -3,7 +3,8 @@ CREATE PROCEDURE [dbo].[OrganizationApplication_Create]
|
||||
@OrganizationId UNIQUEIDENTIFIER,
|
||||
@Applications NVARCHAR(MAX),
|
||||
@CreationDate DATETIME2(7),
|
||||
@RevisionDate DATETIME2(7)
|
||||
@RevisionDate DATETIME2(7),
|
||||
@ContentEncryptionKey VARCHAR(MAX)
|
||||
AS
|
||||
SET NOCOUNT ON;
|
||||
|
||||
@ -13,7 +14,8 @@ AS
|
||||
[OrganizationId],
|
||||
[Applications],
|
||||
[CreationDate],
|
||||
[RevisionDate]
|
||||
[RevisionDate],
|
||||
[ContentEncryptionKey]
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
@ -21,5 +23,6 @@ AS
|
||||
@OrganizationId,
|
||||
@Applications,
|
||||
@CreationDate,
|
||||
@RevisionDate
|
||||
@RevisionDate,
|
||||
@ContentEncryptionKey
|
||||
);
|
||||
|
@ -3,7 +3,8 @@ CREATE PROCEDURE [dbo].[OrganizationReport_Create]
|
||||
@OrganizationId UNIQUEIDENTIFIER,
|
||||
@Date DATETIME2(7),
|
||||
@ReportData NVARCHAR(MAX),
|
||||
@CreationDate DATETIME2(7)
|
||||
@CreationDate DATETIME2(7),
|
||||
@ContentEncryptionKey VARCHAR(MAX)
|
||||
AS
|
||||
SET NOCOUNT ON;
|
||||
|
||||
@ -12,12 +13,14 @@ AS
|
||||
[OrganizationId],
|
||||
[Date],
|
||||
[ReportData],
|
||||
[CreationDate]
|
||||
[CreationDate],
|
||||
[ContentEncryptionKey]
|
||||
)
|
||||
VALUES (
|
||||
@Id,
|
||||
@OrganizationId,
|
||||
@Date,
|
||||
@ReportData,
|
||||
@CreationDate
|
||||
@CreationDate,
|
||||
@ContentEncryptionKey
|
||||
);
|
||||
|
@ -4,9 +4,10 @@ CREATE TABLE [dbo].[OrganizationApplication] (
|
||||
[Applications] NVARCHAR(MAX) NOT NULL,
|
||||
[CreationDate] DATETIME2 (7) NOT NULL,
|
||||
[RevisionDate] DATETIME2 (7) NOT NULL,
|
||||
[ContentEncryptionKey] VARCHAR(MAX) NOT NULL,
|
||||
CONSTRAINT [PK_OrganizationApplication] PRIMARY KEY CLUSTERED ([Id] ASC),
|
||||
CONSTRAINT [FK_OrganizationApplication_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id])
|
||||
);
|
||||
);
|
||||
GO
|
||||
|
||||
CREATE NONCLUSTERED INDEX [IX_OrganizationApplication_OrganizationId]
|
||||
|
@ -4,9 +4,10 @@ CREATE TABLE [dbo].[OrganizationReport] (
|
||||
[Date] DATETIME2 (7) NOT NULL,
|
||||
[ReportData] NVARCHAR(MAX) NOT NULL,
|
||||
[CreationDate] DATETIME2 (7) NOT NULL,
|
||||
[ContentEncryptionKey] VARCHAR(MAX) NOT NULL,
|
||||
CONSTRAINT [PK_OrganizationReport] PRIMARY KEY CLUSTERED ([Id] ASC),
|
||||
CONSTRAINT [FK_OrganizationReport_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id])
|
||||
);
|
||||
);
|
||||
GO
|
||||
|
||||
CREATE NONCLUSTERED INDEX [IX_OrganizationReport_OrganizationId]
|
||||
|
@ -0,0 +1,44 @@
|
||||
IF COL_LENGTH('[dbo].[OrganizationReport]', 'ContentEncryptionKey') IS NULL
|
||||
BEGIN
|
||||
ALTER TABLE [dbo].[OrganizationReport]
|
||||
ADD [ContentEncryptionKey] VARCHAR(MAX) NOT NULL;
|
||||
END
|
||||
GO
|
||||
|
||||
CREATE OR ALTER VIEW [dbo].[OrganizationReportView]
|
||||
AS
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[OrganizationReport]
|
||||
GO
|
||||
|
||||
CREATE OR ALTER PROCEDURE [dbo].[OrganizationReport_Create]
|
||||
@Id UNIQUEIDENTIFIER OUTPUT,
|
||||
@OrganizationId UNIQUEIDENTIFIER,
|
||||
@Date DATETIME2(7),
|
||||
@ReportData NVARCHAR(MAX),
|
||||
@CreationDate DATETIME2(7),
|
||||
@ContentEncryptionKey VARCHAR(MAX)
|
||||
AS
|
||||
SET NOCOUNT ON;
|
||||
|
||||
INSERT INTO [dbo].[OrganizationReport]
|
||||
(
|
||||
[Id],
|
||||
[OrganizationId],
|
||||
[Date],
|
||||
[ReportData],
|
||||
[CreationDate],
|
||||
[ContentEncryptionKey]
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
@Id,
|
||||
@OrganizationId,
|
||||
@Date,
|
||||
@ReportData,
|
||||
@CreationDate,
|
||||
@ContentEncryptionKey
|
||||
);
|
||||
GO
|
@ -0,0 +1,44 @@
|
||||
IF COL_LENGTH('[dbo].[OrganizationApplication]', 'ContentEncryptionKey') IS NULL
|
||||
BEGIN
|
||||
ALTER TABLE [dbo].[OrganizationApplication]
|
||||
ADD [ContentEncryptionKey] VARCHAR(MAX) NOT NULL;
|
||||
END
|
||||
GO
|
||||
|
||||
CREATE OR ALTER VIEW [dbo].[OrganizationApplicationView]
|
||||
AS
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[OrganizationApplication]
|
||||
GO
|
||||
|
||||
CREATE OR ALTER PROCEDURE [dbo].[OrganizationApplication_Create]
|
||||
@Id UNIQUEIDENTIFIER OUTPUT,
|
||||
@OrganizationId UNIQUEIDENTIFIER,
|
||||
@Applications NVARCHAR(MAX),
|
||||
@CreationDate DATETIME2(7),
|
||||
@RevisionDate DATETIME2(7),
|
||||
@ContentEncryptionKey VARCHAR(MAX)
|
||||
AS
|
||||
SET NOCOUNT ON;
|
||||
|
||||
INSERT INTO [dbo].[OrganizationApplication]
|
||||
(
|
||||
[Id],
|
||||
[OrganizationId],
|
||||
[Applications],
|
||||
[CreationDate],
|
||||
[RevisionDate],
|
||||
[ContentEncryptionKey]
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
@Id,
|
||||
@OrganizationId,
|
||||
@Applications,
|
||||
@CreationDate,
|
||||
@RevisionDate,
|
||||
@ContentEncryptionKey
|
||||
);
|
||||
GO
|
3263
util/MySqlMigrations/Migrations/20250702155123_2025-06-26_00_AlterOrganizationReport.sql.Designer.cs
generated
Normal file
3263
util/MySqlMigrations/Migrations/20250702155123_2025-06-26_00_AlterOrganizationReport.sql.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,39 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Bit.MySqlMigrations.Migrations;
|
||||
|
||||
/// <inheritdoc />
|
||||
public partial class _20250626_00_AlterOrganizationReportsql : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "ContentEncryptionKey",
|
||||
table: "OrganizationReport",
|
||||
type: "longtext",
|
||||
nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "ContentEncryptionKey",
|
||||
table: "OrganizationApplication",
|
||||
type: "longtext",
|
||||
nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ContentEncryptionKey",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ContentEncryptionKey",
|
||||
table: "OrganizationApplication");
|
||||
}
|
||||
}
|
3263
util/MySqlMigrations/Migrations/20250702155151_2025-07-01_00_AlterOrganizationApplication.sql.Designer.cs
generated
Normal file
3263
util/MySqlMigrations/Migrations/20250702155151_2025-07-01_00_AlterOrganizationApplication.sql.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.MySqlMigrations.Migrations;
|
||||
|
||||
/// <inheritdoc />
|
||||
public partial class _20250701_00_AlterOrganizationApplicationsql : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -979,6 +979,10 @@ namespace Bit.MySqlMigrations.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("ContentEncryptionKey")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
@ -1004,6 +1008,10 @@ namespace Bit.MySqlMigrations.Migrations
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("ContentEncryptionKey")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
|
3269
util/PostgresMigrations/Migrations/20250702155127_2025-06-26_00_AlterOrganizationReport.sql.Designer.cs
generated
Normal file
3269
util/PostgresMigrations/Migrations/20250702155127_2025-06-26_00_AlterOrganizationReport.sql.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,39 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Bit.PostgresMigrations.Migrations;
|
||||
|
||||
/// <inheritdoc />
|
||||
public partial class _20250626_00_AlterOrganizationReportsql : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "ContentEncryptionKey",
|
||||
table: "OrganizationReport",
|
||||
type: "text",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "ContentEncryptionKey",
|
||||
table: "OrganizationApplication",
|
||||
type: "text",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ContentEncryptionKey",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ContentEncryptionKey",
|
||||
table: "OrganizationApplication");
|
||||
}
|
||||
}
|
3269
util/PostgresMigrations/Migrations/20250702155155_2025-07-01_00_AlterOrganizationApplication.sql.Designer.cs
generated
Normal file
3269
util/PostgresMigrations/Migrations/20250702155155_2025-07-01_00_AlterOrganizationApplication.sql.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.PostgresMigrations.Migrations;
|
||||
|
||||
/// <inheritdoc />
|
||||
public partial class _20250701_00_AlterOrganizationApplicationsql : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -984,6 +984,10 @@ namespace Bit.PostgresMigrations.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ContentEncryptionKey")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
@ -1009,6 +1013,10 @@ namespace Bit.PostgresMigrations.Migrations
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("ContentEncryptionKey")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
|
3252
util/SqliteMigrations/Migrations/20250702155118_2025-06-26_00_AlterOrganizationReport.sql.Designer.cs
generated
Normal file
3252
util/SqliteMigrations/Migrations/20250702155118_2025-06-26_00_AlterOrganizationReport.sql.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,39 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Bit.SqliteMigrations.Migrations;
|
||||
|
||||
/// <inheritdoc />
|
||||
public partial class _20250626_00_AlterOrganizationReportsql : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "ContentEncryptionKey",
|
||||
table: "OrganizationReport",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "ContentEncryptionKey",
|
||||
table: "OrganizationApplication",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ContentEncryptionKey",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ContentEncryptionKey",
|
||||
table: "OrganizationApplication");
|
||||
}
|
||||
}
|
3252
util/SqliteMigrations/Migrations/20250702155159_2025-07-01_00_AlterOrganizationApplication.sql.Designer.cs
generated
Normal file
3252
util/SqliteMigrations/Migrations/20250702155159_2025-07-01_00_AlterOrganizationApplication.sql.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 _20250701_00_AlterOrganizationApplicationsql : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -968,6 +968,10 @@ namespace Bit.SqliteMigrations.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ContentEncryptionKey")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
@ -993,6 +997,10 @@ namespace Bit.SqliteMigrations.Migrations
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ContentEncryptionKey")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
|
Reference in New Issue
Block a user