1
0
mirror of https://github.com/bitwarden/server synced 2026-02-28 18:33:51 +00:00

[PM 30100][Server] Subscription Discount Database Infrastructure (#6936)

* Implement the detail Subscription Discount Database Infrastructure

* Change string to string list

* fix lint error

* Create all missing database object definition files

* Regenerate EF migrations with Designer files

The previous migrations were missing .Designer.cs files. This commit:
- Removes the incomplete migration files
- Regenerates all three provider migrations (MySQL, Postgres, SQLite) with proper Designer files
- Updates DatabaseContextModelSnapshot.cs for each provider

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix failing database

* Resolve the lint  warnings

* Resolve the database failure

* Fix the build Lint

* resolve the dbops reviews

* Add the default value

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
cyprain-okeke
2026-02-06 18:24:26 +01:00
committed by GitHub
parent e3008ccb68
commit 67ba9bcca5
32 changed files with 12003 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
CREATE PROCEDURE [dbo].[SubscriptionDiscount_Create]
@Id UNIQUEIDENTIFIER OUTPUT,
@StripeCouponId VARCHAR(50),
@StripeProductIds NVARCHAR(MAX),
@PercentOff DECIMAL(5,2),
@AmountOff BIGINT,
@Currency VARCHAR(10),
@Duration VARCHAR(20),
@DurationInMonths INT,
@Name NVARCHAR(100),
@StartDate DATETIME2(7),
@EndDate DATETIME2(7),
@AudienceType INT,
@CreationDate DATETIME2(7),
@RevisionDate DATETIME2(7)
AS
BEGIN
SET NOCOUNT ON
INSERT INTO [dbo].[SubscriptionDiscount]
(
[Id],
[StripeCouponId],
[StripeProductIds],
[PercentOff],
[AmountOff],
[Currency],
[Duration],
[DurationInMonths],
[Name],
[StartDate],
[EndDate],
[AudienceType],
[CreationDate],
[RevisionDate]
)
VALUES
(
@Id,
@StripeCouponId,
@StripeProductIds,
@PercentOff,
@AmountOff,
@Currency,
@Duration,
@DurationInMonths,
@Name,
@StartDate,
@EndDate,
@AudienceType,
@CreationDate,
@RevisionDate
)
END

View File

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

View File

@@ -0,0 +1,13 @@
CREATE PROCEDURE [dbo].[SubscriptionDiscount_ReadActive]
AS
BEGIN
SET NOCOUNT ON
SELECT
*
FROM
[dbo].[SubscriptionDiscountView]
WHERE
[StartDate] <= GETUTCDATE()
AND [EndDate] >= GETUTCDATE()
END

View File

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

View File

@@ -0,0 +1,13 @@
CREATE PROCEDURE [dbo].[SubscriptionDiscount_ReadByStripeCouponId]
@StripeCouponId VARCHAR(50)
AS
BEGIN
SET NOCOUNT ON
SELECT
*
FROM
[dbo].[SubscriptionDiscountView]
WHERE
[StripeCouponId] = @StripeCouponId
END

View File

@@ -0,0 +1,38 @@
CREATE PROCEDURE [dbo].[SubscriptionDiscount_Update]
@Id UNIQUEIDENTIFIER OUTPUT,
@StripeCouponId VARCHAR(50),
@StripeProductIds NVARCHAR(MAX),
@PercentOff DECIMAL(5,2),
@AmountOff BIGINT,
@Currency VARCHAR(10),
@Duration VARCHAR(20),
@DurationInMonths INT,
@Name NVARCHAR(100),
@StartDate DATETIME2(7),
@EndDate DATETIME2(7),
@AudienceType INT,
@CreationDate DATETIME2(7),
@RevisionDate DATETIME2(7)
AS
BEGIN
SET NOCOUNT ON
UPDATE
[dbo].[SubscriptionDiscount]
SET
[StripeCouponId] = @StripeCouponId,
[StripeProductIds] = @StripeProductIds,
[PercentOff] = @PercentOff,
[AmountOff] = @AmountOff,
[Currency] = @Currency,
[Duration] = @Duration,
[DurationInMonths] = @DurationInMonths,
[Name] = @Name,
[StartDate] = @StartDate,
[EndDate] = @EndDate,
[AudienceType] = @AudienceType,
[CreationDate] = @CreationDate,
[RevisionDate] = @RevisionDate
WHERE
[Id] = @Id
END

View File

@@ -0,0 +1,22 @@
CREATE TABLE [dbo].[SubscriptionDiscount] (
[Id] UNIQUEIDENTIFIER NOT NULL,
[StripeCouponId] VARCHAR (50) NOT NULL,
[StripeProductIds] NVARCHAR (MAX) NULL,
[PercentOff] DECIMAL (5, 2) NULL,
[AmountOff] BIGINT NULL,
[Currency] VARCHAR (10) NULL,
[Duration] VARCHAR (20) NOT NULL,
[DurationInMonths] INT NULL,
[Name] NVARCHAR (100) NULL,
[StartDate] DATETIME2 (7) NOT NULL,
[EndDate] DATETIME2 (7) NOT NULL,
[AudienceType] INT NOT NULL CONSTRAINT [DF_SubscriptionDiscount_AudienceType] DEFAULT (0),
[CreationDate] DATETIME2 (7) NOT NULL,
[RevisionDate] DATETIME2 (7) NOT NULL,
CONSTRAINT [PK_SubscriptionDiscount] PRIMARY KEY CLUSTERED ([Id] ASC),
CONSTRAINT [IX_SubscriptionDiscount_StripeCouponId] UNIQUE NONCLUSTERED ([StripeCouponId] ASC)
);
GO
CREATE NONCLUSTERED INDEX [IX_SubscriptionDiscount_DateRange]
ON [dbo].[SubscriptionDiscount]([StartDate] ASC, [EndDate] ASC);

View File

@@ -0,0 +1,5 @@
CREATE VIEW [dbo].[SubscriptionDiscountView]
AS
SELECT *
FROM
[dbo].[SubscriptionDiscount]