1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 16:12:49 -05:00

Merge branch 'main' into ac/ac-1682/ef-migrations

This commit is contained in:
Rui Tome
2024-03-22 11:53:01 +00:00
142 changed files with 17858 additions and 918 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.MySqlMigrations.Migrations;
/// <inheritdoc />
public partial class AddCipherIdToSend : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "CipherId",
table: "Send",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "CipherId",
table: "Send");
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,117 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.MySqlMigrations.Migrations;
/// <inheritdoc />
public partial class SetupProviderBilling : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "ProviderId",
table: "Transaction",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<string>(
name: "GatewayCustomerId",
table: "Provider",
type: "longtext",
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "GatewaySubscriptionId",
table: "Provider",
type: "longtext",
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<byte>(
name: "GatewayType",
table: "Provider",
type: "tinyint unsigned",
nullable: true);
migrationBuilder.CreateTable(
name: "ProviderPlan",
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"),
PlanType = table.Column<byte>(type: "tinyint unsigned", nullable: false),
SeatMinimum = table.Column<int>(type: "int", nullable: true),
PurchasedSeats = table.Column<int>(type: "int", nullable: true),
AllocatedSeats = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ProviderPlan", x => x.Id);
table.ForeignKey(
name: "FK_ProviderPlan_Provider_ProviderId",
column: x => x.ProviderId,
principalTable: "Provider",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_Transaction_ProviderId",
table: "Transaction",
column: "ProviderId");
migrationBuilder.CreateIndex(
name: "IX_ProviderPlan_Id_PlanType",
table: "ProviderPlan",
columns: new[] { "Id", "PlanType" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_ProviderPlan_ProviderId",
table: "ProviderPlan",
column: "ProviderId");
migrationBuilder.AddForeignKey(
name: "FK_Transaction_Provider_ProviderId",
table: "Transaction",
column: "ProviderId",
principalTable: "Provider",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Transaction_Provider_ProviderId",
table: "Transaction");
migrationBuilder.DropTable(
name: "ProviderPlan");
migrationBuilder.DropIndex(
name: "IX_Transaction_ProviderId",
table: "Transaction");
migrationBuilder.DropColumn(
name: "ProviderId",
table: "Transaction");
migrationBuilder.DropColumn(
name: "GatewayCustomerId",
table: "Provider");
migrationBuilder.DropColumn(
name: "GatewaySubscriptionId",
table: "Provider");
migrationBuilder.DropColumn(
name: "GatewayType",
table: "Provider");
}
}

View File

@ -4,7 +4,6 @@ using Bit.Infrastructure.EntityFramework.Repositories;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
@ -17,7 +16,7 @@ namespace Bit.MySqlMigrations.Migrations
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.15")
.HasAnnotation("ProductVersion", "7.0.16")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.AdminConsole.Models.Organization", b =>
@ -277,6 +276,15 @@ namespace Bit.MySqlMigrations.Migrations
b.Property<bool>("Enabled")
.HasColumnType("tinyint(1)");
b.Property<string>("GatewayCustomerId")
.HasColumnType("longtext");
b.Property<string>("GatewaySubscriptionId")
.HasColumnType("longtext");
b.Property<byte?>("GatewayType")
.HasColumnType("tinyint unsigned");
b.Property<string>("Name")
.HasColumnType("longtext");
@ -486,8 +494,7 @@ namespace Bit.MySqlMigrations.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
.HasColumnType("int");
b.Property<string>("ClientId")
.IsRequired()
@ -666,6 +673,36 @@ namespace Bit.MySqlMigrations.Migrations
b.ToTable("WebAuthnCredential", (string)null);
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Billing.Models.ProviderPlan", b =>
{
b.Property<Guid>("Id")
.HasColumnType("char(36)");
b.Property<int?>("AllocatedSeats")
.HasColumnType("int");
b.Property<byte>("PlanType")
.HasColumnType("tinyint unsigned");
b.Property<Guid>("ProviderId")
.HasColumnType("char(36)");
b.Property<int?>("PurchasedSeats")
.HasColumnType("int");
b.Property<int?>("SeatMinimum")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ProviderId");
b.HasIndex("Id", "PlanType")
.IsUnique();
b.ToTable("ProviderPlan", (string)null);
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Collection", b =>
{
b.Property<Guid>("Id")
@ -1157,6 +1194,9 @@ namespace Bit.MySqlMigrations.Migrations
b.Property<int>("AccessCount")
.HasColumnType("int");
b.Property<Guid?>("CipherId")
.HasColumnType("char(36)");
b.Property<DateTime>("CreationDate")
.HasColumnType("datetime(6)");
@ -1270,6 +1310,9 @@ namespace Bit.MySqlMigrations.Migrations
b.Property<byte?>("PaymentMethodType")
.HasColumnType("tinyint unsigned");
b.Property<Guid?>("ProviderId")
.HasColumnType("char(36)");
b.Property<bool?>("Refunded")
.HasColumnType("tinyint(1)");
@ -1286,6 +1329,8 @@ namespace Bit.MySqlMigrations.Migrations
b.HasIndex("OrganizationId");
b.HasIndex("ProviderId");
b.HasIndex("UserId")
.HasAnnotation("SqlServer:Clustered", false);
@ -2005,6 +2050,17 @@ namespace Bit.MySqlMigrations.Migrations
b.Navigation("User");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Billing.Models.ProviderPlan", 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.Models.Collection", b =>
{
b.HasOne("Bit.Infrastructure.EntityFramework.AdminConsole.Models.Organization", "Organization")
@ -2200,12 +2256,18 @@ namespace Bit.MySqlMigrations.Migrations
.WithMany("Transactions")
.HasForeignKey("OrganizationId");
b.HasOne("Bit.Infrastructure.EntityFramework.AdminConsole.Models.Provider.Provider", "Provider")
.WithMany()
.HasForeignKey("ProviderId");
b.HasOne("Bit.Infrastructure.EntityFramework.Models.User", "User")
.WithMany("Transactions")
.HasForeignKey("UserId");
b.Navigation("Organization");
b.Navigation("Provider");
b.Navigation("User");
});