1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-07 02:52:50 -05:00

[AC-2551] Consolidated Billing Migration (#4616)

* Move existing Billing SQL files into dbo folder

I noticed that every other team had a nested dbo folder under their team folder while Billing did not. This change replicates that.

* Add SQL files for ClientOrganizationMigrationRecord table

* Add SQL Server migration for ClientOrganizationMigrationRecord table

* Add ClientOrganizationMigrationRecord entity and repository interface

* Add ClientOrganizationMigrationRecord Dapper repository

* Add ClientOrganizationMigrationRecord EF repository

* Add EF migrations for ClientOrganizationMigrationRecord table

* Implement migration process

* Wire up new Admin tool to migrate providers

* Run dotnet format

* Updated coupon and credit application per product request

* AC-3057-3058: Fix expiration date and enabled from webhook processing

* Run dotnet format

* AC-3059: Fix assigned seats during migration

* Updated AllocatedSeats in the case plan already exists

* Update migration scripts to reflect current date
This commit is contained in:
Alex Morask
2024-10-04 10:55:00 -04:00
committed by GitHub
parent 738febf031
commit 0496085c39
63 changed files with 10418 additions and 3 deletions

View File

@ -0,0 +1,45 @@
CREATE PROCEDURE [dbo].[ClientOrganizationMigrationRecord_Create]
@Id UNIQUEIDENTIFIER OUTPUT,
@OrganizationId UNIQUEIDENTIFIER,
@ProviderId UNIQUEIDENTIFIER,
@PlanType TINYINT,
@Seats SMALLINT,
@MaxStorageGb SMALLINT,
@GatewayCustomerId VARCHAR(50),
@GatewaySubscriptionId VARCHAR(50),
@ExpirationDate DATETIME2(7),
@MaxAutoscaleSeats INT,
@Status TINYINT
AS
BEGIN
SET NOCOUNT ON
INSERT INTO [dbo].[ClientOrganizationMigrationRecord]
(
[Id],
[OrganizationId],
[ProviderId],
[PlanType],
[Seats],
[MaxStorageGb],
[GatewayCustomerId],
[GatewaySubscriptionId],
[ExpirationDate],
[MaxAutoscaleSeats],
[Status]
)
VALUES
(
@Id,
@OrganizationId,
@ProviderId,
@PlanType,
@Seats,
@MaxStorageGb,
@GatewayCustomerId,
@GatewaySubscriptionId,
@ExpirationDate,
@MaxAutoscaleSeats,
@Status
)
END

View File

@ -0,0 +1,12 @@
CREATE PROCEDURE [dbo].[ClientOrganizationMigrationRecord_DeleteById]
@Id UNIQUEIDENTIFIER
AS
BEGIN
SET NOCOUNT ON
DELETE
FROM
[dbo].[ClientOrganizationMigrationRecord]
WHERE
[Id] = @Id
END

View File

@ -0,0 +1,13 @@
CREATE PROCEDURE [dbo].[ClientOrganizationMigrationRecord_ReadById]
@Id UNIQUEIDENTIFIER
AS
BEGIN
SET NOCOUNT ON
SELECT
*
FROM
[dbo].[ClientOrganizationMigrationRecordView]
WHERE
[Id] = @Id
END

View File

@ -0,0 +1,13 @@
CREATE PROCEDURE [dbo].[ClientOrganizationMigrationRecord_ReadByOrganizationId]
@OrganizationId UNIQUEIDENTIFIER
AS
BEGIN
SET NOCOUNT ON
SELECT
*
FROM
[dbo].[ClientOrganizationMigrationRecordView]
WHERE
[OrganizationId] = @OrganizationId
END

View File

@ -0,0 +1,13 @@
CREATE PROCEDURE [dbo].[ClientOrganizationMigrationRecord_ReadByProviderId]
@ProviderId UNIQUEIDENTIFIER
AS
BEGIN
SET NOCOUNT ON
SELECT
*
FROM
[dbo].[ClientOrganizationMigrationRecordView]
WHERE
[ProviderId] = @ProviderId
END

View File

@ -0,0 +1,32 @@
CREATE PROCEDURE [dbo].[ClientOrganizationMigrationRecord_Update]
@Id UNIQUEIDENTIFIER OUTPUT,
@OrganizationId UNIQUEIDENTIFIER,
@ProviderId UNIQUEIDENTIFIER,
@PlanType TINYINT,
@Seats SMALLINT,
@MaxStorageGb SMALLINT,
@GatewayCustomerId VARCHAR(50),
@GatewaySubscriptionId VARCHAR(50),
@ExpirationDate DATETIME2(7),
@MaxAutoscaleSeats INT,
@Status TINYINT
AS
BEGIN
SET NOCOUNT ON
UPDATE
[dbo].[ClientOrganizationMigrationRecord]
SET
[OrganizationId] = @OrganizationId,
[ProviderId] = @ProviderId,
[PlanType] = @PlanType,
[Seats] = @Seats,
[MaxStorageGb] = @MaxStorageGb,
[GatewayCustomerId] = @GatewayCustomerId,
[GatewaySubscriptionId] = @GatewaySubscriptionId,
[ExpirationDate] = @ExpirationDate,
[MaxAutoscaleSeats] = @MaxAutoscaleSeats,
[Status] = @Status
WHERE
[Id] = @Id
END

View File

@ -0,0 +1,15 @@
CREATE TABLE [dbo].[ClientOrganizationMigrationRecord] (
[Id] UNIQUEIDENTIFIER NOT NULL,
[OrganizationId] UNIQUEIDENTIFIER NOT NULL,
[ProviderId] UNIQUEIDENTIFIER NOT NULL,
[PlanType] TINYINT NOT NULL,
[Seats] SMALLINT NOT NULL,
[MaxStorageGb] SMALLINT NULL,
[GatewayCustomerId] VARCHAR(50) NOT NULL,
[GatewaySubscriptionId] VARCHAR(50) NOT NULL,
[ExpirationDate] DATETIME2(7) NULL,
[MaxAutoscaleSeats] INT NULL,
[Status] TINYINT NOT NULL,
CONSTRAINT [PK_ClientOrganizationMigrationRecord] PRIMARY KEY CLUSTERED ([Id] ASC),
CONSTRAINT [PK_OrganizationIdProviderId] UNIQUE ([ProviderId], [OrganizationId])
);

View File

@ -0,0 +1,6 @@
CREATE VIEW [dbo].[ClientOrganizationMigrationRecordView]
AS
SELECT
*
FROM
[dbo].[ClientOrganizationMigrationRecord]

View File

@ -19,4 +19,7 @@
<SuppressTSqlWarnings>71502</SuppressTSqlWarnings>
</Build>
</ItemGroup>
<ItemGroup>
<Folder Include="Billing\dbo\" />
</ItemGroup>
</Project>