1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-05 13:08:17 -05:00

[AC-1943] Add ProviderInvoiceItem table (#4163)

* Add ProviderInvoiceItem table

* Run dotnet format
This commit is contained in:
Alex Morask 2024-06-06 13:25:13 -04:00 committed by GitHub
parent fef34d845f
commit 725fc2eed3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
28 changed files with 8765 additions and 0 deletions

View File

@ -0,0 +1,26 @@
using Bit.Core.Entities;
using Bit.Core.Utilities;
namespace Bit.Core.Billing.Entities;
public class ProviderInvoiceItem : ITableObject<Guid>
{
public Guid Id { get; set; }
public Guid ProviderId { get; set; }
public string InvoiceId { get; set; }
public string InvoiceNumber { get; set; }
public string ClientName { get; set; }
public string PlanName { get; set; }
public int AssignedSeats { get; set; }
public int UsedSeats { get; set; }
public decimal Total { get; set; }
public DateTime Created { get; set; }
public void SetNewId()
{
if (Id == default)
{
Id = CoreHelpers.GenerateComb();
}
}
}

View File

@ -0,0 +1,10 @@
using Bit.Core.Billing.Entities;
using Bit.Core.Repositories;
namespace Bit.Core.Billing.Repositories;
public interface IProviderInvoiceItemRepository : IRepository<ProviderInvoiceItem, Guid>
{
Task<ProviderInvoiceItem> GetByInvoiceId(string invoiceId);
Task<ICollection<ProviderInvoiceItem>> GetByProviderId(Guid providerId);
}

View File

@ -0,0 +1,40 @@
using System.Data;
using Bit.Core.Billing.Entities;
using Bit.Core.Billing.Repositories;
using Bit.Core.Settings;
using Bit.Infrastructure.Dapper.Repositories;
using Dapper;
using Microsoft.Data.SqlClient;
namespace Bit.Infrastructure.Dapper.Billing.Repositories;
public class ProviderInvoiceItemRepository(
GlobalSettings globalSettings)
: Repository<ProviderInvoiceItem, Guid>(
globalSettings.SqlServer.ConnectionString,
globalSettings.SqlServer.ReadOnlyConnectionString), IProviderInvoiceItemRepository
{
public async Task<ProviderInvoiceItem> GetByInvoiceId(string invoiceId)
{
var sqlConnection = new SqlConnection(ConnectionString);
var results = await sqlConnection.QueryAsync<ProviderInvoiceItem>(
"[dbo].[ProviderInvoiceItem_ReadByInvoiceId]",
new { InvoiceId = invoiceId },
commandType: CommandType.StoredProcedure);
return results.FirstOrDefault();
}
public async Task<ICollection<ProviderInvoiceItem>> GetByProviderId(Guid providerId)
{
var sqlConnection = new SqlConnection(ConnectionString);
var results = await sqlConnection.QueryAsync<ProviderInvoiceItem>(
"[dbo].[ProviderInvoiceItem_ReadByProviderId]",
new { ProviderId = providerId },
commandType: CommandType.StoredProcedure);
return results.ToArray();
}
}

View File

@ -51,6 +51,7 @@ public static class DapperServiceCollectionExtensions
services.AddSingleton<IOrganizationDomainRepository, OrganizationDomainRepository>(); services.AddSingleton<IOrganizationDomainRepository, OrganizationDomainRepository>();
services.AddSingleton<IWebAuthnCredentialRepository, WebAuthnCredentialRepository>(); services.AddSingleton<IWebAuthnCredentialRepository, WebAuthnCredentialRepository>();
services.AddSingleton<IProviderPlanRepository, ProviderPlanRepository>(); services.AddSingleton<IProviderPlanRepository, ProviderPlanRepository>();
services.AddSingleton<IProviderInvoiceItemRepository, ProviderInvoiceItemRepository>();
if (selfHosted) if (selfHosted)
{ {

View File

@ -0,0 +1,21 @@
using Bit.Infrastructure.EntityFramework.Billing.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Bit.Infrastructure.EntityFramework.Billing.Configurations;
public class ProviderInvoiceItemEntityTypeConfiguration : IEntityTypeConfiguration<ProviderInvoiceItem>
{
public void Configure(EntityTypeBuilder<ProviderInvoiceItem> builder)
{
builder
.Property(t => t.Id)
.ValueGeneratedNever();
builder
.HasIndex(providerInvoiceItem => new { providerInvoiceItem.Id, providerInvoiceItem.InvoiceId })
.IsUnique();
builder.ToTable(nameof(ProviderInvoiceItem));
}
}

View File

@ -0,0 +1,18 @@
using AutoMapper;
using Bit.Infrastructure.EntityFramework.AdminConsole.Models.Provider;
namespace Bit.Infrastructure.EntityFramework.Billing.Models;
// ReSharper disable once ClassWithVirtualMembersNeverInherited.Global
public class ProviderInvoiceItem : Core.Billing.Entities.ProviderInvoiceItem
{
public virtual Provider Provider { get; set; }
}
public class ProviderInvoiceItemMapperProfile : Profile
{
public ProviderInvoiceItemMapperProfile()
{
CreateMap<Core.Billing.Entities.ProviderInvoiceItem, ProviderInvoiceItem>().ReverseMap();
}
}

View File

@ -3,6 +3,7 @@ using Bit.Infrastructure.EntityFramework.AdminConsole.Models.Provider;
namespace Bit.Infrastructure.EntityFramework.Billing.Models; namespace Bit.Infrastructure.EntityFramework.Billing.Models;
// ReSharper disable once ClassWithVirtualMembersNeverInherited.Global
public class ProviderPlan : Core.Billing.Entities.ProviderPlan public class ProviderPlan : Core.Billing.Entities.ProviderPlan
{ {
public virtual Provider Provider { get; set; } public virtual Provider Provider { get; set; }

View File

@ -0,0 +1,46 @@
using AutoMapper;
using Bit.Core.Billing.Entities;
using Bit.Core.Billing.Repositories;
using Bit.Infrastructure.EntityFramework.Repositories;
using LinqToDB;
using Microsoft.Extensions.DependencyInjection;
using EFProviderInvoiceItem = Bit.Infrastructure.EntityFramework.Billing.Models.ProviderInvoiceItem;
namespace Bit.Infrastructure.EntityFramework.Billing.Repositories;
public class ProviderInvoiceItemRepository(
IMapper mapper,
IServiceScopeFactory serviceScopeFactory)
: Repository<ProviderInvoiceItem, EFProviderInvoiceItem, Guid>(
serviceScopeFactory,
mapper,
context => context.ProviderInvoiceItems), IProviderInvoiceItemRepository
{
public async Task<ProviderInvoiceItem> GetByInvoiceId(string invoiceId)
{
using var serviceScope = ServiceScopeFactory.CreateScope();
var databaseContext = GetDatabaseContext(serviceScope);
var query =
from providerInvoiceItem in databaseContext.ProviderInvoiceItems
where providerInvoiceItem.InvoiceId == invoiceId
select providerInvoiceItem;
return await query.FirstOrDefaultAsync();
}
public async Task<ICollection<ProviderInvoiceItem>> GetByProviderId(Guid providerId)
{
using var serviceScope = ServiceScopeFactory.CreateScope();
var databaseContext = GetDatabaseContext(serviceScope);
var query =
from providerInvoiceItem in databaseContext.ProviderInvoiceItems
where providerInvoiceItem.ProviderId == providerId
select providerInvoiceItem;
return await query.ToArrayAsync();
}
}

View File

@ -88,6 +88,7 @@ public static class EntityFrameworkServiceCollectionExtensions
services.AddSingleton<IOrganizationDomainRepository, OrganizationDomainRepository>(); services.AddSingleton<IOrganizationDomainRepository, OrganizationDomainRepository>();
services.AddSingleton<IWebAuthnCredentialRepository, WebAuthnCredentialRepository>(); services.AddSingleton<IWebAuthnCredentialRepository, WebAuthnCredentialRepository>();
services.AddSingleton<IProviderPlanRepository, ProviderPlanRepository>(); services.AddSingleton<IProviderPlanRepository, ProviderPlanRepository>();
services.AddSingleton<IProviderInvoiceItemRepository, ProviderInvoiceItemRepository>();
if (selfHosted) if (selfHosted)
{ {

View File

@ -67,6 +67,7 @@ public class DatabaseContext : DbContext
public DbSet<OrganizationDomain> OrganizationDomains { get; set; } public DbSet<OrganizationDomain> OrganizationDomains { get; set; }
public DbSet<WebAuthnCredential> WebAuthnCredentials { get; set; } public DbSet<WebAuthnCredential> WebAuthnCredentials { get; set; }
public DbSet<ProviderPlan> ProviderPlans { get; set; } public DbSet<ProviderPlan> ProviderPlans { get; set; }
public DbSet<ProviderInvoiceItem> ProviderInvoiceItems { get; set; }
protected override void OnModelCreating(ModelBuilder builder) protected override void OnModelCreating(ModelBuilder builder)
{ {

View File

@ -0,0 +1,41 @@
CREATE PROCEDURE [dbo].[ProviderInvoiceItem_Create]
@Id UNIQUEIDENTIFIER OUTPUT,
@ProviderId UNIQUEIDENTIFIER,
@InvoiceId VARCHAR (50),
@InvoiceNumber VARCHAR (50),
@ClientName NVARCHAR (50),
@PlanName NVARCHAR (50),
@AssignedSeats INT,
@UsedSeats INT,
@Total MONEY
AS
BEGIN
SET NOCOUNT ON
INSERT INTO [dbo].[ProviderInvoiceItem]
(
[Id],
[ProviderId],
[InvoiceId],
[InvoiceNumber],
[ClientName],
[PlanName],
[AssignedSeats],
[UsedSeats],
[Total],
[Created]
)
VALUES
(
@Id,
@ProviderId,
@InvoiceId,
@InvoiceNumber,
@ClientName,
@PlanName,
@AssignedSeats,
@UsedSeats,
@Total,
GETUTCDATE()
)
END

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,28 @@
CREATE PROCEDURE [dbo].[ProviderInvoiceItem_Update]
@Id UNIQUEIDENTIFIER,
@ProviderId UNIQUEIDENTIFIER,
@InvoiceId VARCHAR (50),
@InvoiceNumber VARCHAR (50),
@ClientName NVARCHAR (50),
@PlanName NVARCHAR (50),
@AssignedSeats INT,
@UsedSeats INT,
@Total MONEY
AS
BEGIN
SET NOCOUNT ON
UPDATE
[dbo].[ProviderInvoiceItem]
SET
[ProviderId] = @ProviderId,
[InvoiceId] = @InvoiceId,
[InvoiceNumber] = @InvoiceNumber,
[ClientName] = @ClientName,
[PlanName] = @PlanName,
[AssignedSeats] = @AssignedSeats,
[UsedSeats] = @UsedSeats,
[Total] = @Total
WHERE
[Id] = @Id
END

View File

@ -0,0 +1,15 @@
CREATE TABLE [dbo].[ProviderInvoiceItem] (
[Id] UNIQUEIDENTIFIER NOT NULL,
[ProviderId] UNIQUEIDENTIFIER NOT NULL,
[InvoiceId] VARCHAR (50) NOT NULL,
[InvoiceNumber] VARCHAR (50) NOT NULL,
[ClientName] NVARCHAR (50) NOT NULL,
[PlanName] NVARCHAR (50) NOT NULL,
[AssignedSeats] INT NOT NULL,
[UsedSeats] INT NOT NULL,
[Total] MONEY NOT NULL,
[Created] DATETIME2 (7) NOT NULL,
CONSTRAINT [PK_ProviderInvoiceItem] PRIMARY KEY CLUSTERED ([Id] ASC),
CONSTRAINT [FK_ProviderInvoiceItem_Provider] FOREIGN KEY ([ProviderId]) REFERENCES [dbo].[Provider] ([Id]),
CONSTRAINT [PK_ProviderIdInvoiceId] UNIQUE ([ProviderId], [InvoiceId])
);

View File

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

View File

@ -0,0 +1,211 @@
-- ProviderInvoiceItem
-- Table
IF OBJECT_ID('[dbo].[ProviderInvoiceItem]') IS NULL
BEGIN
CREATE TABLE [dbo].[ProviderInvoiceItem] (
[Id] UNIQUEIDENTIFIER NOT NULL,
[ProviderId] UNIQUEIDENTIFIER NOT NULL,
[InvoiceId] VARCHAR (50) NOT NULL,
[InvoiceNumber] VARCHAR (50) NOT NULL,
[ClientName] NVARCHAR (50) NOT NULL,
[PlanName] NVARCHAR (50) NOT NULL,
[AssignedSeats] INT NOT NULL,
[UsedSeats] INT NOT NULL,
[Total] MONEY NOT NULL,
[Created] DATETIME2 (7) NOT NULL,
CONSTRAINT [PK_ProviderInvoiceItem] PRIMARY KEY CLUSTERED ([Id] ASC),
CONSTRAINT [FK_ProviderInvoiceItem_Provider] FOREIGN KEY ([ProviderId]) REFERENCES [dbo].[Provider] ([Id]),
CONSTRAINT [PK_ProviderIdInvoiceId] UNIQUE ([ProviderId], [InvoiceId])
);
END
GO
-- View
IF EXISTS(SELECT * FROM sys.views WHERE [Name] = 'ProviderInvoiceItemView')
BEGIN
DROP VIEW [dbo].[ProviderInvoiceItemView]
END
GO
CREATE VIEW [dbo].[ProviderInvoiceItemView]
AS
SELECT
*
FROM
[dbo].[ProviderInvoiceItem]
GO
-- Stored Procedure: Create
IF OBJECT_ID('[dbo].[ProviderInvoiceItem_Create]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[ProviderInvoiceItem_Create]
END
GO
CREATE PROCEDURE [dbo].[ProviderInvoiceItem_Create]
@Id UNIQUEIDENTIFIER OUTPUT,
@ProviderId UNIQUEIDENTIFIER,
@InvoiceId VARCHAR (50),
@InvoiceNumber VARCHAR (50),
@ClientName NVARCHAR (50),
@PlanName NVARCHAR (50),
@AssignedSeats INT,
@UsedSeats INT,
@Total MONEY
AS
BEGIN
SET NOCOUNT ON
INSERT INTO [dbo].[ProviderInvoiceItem]
(
[Id],
[ProviderId],
[InvoiceId],
[InvoiceNumber],
[ClientName],
[PlanName],
[AssignedSeats],
[UsedSeats],
[Total],
[Created]
)
VALUES
(
@Id,
@ProviderId,
@InvoiceId,
@InvoiceNumber,
@ClientName,
@PlanName,
@AssignedSeats,
@UsedSeats,
@Total,
GETUTCDATE()
)
END
GO
-- Stored Procedure: DeleteById
IF OBJECT_ID('[dbo].[ProviderInvoiceItem_DeleteById]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[ProviderInvoiceItem_DeleteById]
END
GO
CREATE PROCEDURE [dbo].[ProviderInvoiceItem_DeleteById]
@Id UNIQUEIDENTIFIER
AS
BEGIN
SET NOCOUNT ON
DELETE
FROM
[dbo].[ProviderInvoiceItem]
WHERE
[Id] = @Id
END
GO
-- Stored Procedure: ReadById
IF OBJECT_ID('[dbo].[ProviderInvoiceItem_ReadById]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[ProviderInvoiceItem_ReadById]
END
GO
CREATE PROCEDURE [dbo].[ProviderInvoiceItem_ReadById]
@Id UNIQUEIDENTIFIER
AS
BEGIN
SET NOCOUNT ON
SELECT
*
FROM
[dbo].[ProviderInvoiceItemView]
WHERE
[Id] = @Id
END
GO
-- Stored Procedure: ReadByInvoiceId
IF OBJECT_ID('[dbo].[ProviderInvoiceItem_ReadByInvoiceId]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[ProviderInvoiceItem_ReadByInvoiceId]
END
GO
CREATE PROCEDURE [dbo].[ProviderInvoiceItem_ReadByInvoiceId]
@InvoiceId VARCHAR (50)
AS
BEGIN
SET NOCOUNT ON
SELECT
*
FROM
[dbo].[ProviderInvoiceItemView]
WHERE
[InvoiceId] = @InvoiceId
END
GO
-- Stored Procedure: ReadByProviderId
IF OBJECT_ID('[dbo].[ProviderInvoiceItem_ReadByProviderId]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[ProviderInvoiceItem_ReadByProviderId]
END
GO
CREATE PROCEDURE [dbo].[ProviderInvoiceItem_ReadByProviderId]
@ProviderId UNIQUEIDENTIFIER
AS
BEGIN
SET NOCOUNT ON
SELECT
*
FROM
[dbo].[ProviderInvoiceItemView]
WHERE
[ProviderId] = @ProviderId
END
GO
-- Stored Procedure: Update
IF OBJECT_ID('[dbo].[ProviderInvoiceItem_Update]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[ProviderInvoiceItem_Update]
END
GO
CREATE PROCEDURE [dbo].[ProviderInvoiceItem_Update]
@Id UNIQUEIDENTIFIER,
@ProviderId UNIQUEIDENTIFIER,
@InvoiceId VARCHAR (50),
@InvoiceNumber VARCHAR (50),
@ClientName NVARCHAR (50),
@PlanName NVARCHAR (50),
@AssignedSeats INT,
@UsedSeats INT,
@Total MONEY
AS
BEGIN
SET NOCOUNT ON
UPDATE
[dbo].[ProviderInvoiceItem]
SET
[ProviderId] = @ProviderId,
[InvoiceId] = @InvoiceId,
[InvoiceNumber] = @InvoiceNumber,
[ClientName] = @ClientName,
[PlanName] = @PlanName,
[AssignedSeats] = @AssignedSeats,
[UsedSeats] = @UsedSeats,
[Total] = @Total
WHERE
[Id] = @Id
END
GO

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,62 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.MySqlMigrations.Migrations;
/// <inheritdoc />
public partial class ProviderInvoiceItem : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ProviderInvoiceItem",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
ProviderId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
InvoiceId = table.Column<string>(type: "varchar(255)", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
InvoiceNumber = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ClientName = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
PlanName = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
AssignedSeats = table.Column<int>(type: "int", nullable: false),
UsedSeats = table.Column<int>(type: "int", nullable: false),
Total = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
Created = table.Column<DateTime>(type: "datetime(6)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ProviderInvoiceItem", x => x.Id);
table.ForeignKey(
name: "FK_ProviderInvoiceItem_Provider_ProviderId",
column: x => x.ProviderId,
principalTable: "Provider",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_ProviderInvoiceItem_Id_InvoiceId",
table: "ProviderInvoiceItem",
columns: new[] { "Id", "InvoiceId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_ProviderInvoiceItem_ProviderId",
table: "ProviderInvoiceItem",
column: "ProviderId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ProviderInvoiceItem");
}
}

View File

@ -673,6 +673,48 @@ namespace Bit.MySqlMigrations.Migrations
b.ToTable("WebAuthnCredential", (string)null); b.ToTable("WebAuthnCredential", (string)null);
}); });
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Billing.Models.ProviderInvoiceItem", b =>
{
b.Property<Guid>("Id")
.HasColumnType("char(36)");
b.Property<int>("AssignedSeats")
.HasColumnType("int");
b.Property<string>("ClientName")
.HasColumnType("longtext");
b.Property<DateTime>("Created")
.HasColumnType("datetime(6)");
b.Property<string>("InvoiceId")
.HasColumnType("varchar(255)");
b.Property<string>("InvoiceNumber")
.HasColumnType("longtext");
b.Property<string>("PlanName")
.HasColumnType("longtext");
b.Property<Guid>("ProviderId")
.HasColumnType("char(36)");
b.Property<decimal>("Total")
.HasColumnType("decimal(65,30)");
b.Property<int>("UsedSeats")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ProviderId");
b.HasIndex("Id", "InvoiceId")
.IsUnique();
b.ToTable("ProviderInvoiceItem", (string)null);
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Billing.Models.ProviderPlan", b => modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Billing.Models.ProviderPlan", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
@ -2050,6 +2092,17 @@ namespace Bit.MySqlMigrations.Migrations
b.Navigation("User"); b.Navigation("User");
}); });
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Billing.Models.ProviderInvoiceItem", b =>
{
b.HasOne("Bit.Infrastructure.EntityFramework.AdminConsole.Models.Provider.Provider", "Provider")
.WithMany()
.HasForeignKey("ProviderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Provider");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Billing.Models.ProviderPlan", b => modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Billing.Models.ProviderPlan", b =>
{ {
b.HasOne("Bit.Infrastructure.EntityFramework.AdminConsole.Models.Provider.Provider", "Provider") b.HasOne("Bit.Infrastructure.EntityFramework.AdminConsole.Models.Provider.Provider", "Provider")

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,57 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.PostgresMigrations.Migrations;
/// <inheritdoc />
public partial class ProviderInvoiceItem : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ProviderInvoiceItem",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
ProviderId = table.Column<Guid>(type: "uuid", nullable: false),
InvoiceId = table.Column<string>(type: "text", nullable: true),
InvoiceNumber = table.Column<string>(type: "text", nullable: true),
ClientName = table.Column<string>(type: "text", nullable: true),
PlanName = table.Column<string>(type: "text", nullable: true),
AssignedSeats = table.Column<int>(type: "integer", nullable: false),
UsedSeats = table.Column<int>(type: "integer", nullable: false),
Total = table.Column<decimal>(type: "numeric", nullable: false),
Created = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ProviderInvoiceItem", x => x.Id);
table.ForeignKey(
name: "FK_ProviderInvoiceItem_Provider_ProviderId",
column: x => x.ProviderId,
principalTable: "Provider",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_ProviderInvoiceItem_Id_InvoiceId",
table: "ProviderInvoiceItem",
columns: new[] { "Id", "InvoiceId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_ProviderInvoiceItem_ProviderId",
table: "ProviderInvoiceItem",
column: "ProviderId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ProviderInvoiceItem");
}
}

View File

@ -687,6 +687,48 @@ namespace Bit.PostgresMigrations.Migrations
b.ToTable("WebAuthnCredential", (string)null); b.ToTable("WebAuthnCredential", (string)null);
}); });
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Billing.Models.ProviderInvoiceItem", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<int>("AssignedSeats")
.HasColumnType("integer");
b.Property<string>("ClientName")
.HasColumnType("text");
b.Property<DateTime>("Created")
.HasColumnType("timestamp with time zone");
b.Property<string>("InvoiceId")
.HasColumnType("text");
b.Property<string>("InvoiceNumber")
.HasColumnType("text");
b.Property<string>("PlanName")
.HasColumnType("text");
b.Property<Guid>("ProviderId")
.HasColumnType("uuid");
b.Property<decimal>("Total")
.HasColumnType("numeric");
b.Property<int>("UsedSeats")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ProviderId");
b.HasIndex("Id", "InvoiceId")
.IsUnique();
b.ToTable("ProviderInvoiceItem", (string)null);
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Billing.Models.ProviderPlan", b => modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Billing.Models.ProviderPlan", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
@ -2066,6 +2108,17 @@ namespace Bit.PostgresMigrations.Migrations
b.Navigation("User"); b.Navigation("User");
}); });
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Billing.Models.ProviderInvoiceItem", b =>
{
b.HasOne("Bit.Infrastructure.EntityFramework.AdminConsole.Models.Provider.Provider", "Provider")
.WithMany()
.HasForeignKey("ProviderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Provider");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Billing.Models.ProviderPlan", b => modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Billing.Models.ProviderPlan", b =>
{ {
b.HasOne("Bit.Infrastructure.EntityFramework.AdminConsole.Models.Provider.Provider", "Provider") b.HasOne("Bit.Infrastructure.EntityFramework.AdminConsole.Models.Provider.Provider", "Provider")

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,57 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.SqliteMigrations.Migrations;
/// <inheritdoc />
public partial class ProviderInvoiceItem : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ProviderInvoiceItem",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
ProviderId = table.Column<Guid>(type: "TEXT", nullable: false),
InvoiceId = table.Column<string>(type: "TEXT", nullable: true),
InvoiceNumber = table.Column<string>(type: "TEXT", nullable: true),
ClientName = table.Column<string>(type: "TEXT", nullable: true),
PlanName = table.Column<string>(type: "TEXT", nullable: true),
AssignedSeats = table.Column<int>(type: "INTEGER", nullable: false),
UsedSeats = table.Column<int>(type: "INTEGER", nullable: false),
Total = table.Column<decimal>(type: "TEXT", nullable: false),
Created = table.Column<DateTime>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ProviderInvoiceItem", x => x.Id);
table.ForeignKey(
name: "FK_ProviderInvoiceItem_Provider_ProviderId",
column: x => x.ProviderId,
principalTable: "Provider",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_ProviderInvoiceItem_Id_InvoiceId",
table: "ProviderInvoiceItem",
columns: new[] { "Id", "InvoiceId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_ProviderInvoiceItem_ProviderId",
table: "ProviderInvoiceItem",
column: "ProviderId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ProviderInvoiceItem");
}
}

View File

@ -671,6 +671,48 @@ namespace Bit.SqliteMigrations.Migrations
b.ToTable("WebAuthnCredential", (string)null); b.ToTable("WebAuthnCredential", (string)null);
}); });
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Billing.Models.ProviderInvoiceItem", b =>
{
b.Property<Guid>("Id")
.HasColumnType("TEXT");
b.Property<int>("AssignedSeats")
.HasColumnType("INTEGER");
b.Property<string>("ClientName")
.HasColumnType("TEXT");
b.Property<DateTime>("Created")
.HasColumnType("TEXT");
b.Property<string>("InvoiceId")
.HasColumnType("TEXT");
b.Property<string>("InvoiceNumber")
.HasColumnType("TEXT");
b.Property<string>("PlanName")
.HasColumnType("TEXT");
b.Property<Guid>("ProviderId")
.HasColumnType("TEXT");
b.Property<decimal>("Total")
.HasColumnType("TEXT");
b.Property<int>("UsedSeats")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("ProviderId");
b.HasIndex("Id", "InvoiceId")
.IsUnique();
b.ToTable("ProviderInvoiceItem", (string)null);
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Billing.Models.ProviderPlan", b => modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Billing.Models.ProviderPlan", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
@ -2048,6 +2090,17 @@ namespace Bit.SqliteMigrations.Migrations
b.Navigation("User"); b.Navigation("User");
}); });
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Billing.Models.ProviderInvoiceItem", b =>
{
b.HasOne("Bit.Infrastructure.EntityFramework.AdminConsole.Models.Provider.Provider", "Provider")
.WithMany()
.HasForeignKey("ProviderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Provider");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Billing.Models.ProviderPlan", b => modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Billing.Models.ProviderPlan", b =>
{ {
b.HasOne("Bit.Infrastructure.EntityFramework.AdminConsole.Models.Provider.Provider", "Provider") b.HasOne("Bit.Infrastructure.EntityFramework.AdminConsole.Models.Provider.Provider", "Provider")