mirror of
https://github.com/bitwarden/server.git
synced 2024-12-22 16:57:36 +01:00
[EC-427] Add provider types (MSP/Reseller) to Provider table (#2518)
* [EC-427] Add columns 'Type' and 'BillingPhone' to Provider table
* [EC-427] Provider table Type and BillingPhone MySql migrations
* [EC-427] Provider table Type and BillingPhone Postgres migrations
* [EC-427] Add mysql migration script
* [EC-427] Add mysql migration script
* [EC-427] Updated Provider sql script to include default column value
* [EC-427] Removed default value from Provider.Type column
* [EC-427] Changed migration script to include a default value constraint instead of updating the null type
* [EC-427] Updated Sql project Provider table script
* [EC-427] Changed migration script to use 'Create OR Alter' for views and sprocs
* [EC-427] Added default values for 'BillingPhone' and 'Type' fields on sprocs [dbo].[Provider_Create] and [dbo].[Provider_Update]
* [EC-427] Adjusting metadata in migration script
* [EC-427] Updated Provider sprocs SQL script files
* [EC-427] Fixed migration script
* [EC-427] Added sqlite migration
* [EC-427] Add missing Provider_Update sproc default value
* [EC-427] Added missing GO action to migration script
* [EC-428] Redirect to Edit after creating Provider
* Revert "[EC-428] Redirect to Edit after creating Provider"
This reverts commit 6347bca1ed
.
This commit is contained in:
parent
c6c0f95ed7
commit
68989442c8
@ -14,8 +14,10 @@ public class Provider : ITableObject<Guid>
|
||||
public string BusinessCountry { get; set; }
|
||||
public string BusinessTaxNumber { get; set; }
|
||||
public string BillingEmail { get; set; }
|
||||
public string BillingPhone { get; set; }
|
||||
public ProviderStatusType Status { get; set; }
|
||||
public bool UseEvents { get; set; }
|
||||
public ProviderType Type { get; set; }
|
||||
public bool Enabled { get; set; } = true;
|
||||
public DateTime CreationDate { 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),
|
||||
@BusinessTaxNumber NVARCHAR(30),
|
||||
@BillingEmail NVARCHAR(256),
|
||||
@BillingPhone NVARCHAR(50) = NULL,
|
||||
@Status TINYINT,
|
||||
@Type TINYINT = 0,
|
||||
@UseEvents BIT,
|
||||
@Enabled BIT,
|
||||
@CreationDate DATETIME2(7),
|
||||
@ -28,7 +30,9 @@ BEGIN
|
||||
[BusinessCountry],
|
||||
[BusinessTaxNumber],
|
||||
[BillingEmail],
|
||||
[BillingPhone],
|
||||
[Status],
|
||||
[Type],
|
||||
[UseEvents],
|
||||
[Enabled],
|
||||
[CreationDate],
|
||||
@ -45,7 +49,9 @@ BEGIN
|
||||
@BusinessCountry,
|
||||
@BusinessTaxNumber,
|
||||
@BillingEmail,
|
||||
@BillingPhone,
|
||||
@Status,
|
||||
@Type,
|
||||
@UseEvents,
|
||||
@Enabled,
|
||||
@CreationDate,
|
||||
|
@ -8,7 +8,9 @@
|
||||
@BusinessCountry VARCHAR(2),
|
||||
@BusinessTaxNumber NVARCHAR(30),
|
||||
@BillingEmail NVARCHAR(256),
|
||||
@BillingPhone NVARCHAR(50) = NULL,
|
||||
@Status TINYINT,
|
||||
@Type TINYINT = 0,
|
||||
@UseEvents BIT,
|
||||
@Enabled BIT,
|
||||
@CreationDate DATETIME2(7),
|
||||
@ -28,7 +30,9 @@ BEGIN
|
||||
[BusinessCountry] = @BusinessCountry,
|
||||
[BusinessTaxNumber] = @BusinessTaxNumber,
|
||||
[BillingEmail] = @BillingEmail,
|
||||
[BillingPhone] = @BillingPhone,
|
||||
[Status] = @Status,
|
||||
[Type] = @Type,
|
||||
[UseEvents] = @UseEvents,
|
||||
[Enabled] = @Enabled,
|
||||
[CreationDate] = @CreationDate,
|
||||
|
@ -8,8 +8,10 @@
|
||||
[BusinessCountry] VARCHAR (2) NULL,
|
||||
[BusinessTaxNumber] NVARCHAR (30) NULL,
|
||||
[BillingEmail] NVARCHAR (256) NULL,
|
||||
[BillingPhone] NVARCHAR (50) NULL,
|
||||
[Status] TINYINT NOT NULL,
|
||||
[UseEvents] BIT NOT NULL,
|
||||
[Type] TINYINT NOT NULL CONSTRAINT DF_Provider_Type DEFAULT (0),
|
||||
[Enabled] BIT NOT NULL,
|
||||
[CreationDate] DATETIME2 (7) NOT NULL,
|
||||
[RevisionDate] DATETIME2 (7) NOT NULL,
|
||||
|
@ -10,7 +10,8 @@ SELECT
|
||||
P.[Enabled],
|
||||
PU.[Permissions],
|
||||
P.[UseEvents],
|
||||
P.[Status] ProviderStatus
|
||||
P.[Status] ProviderStatus,
|
||||
P.[Type] ProviderType
|
||||
FROM
|
||||
[dbo].[ProviderUser] PU
|
||||
LEFT JOIN
|
||||
|
@ -0,0 +1,169 @@
|
||||
-- Add column 'Type' to 'Provider' table
|
||||
IF COL_LENGTH('[dbo].[Provider]', 'Type') IS NULL
|
||||
BEGIN
|
||||
ALTER TABLE
|
||||
[dbo].[Provider]
|
||||
ADD
|
||||
[Type] TINYINT NOT NULL CONSTRAINT DF_Provider_Type DEFAULT (0);
|
||||
END
|
||||
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'
|
||||
CREATE OR ALTER VIEW [dbo].[ProviderView]
|
||||
AS
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[Provider]
|
||||
GO
|
||||
|
||||
-- Recreate ProviderUserProviderDetailsView so that it includes the new columns 'Type' and 'BillingPhone'
|
||||
CREATE OR ALTER 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'
|
||||
CREATE OR 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) = NULL,
|
||||
@Status TINYINT,
|
||||
@Type TINYINT = 0,
|
||||
@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'
|
||||
CREATE OR 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) = NULL,
|
||||
@Status TINYINT,
|
||||
@Type TINYINT = 0,
|
||||
@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
|
||||
GO
|
||||
|
||||
IF OBJECT_ID('[dbo].[Provider_ReadById]') IS NOT NULL
|
||||
BEGIN
|
||||
EXECUTE sp_refreshsqlmodule N'[dbo].[Provider_ReadById]';
|
||||
END
|
||||
GO
|
||||
|
||||
IF OBJECT_ID('[dbo].[Provider_Search]') IS NOT NULL
|
||||
BEGIN
|
||||
EXECUTE sp_refreshsqlmodule N'[dbo].[Provider_Search]';
|
||||
END
|
||||
GO
|
1687
util/MySqlMigrations/Migrations/20221226164641_ProviderAddProviderTypeBillingPhone.Designer.cs
generated
Normal file
1687
util/MySqlMigrations/Migrations/20221226164641_ProviderAddProviderTypeBillingPhone.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,36 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Bit.MySqlMigrations.Migrations;
|
||||
|
||||
public partial class ProviderAddProviderTypeBillingPhone : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "BillingPhone",
|
||||
table: "Provider",
|
||||
type: "longtext",
|
||||
nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AddColumn<byte>(
|
||||
name: "Type",
|
||||
table: "Provider",
|
||||
type: "tinyint unsigned",
|
||||
nullable: false,
|
||||
defaultValue: (byte)0);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "BillingPhone",
|
||||
table: "Provider");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Type",
|
||||
table: "Provider");
|
||||
}
|
||||
}
|
@ -941,6 +941,9 @@ namespace Bit.MySqlMigrations.Migrations
|
||||
b.Property<string>("BillingEmail")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("BillingPhone")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("BusinessAddress1")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
@ -974,6 +977,9 @@ namespace Bit.MySqlMigrations.Migrations
|
||||
b.Property<byte>("Status")
|
||||
.HasColumnType("tinyint unsigned");
|
||||
|
||||
b.Property<byte>("Type")
|
||||
.HasColumnType("tinyint unsigned");
|
||||
|
||||
b.Property<bool>("UseEvents")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
START TRANSACTION;
|
||||
|
||||
ALTER TABLE `Provider` ADD `BillingPhone` longtext CHARACTER SET utf8mb4 NULL;
|
||||
|
||||
ALTER TABLE `Provider` ADD `Type` tinyint unsigned NOT NULL DEFAULT 0;
|
||||
|
||||
INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`)
|
||||
VALUES ('20221226164641_ProviderAddProviderTypeBillingPhone', '6.0.12');
|
||||
|
||||
COMMIT;
|
1698
util/PostgresMigrations/Migrations/20221227100237_ProviderAddProviderTypeBillingPhone.Designer.cs
generated
Normal file
1698
util/PostgresMigrations/Migrations/20221227100237_ProviderAddProviderTypeBillingPhone.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,35 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Bit.PostgresMigrations.Migrations;
|
||||
|
||||
public partial class ProviderAddProviderTypeBillingPhone : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "BillingPhone",
|
||||
table: "Provider",
|
||||
type: "text",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<byte>(
|
||||
name: "Type",
|
||||
table: "Provider",
|
||||
type: "smallint",
|
||||
nullable: false,
|
||||
defaultValue: (byte)0);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "BillingPhone",
|
||||
table: "Provider");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Type",
|
||||
table: "Provider");
|
||||
}
|
||||
}
|
@ -946,6 +946,9 @@ namespace Bit.PostgresMigrations.Migrations
|
||||
b.Property<string>("BillingEmail")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("BillingPhone")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("BusinessAddress1")
|
||||
.HasColumnType("text");
|
||||
|
||||
@ -979,6 +982,9 @@ namespace Bit.PostgresMigrations.Migrations
|
||||
b.Property<byte>("Status")
|
||||
.HasColumnType("smallint");
|
||||
|
||||
b.Property<byte>("Type")
|
||||
.HasColumnType("smallint");
|
||||
|
||||
b.Property<bool>("UseEvents")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
START TRANSACTION;
|
||||
|
||||
ALTER TABLE "Provider" ADD "BillingPhone" text NULL;
|
||||
|
||||
ALTER TABLE "Provider" ADD "Type" smallint NOT NULL DEFAULT 0;
|
||||
|
||||
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
|
||||
VALUES ('20221227100237_ProviderAddProviderTypeBillingPhone', '6.0.12');
|
||||
|
||||
COMMIT;
|
1685
util/SqliteMigrations/Migrations/20230112125615_ProviderAddProviderTypeBillingPhone.Designer.cs
generated
Normal file
1685
util/SqliteMigrations/Migrations/20230112125615_ProviderAddProviderTypeBillingPhone.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,35 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Bit.SqliteMigrations.Migrations;
|
||||
|
||||
public partial class ProviderAddProviderTypeBillingPhone : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "BillingPhone",
|
||||
table: "Provider",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<byte>(
|
||||
name: "Type",
|
||||
table: "Provider",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
defaultValue: (byte)0);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "BillingPhone",
|
||||
table: "Provider");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Type",
|
||||
table: "Provider");
|
||||
}
|
||||
}
|
@ -939,6 +939,9 @@ namespace Bit.SqliteMigrations.Migrations
|
||||
b.Property<string>("BillingEmail")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("BillingPhone")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("BusinessAddress1")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
@ -972,6 +975,9 @@ namespace Bit.SqliteMigrations.Migrations
|
||||
b.Property<byte>("Status")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<byte>("Type")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("UseEvents")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user