mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 07:36:14 -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:
@ -0,0 +1,175 @@
|
||||
-- Table
|
||||
IF OBJECT_ID('[dbo].[ClientOrganizationMigrationRecord]') IS NULL
|
||||
BEGIN
|
||||
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])
|
||||
);
|
||||
END
|
||||
GO
|
||||
|
||||
-- View
|
||||
CREATE OR AlTER VIEW [dbo].[ClientOrganizationMigrationRecordView]
|
||||
AS
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[ClientOrganizationMigrationRecord]
|
||||
GO
|
||||
|
||||
-- Stored Procedures: Create
|
||||
CREATE OR ALTER 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
|
||||
GO
|
||||
|
||||
-- Stored Procedures: DeleteById
|
||||
CREATE OR ALTER PROCEDURE [dbo].[ClientOrganizationMigrationRecord_DeleteById]
|
||||
@Id UNIQUEIDENTIFIER
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
DELETE
|
||||
FROM
|
||||
[dbo].[ClientOrganizationMigrationRecord]
|
||||
WHERE
|
||||
[Id] = @Id
|
||||
END
|
||||
GO
|
||||
|
||||
-- Stored Procedures: ReadById
|
||||
CREATE OR ALTER PROCEDURE [dbo].[ClientOrganizationMigrationRecord_ReadById]
|
||||
@Id UNIQUEIDENTIFIER
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[ClientOrganizationMigrationRecordView]
|
||||
WHERE
|
||||
[Id] = @Id
|
||||
END
|
||||
GO
|
||||
|
||||
-- Stored Procedures: ReadByOrganizationId
|
||||
CREATE OR ALTER PROCEDURE [dbo].[ClientOrganizationMigrationRecord_ReadByOrganizationId]
|
||||
@OrganizationId UNIQUEIDENTIFIER
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[ClientOrganizationMigrationRecordView]
|
||||
WHERE
|
||||
[OrganizationId] = @OrganizationId
|
||||
END
|
||||
GO
|
||||
|
||||
-- Stored Procedures: ReadByProviderId
|
||||
CREATE OR ALTER PROCEDURE [dbo].[ClientOrganizationMigrationRecord_ReadByProviderId]
|
||||
@ProviderId UNIQUEIDENTIFIER
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[ClientOrganizationMigrationRecordView]
|
||||
WHERE
|
||||
[ProviderId] = @ProviderId
|
||||
END
|
||||
GO
|
||||
|
||||
-- Stored Procedures: Update
|
||||
CREATE OR ALTER 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
|
||||
GO
|
Reference in New Issue
Block a user