mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 00:52:49 -05:00
[EC-427] Add columns 'Type' and 'BillingPhone' to Provider table
This commit is contained in:
@ -14,8 +14,10 @@ public class Provider : ITableObject<Guid>
|
|||||||
public string BusinessCountry { get; set; }
|
public string BusinessCountry { get; set; }
|
||||||
public string BusinessTaxNumber { get; set; }
|
public string BusinessTaxNumber { get; set; }
|
||||||
public string BillingEmail { get; set; }
|
public string BillingEmail { get; set; }
|
||||||
|
public string BillingPhone { get; set; }
|
||||||
public ProviderStatusType Status { get; set; }
|
public ProviderStatusType Status { get; set; }
|
||||||
public bool UseEvents { get; set; }
|
public bool UseEvents { get; set; }
|
||||||
|
public ProviderType Type { get; set; }
|
||||||
public bool Enabled { get; set; } = true;
|
public bool Enabled { get; set; } = true;
|
||||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
||||||
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;
|
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;
|
||||||
|
7
src/Core/Enums/Provider/ProviderType.cs
Normal file
7
src/Core/Enums/Provider/ProviderType.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace Bit.Core.Enums.Provider;
|
||||||
|
|
||||||
|
public enum ProviderType : byte
|
||||||
|
{
|
||||||
|
Msp = 0,
|
||||||
|
Reseller = 1,
|
||||||
|
}
|
@ -8,7 +8,9 @@
|
|||||||
@BusinessCountry VARCHAR(2),
|
@BusinessCountry VARCHAR(2),
|
||||||
@BusinessTaxNumber NVARCHAR(30),
|
@BusinessTaxNumber NVARCHAR(30),
|
||||||
@BillingEmail NVARCHAR(256),
|
@BillingEmail NVARCHAR(256),
|
||||||
|
@BillingPhone NVARCHAR(50),
|
||||||
@Status TINYINT,
|
@Status TINYINT,
|
||||||
|
@Type TINYINT,
|
||||||
@UseEvents BIT,
|
@UseEvents BIT,
|
||||||
@Enabled BIT,
|
@Enabled BIT,
|
||||||
@CreationDate DATETIME2(7),
|
@CreationDate DATETIME2(7),
|
||||||
@ -28,7 +30,9 @@ BEGIN
|
|||||||
[BusinessCountry],
|
[BusinessCountry],
|
||||||
[BusinessTaxNumber],
|
[BusinessTaxNumber],
|
||||||
[BillingEmail],
|
[BillingEmail],
|
||||||
|
[BillingPhone],
|
||||||
[Status],
|
[Status],
|
||||||
|
[Type],
|
||||||
[UseEvents],
|
[UseEvents],
|
||||||
[Enabled],
|
[Enabled],
|
||||||
[CreationDate],
|
[CreationDate],
|
||||||
@ -45,7 +49,9 @@ BEGIN
|
|||||||
@BusinessCountry,
|
@BusinessCountry,
|
||||||
@BusinessTaxNumber,
|
@BusinessTaxNumber,
|
||||||
@BillingEmail,
|
@BillingEmail,
|
||||||
|
@BillingPhone,
|
||||||
@Status,
|
@Status,
|
||||||
|
@Type,
|
||||||
@UseEvents,
|
@UseEvents,
|
||||||
@Enabled,
|
@Enabled,
|
||||||
@CreationDate,
|
@CreationDate,
|
||||||
|
@ -8,7 +8,9 @@
|
|||||||
@BusinessCountry VARCHAR(2),
|
@BusinessCountry VARCHAR(2),
|
||||||
@BusinessTaxNumber NVARCHAR(30),
|
@BusinessTaxNumber NVARCHAR(30),
|
||||||
@BillingEmail NVARCHAR(256),
|
@BillingEmail NVARCHAR(256),
|
||||||
|
@BillingPhone NVARCHAR(50),
|
||||||
@Status TINYINT,
|
@Status TINYINT,
|
||||||
|
@Type TINYINT,
|
||||||
@UseEvents BIT,
|
@UseEvents BIT,
|
||||||
@Enabled BIT,
|
@Enabled BIT,
|
||||||
@CreationDate DATETIME2(7),
|
@CreationDate DATETIME2(7),
|
||||||
@ -28,7 +30,9 @@ BEGIN
|
|||||||
[BusinessCountry] = @BusinessCountry,
|
[BusinessCountry] = @BusinessCountry,
|
||||||
[BusinessTaxNumber] = @BusinessTaxNumber,
|
[BusinessTaxNumber] = @BusinessTaxNumber,
|
||||||
[BillingEmail] = @BillingEmail,
|
[BillingEmail] = @BillingEmail,
|
||||||
|
[BillingPhone] = @BillingPhone,
|
||||||
[Status] = @Status,
|
[Status] = @Status,
|
||||||
|
[Type] = @Type,
|
||||||
[UseEvents] = @UseEvents,
|
[UseEvents] = @UseEvents,
|
||||||
[Enabled] = @Enabled,
|
[Enabled] = @Enabled,
|
||||||
[CreationDate] = @CreationDate,
|
[CreationDate] = @CreationDate,
|
||||||
|
@ -8,8 +8,10 @@
|
|||||||
[BusinessCountry] VARCHAR (2) NULL,
|
[BusinessCountry] VARCHAR (2) NULL,
|
||||||
[BusinessTaxNumber] NVARCHAR (30) NULL,
|
[BusinessTaxNumber] NVARCHAR (30) NULL,
|
||||||
[BillingEmail] NVARCHAR (256) NULL,
|
[BillingEmail] NVARCHAR (256) NULL,
|
||||||
|
[BillingPhone] NVARCHAR (50) NULL,
|
||||||
[Status] TINYINT NOT NULL,
|
[Status] TINYINT NOT NULL,
|
||||||
[UseEvents] BIT NOT NULL,
|
[UseEvents] BIT NOT NULL,
|
||||||
|
[Type] TINYINT NOT NULL,
|
||||||
[Enabled] BIT NOT NULL,
|
[Enabled] BIT NOT NULL,
|
||||||
[CreationDate] DATETIME2 (7) NOT NULL,
|
[CreationDate] DATETIME2 (7) NOT NULL,
|
||||||
[RevisionDate] DATETIME2 (7) NOT NULL,
|
[RevisionDate] DATETIME2 (7) NOT NULL,
|
||||||
|
@ -10,7 +10,8 @@ SELECT
|
|||||||
P.[Enabled],
|
P.[Enabled],
|
||||||
PU.[Permissions],
|
PU.[Permissions],
|
||||||
P.[UseEvents],
|
P.[UseEvents],
|
||||||
P.[Status] ProviderStatus
|
P.[Status] ProviderStatus,
|
||||||
|
P.[Type] ProviderType
|
||||||
FROM
|
FROM
|
||||||
[dbo].[ProviderUser] PU
|
[dbo].[ProviderUser] PU
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
|
@ -0,0 +1,178 @@
|
|||||||
|
-- Add column 'Type' to 'Provider' table
|
||||||
|
IF COL_LENGTH('[dbo].[Provider]', 'Type') IS NULL
|
||||||
|
BEGIN
|
||||||
|
ALTER TABLE
|
||||||
|
[dbo].[Provider]
|
||||||
|
ADD
|
||||||
|
[Type] TINYINT NULL
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
||||||
|
-- Setting existing Providers Type = 0 (MSP)
|
||||||
|
UPDATE [dbo].[Provider]
|
||||||
|
SET [Type] = 0
|
||||||
|
WHERE [Type] = NULL
|
||||||
|
GO
|
||||||
|
|
||||||
|
-- Changing 'Type' column to not null
|
||||||
|
ALTER TABLE [dbo].[Provider] ALTER COLUMN [Type] TINYINT NOT NULL
|
||||||
|
GO
|
||||||
|
|
||||||
|
-- Add column 'BillingPhone' to 'Provider' table
|
||||||
|
IF COL_LENGTH('[dbo].[Provider]', 'BillingPhone') IS NULL
|
||||||
|
BEGIN
|
||||||
|
ALTER TABLE
|
||||||
|
[dbo].[Provider]
|
||||||
|
ADD
|
||||||
|
[BillingPhone] NVARCHAR (50) NULL
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
||||||
|
-- Recreate ProviderView so that it includes the new columns 'Type' and 'BillingPhone'
|
||||||
|
IF EXISTS(SELECT * FROM sys.views WHERE [Name] = 'ProviderView')
|
||||||
|
BEGIN
|
||||||
|
DROP VIEW [dbo].[ProviderView]
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE VIEW [dbo].[ProviderView]
|
||||||
|
AS
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
[dbo].[Provider]
|
||||||
|
GO
|
||||||
|
|
||||||
|
-- Recreate ProviderUserProviderDetailsView so that it includes the new columns 'Type' and 'BillingPhone'
|
||||||
|
IF EXISTS(SELECT * FROM sys.views WHERE [Name] = 'ProviderUserProviderDetailsView')
|
||||||
|
BEGIN
|
||||||
|
DROP VIEW [dbo].[ProviderUserProviderDetailsView]
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE VIEW [dbo].[ProviderUserProviderDetailsView]
|
||||||
|
AS
|
||||||
|
SELECT
|
||||||
|
PU.[UserId],
|
||||||
|
PU.[ProviderId],
|
||||||
|
P.[Name],
|
||||||
|
PU.[Key],
|
||||||
|
PU.[Status],
|
||||||
|
PU.[Type],
|
||||||
|
P.[Enabled],
|
||||||
|
PU.[Permissions],
|
||||||
|
P.[UseEvents],
|
||||||
|
P.[Status] ProviderStatus,
|
||||||
|
P.[Type] ProviderType
|
||||||
|
FROM
|
||||||
|
[dbo].[ProviderUser] PU
|
||||||
|
LEFT JOIN
|
||||||
|
[dbo].[Provider] P ON P.[Id] = PU.[ProviderId]
|
||||||
|
GO
|
||||||
|
|
||||||
|
-- Alter Provider_Create view to add new columns 'Type' and 'BillingPhone'
|
||||||
|
ALTER PROCEDURE [dbo].[Provider_Create]
|
||||||
|
@Id UNIQUEIDENTIFIER OUTPUT,
|
||||||
|
@Name NVARCHAR(50),
|
||||||
|
@BusinessName NVARCHAR(50),
|
||||||
|
@BusinessAddress1 NVARCHAR(50),
|
||||||
|
@BusinessAddress2 NVARCHAR(50),
|
||||||
|
@BusinessAddress3 NVARCHAR(50),
|
||||||
|
@BusinessCountry VARCHAR(2),
|
||||||
|
@BusinessTaxNumber NVARCHAR(30),
|
||||||
|
@BillingEmail NVARCHAR(256),
|
||||||
|
@BillingPhone NVARCHAR(50),
|
||||||
|
@Status TINYINT,
|
||||||
|
@Type TINYINT,
|
||||||
|
@UseEvents BIT,
|
||||||
|
@Enabled BIT,
|
||||||
|
@CreationDate DATETIME2(7),
|
||||||
|
@RevisionDate DATETIME2(7)
|
||||||
|
AS
|
||||||
|
BEGIN
|
||||||
|
SET NOCOUNT ON
|
||||||
|
|
||||||
|
INSERT INTO [dbo].[Provider]
|
||||||
|
(
|
||||||
|
[Id],
|
||||||
|
[Name],
|
||||||
|
[BusinessName],
|
||||||
|
[BusinessAddress1],
|
||||||
|
[BusinessAddress2],
|
||||||
|
[BusinessAddress3],
|
||||||
|
[BusinessCountry],
|
||||||
|
[BusinessTaxNumber],
|
||||||
|
[BillingEmail],
|
||||||
|
[BillingPhone],
|
||||||
|
[Status],
|
||||||
|
[Type],
|
||||||
|
[UseEvents],
|
||||||
|
[Enabled],
|
||||||
|
[CreationDate],
|
||||||
|
[RevisionDate]
|
||||||
|
)
|
||||||
|
VALUES
|
||||||
|
(
|
||||||
|
@Id,
|
||||||
|
@Name,
|
||||||
|
@BusinessName,
|
||||||
|
@BusinessAddress1,
|
||||||
|
@BusinessAddress2,
|
||||||
|
@BusinessAddress3,
|
||||||
|
@BusinessCountry,
|
||||||
|
@BusinessTaxNumber,
|
||||||
|
@BillingEmail,
|
||||||
|
@BillingPhone,
|
||||||
|
@Status,
|
||||||
|
@Type,
|
||||||
|
@UseEvents,
|
||||||
|
@Enabled,
|
||||||
|
@CreationDate,
|
||||||
|
@RevisionDate
|
||||||
|
)
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
||||||
|
-- Alter Provider_Update view to add new columns 'Type' and 'BillingPhone'
|
||||||
|
ALTER PROCEDURE [dbo].[Provider_Update]
|
||||||
|
@Id UNIQUEIDENTIFIER,
|
||||||
|
@Name NVARCHAR(50),
|
||||||
|
@BusinessName NVARCHAR(50),
|
||||||
|
@BusinessAddress1 NVARCHAR(50),
|
||||||
|
@BusinessAddress2 NVARCHAR(50),
|
||||||
|
@BusinessAddress3 NVARCHAR(50),
|
||||||
|
@BusinessCountry VARCHAR(2),
|
||||||
|
@BusinessTaxNumber NVARCHAR(30),
|
||||||
|
@BillingEmail NVARCHAR(256),
|
||||||
|
@BillingPhone NVARCHAR(50),
|
||||||
|
@Status TINYINT,
|
||||||
|
@Type TINYINT,
|
||||||
|
@UseEvents BIT,
|
||||||
|
@Enabled BIT,
|
||||||
|
@CreationDate DATETIME2(7),
|
||||||
|
@RevisionDate DATETIME2(7)
|
||||||
|
AS
|
||||||
|
BEGIN
|
||||||
|
SET NOCOUNT ON
|
||||||
|
|
||||||
|
UPDATE
|
||||||
|
[dbo].[Provider]
|
||||||
|
SET
|
||||||
|
[Name] = @Name,
|
||||||
|
[BusinessName] = @BusinessName,
|
||||||
|
[BusinessAddress1] = @BusinessAddress1,
|
||||||
|
[BusinessAddress2] = @BusinessAddress2,
|
||||||
|
[BusinessAddress3] = @BusinessAddress3,
|
||||||
|
[BusinessCountry] = @BusinessCountry,
|
||||||
|
[BusinessTaxNumber] = @BusinessTaxNumber,
|
||||||
|
[BillingEmail] = @BillingEmail,
|
||||||
|
[BillingPhone] = @BillingPhone,
|
||||||
|
[Status] = @Status,
|
||||||
|
[Type] = @Type,
|
||||||
|
[UseEvents] = @UseEvents,
|
||||||
|
[Enabled] = @Enabled,
|
||||||
|
[CreationDate] = @CreationDate,
|
||||||
|
[RevisionDate] = @RevisionDate
|
||||||
|
WHERE
|
||||||
|
[Id] = @Id
|
||||||
|
END
|
Reference in New Issue
Block a user