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

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

This commit is contained in:
Rui Tome
2024-01-12 12:02:14 +00:00
166 changed files with 33487 additions and 1600 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,119 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.SqliteMigrations.Migrations;
/// <inheritdoc />
public partial class GrantIdWithIndexes : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropPrimaryKey(
name: "PK_Grant",
table: "Grant");
migrationBuilder.AlterColumn<string>(
name: "Type",
table: "Grant",
type: "TEXT",
maxLength: 50,
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "TEXT",
oldMaxLength: 50,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Data",
table: "Grant",
type: "TEXT",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "TEXT",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "ClientId",
table: "Grant",
type: "TEXT",
maxLength: 200,
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "TEXT",
oldMaxLength: 200,
oldNullable: true);
migrationBuilder.AddColumn<int>(
name: "Id",
table: "Grant",
type: "INTEGER",
nullable: false,
defaultValue: 0)
.Annotation("Sqlite:Autoincrement", true);
migrationBuilder.AddPrimaryKey(
name: "PK_Grant",
table: "Grant",
column: "Id");
migrationBuilder.CreateIndex(
name: "IX_Grant_Key",
table: "Grant",
column: "Key",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropPrimaryKey(
name: "PK_Grant",
table: "Grant");
migrationBuilder.DropIndex(
name: "IX_Grant_Key",
table: "Grant");
migrationBuilder.DropColumn(
name: "Id",
table: "Grant");
migrationBuilder.AlterColumn<string>(
name: "Type",
table: "Grant",
type: "TEXT",
maxLength: 50,
nullable: true,
oldClrType: typeof(string),
oldType: "TEXT",
oldMaxLength: 50);
migrationBuilder.AlterColumn<string>(
name: "Data",
table: "Grant",
type: "TEXT",
nullable: true,
oldClrType: typeof(string),
oldType: "TEXT");
migrationBuilder.AlterColumn<string>(
name: "ClientId",
table: "Grant",
type: "TEXT",
maxLength: 200,
nullable: true,
oldClrType: typeof(string),
oldType: "TEXT",
oldMaxLength: 200);
migrationBuilder.AddPrimaryKey(
name: "PK_Grant",
table: "Grant",
column: "Key");
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,35 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.SqliteMigrations.Migrations;
/// <inheritdoc />
public partial class AddToolsTableIndexes : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_Send_DeletionDate",
table: "Send",
column: "DeletionDate");
migrationBuilder.CreateIndex(
name: "IX_Send_UserId_OrganizationId",
table: "Send",
columns: new[] { "UserId", "OrganizationId" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Send_DeletionDate",
table: "Send");
migrationBuilder.DropIndex(
name: "IX_Send_UserId_OrganizationId",
table: "Send");
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,110 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.SqliteMigrations.Migrations;
/// <inheritdoc />
public partial class AddTableIndexes : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_User_Email",
table: "User",
column: "Email",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_User_Premium_PremiumExpirationDate_RenewalReminderDate",
table: "User",
columns: new[] { "Premium", "PremiumExpirationDate", "RenewalReminderDate" });
migrationBuilder.CreateIndex(
name: "IX_Transaction_UserId_OrganizationId_CreationDate",
table: "Transaction",
columns: new[] { "UserId", "OrganizationId", "CreationDate" });
migrationBuilder.CreateIndex(
name: "IX_Policy_OrganizationId_Type",
table: "Policy",
columns: new[] { "OrganizationId", "Type" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_OrganizationUser_UserId_OrganizationId_Status",
table: "OrganizationUser",
columns: new[] { "UserId", "OrganizationId", "Status" });
migrationBuilder.CreateIndex(
name: "IX_OrganizationSponsorship_SponsoringOrganizationUserId",
table: "OrganizationSponsorship",
column: "SponsoringOrganizationUserId");
migrationBuilder.CreateIndex(
name: "IX_Organization_Id_Enabled",
table: "Organization",
columns: new[] { "Id", "Enabled" });
migrationBuilder.CreateIndex(
name: "IX_Event_Date_OrganizationId_ActingUserId_CipherId",
table: "Event",
columns: new[] { "Date", "OrganizationId", "ActingUserId", "CipherId" });
migrationBuilder.CreateIndex(
name: "IX_Device_Identifier",
table: "Device",
column: "Identifier");
migrationBuilder.CreateIndex(
name: "IX_Device_UserId_Identifier",
table: "Device",
columns: new[] { "UserId", "Identifier" },
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_User_Email",
table: "User");
migrationBuilder.DropIndex(
name: "IX_User_Premium_PremiumExpirationDate_RenewalReminderDate",
table: "User");
migrationBuilder.DropIndex(
name: "IX_Transaction_UserId_OrganizationId_CreationDate",
table: "Transaction");
migrationBuilder.DropIndex(
name: "IX_Policy_OrganizationId_Type",
table: "Policy");
migrationBuilder.DropIndex(
name: "IX_OrganizationUser_UserId_OrganizationId_Status",
table: "OrganizationUser");
migrationBuilder.DropIndex(
name: "IX_OrganizationSponsorship_SponsoringOrganizationUserId",
table: "OrganizationSponsorship");
migrationBuilder.DropIndex(
name: "IX_Organization_Id_Enabled",
table: "Organization");
migrationBuilder.DropIndex(
name: "IX_Event_Date_OrganizationId_ActingUserId_CipherId",
table: "Event");
migrationBuilder.DropIndex(
name: "IX_Device_Identifier",
table: "Device");
migrationBuilder.DropIndex(
name: "IX_Device_UserId_Identifier",
table: "Device");
}
}

View File

@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.SqliteMigrations.Migrations;
/// <inheritdoc />
public partial class OrganizationFlexibleCollectionsColumn : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "FlexibleCollections",
table: "Organization",
type: "INTEGER",
nullable: false,
defaultValue: false);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "FlexibleCollections",
table: "Organization");
}
}

View File

@ -63,6 +63,9 @@ namespace Bit.SqliteMigrations.Migrations
b.Property<DateTime?>("ExpirationDate")
.HasColumnType("TEXT");
b.Property<bool>("FlexibleCollections")
.HasColumnType("INTEGER");
b.Property<byte?>("Gateway")
.HasColumnType("INTEGER");
@ -198,6 +201,9 @@ namespace Bit.SqliteMigrations.Migrations
b.HasKey("Id");
b.HasIndex("Id", "Enabled")
.HasAnnotation("Npgsql:IndexInclude", new[] { "UseTotp" });
b.ToTable("Organization", (string)null);
});
@ -226,7 +232,12 @@ namespace Bit.SqliteMigrations.Migrations
b.HasKey("Id");
b.HasIndex("OrganizationId");
b.HasIndex("OrganizationId")
.HasAnnotation("SqlServer:Clustered", false);
b.HasIndex("OrganizationId", "Type")
.IsUnique()
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("Policy", (string)null);
});
@ -473,11 +484,13 @@ namespace Bit.SqliteMigrations.Migrations
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Auth.Models.Grant", b =>
{
b.Property<string>("Key")
.HasMaxLength(200)
.HasColumnType("TEXT");
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasAnnotation("Sqlite:Autoincrement", true);
b.Property<string>("ClientId")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("TEXT");
@ -488,6 +501,7 @@ namespace Bit.SqliteMigrations.Migrations
.HasColumnType("TEXT");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Description")
@ -497,6 +511,11 @@ namespace Bit.SqliteMigrations.Migrations
b.Property<DateTime?>("ExpirationDate")
.HasColumnType("TEXT");
b.Property<string>("Key")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("TEXT");
b.Property<string>("SessionId")
.HasMaxLength(100)
.HasColumnType("TEXT");
@ -506,10 +525,15 @@ namespace Bit.SqliteMigrations.Migrations
.HasColumnType("TEXT");
b.Property<string>("Type")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("TEXT");
b.HasKey("Key");
b.HasKey("Id")
.HasAnnotation("SqlServer:Clustered", true);
b.HasIndex("Key")
.IsUnique();
b.ToTable("Grant", (string)null);
});
@ -760,7 +784,15 @@ namespace Bit.SqliteMigrations.Migrations
b.HasKey("Id");
b.HasIndex("UserId");
b.HasIndex("Identifier")
.HasAnnotation("SqlServer:Clustered", false);
b.HasIndex("UserId")
.HasAnnotation("SqlServer:Clustered", false);
b.HasIndex("UserId", "Identifier")
.IsUnique()
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("Device", (string)null);
});
@ -833,6 +865,9 @@ namespace Bit.SqliteMigrations.Migrations
b.HasKey("Id");
b.HasIndex("Date", "OrganizationId", "ActingUserId", "CipherId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("Event", (string)null);
});
@ -1033,6 +1068,9 @@ namespace Bit.SqliteMigrations.Migrations
b.HasIndex("SponsoringOrganizationId");
b.HasIndex("SponsoringOrganizationUserId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("OrganizationSponsorship", (string)null);
});
@ -1084,9 +1122,15 @@ namespace Bit.SqliteMigrations.Migrations
b.HasKey("Id");
b.HasIndex("OrganizationId");
b.HasIndex("OrganizationId")
.HasAnnotation("SqlServer:Clustered", false);
b.HasIndex("UserId");
b.HasIndex("UserId")
.HasAnnotation("SqlServer:Clustered", false);
b.HasIndex("UserId", "OrganizationId", "Status")
.HasAnnotation("Npgsql:IndexInclude", new[] { "AccessAll" })
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("OrganizationUser", (string)null);
});
@ -1141,9 +1185,16 @@ namespace Bit.SqliteMigrations.Migrations
b.HasKey("Id");
b.HasIndex("DeletionDate")
.HasAnnotation("SqlServer:Clustered", false);
b.HasIndex("OrganizationId");
b.HasIndex("UserId");
b.HasIndex("UserId")
.HasAnnotation("SqlServer:Clustered", false);
b.HasIndex("UserId", "OrganizationId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("Send", (string)null);
});
@ -1221,7 +1272,11 @@ namespace Bit.SqliteMigrations.Migrations
b.HasIndex("OrganizationId");
b.HasIndex("UserId");
b.HasIndex("UserId")
.HasAnnotation("SqlServer:Clustered", false);
b.HasIndex("UserId", "OrganizationId", "CreationDate")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("Transaction", (string)null);
});
@ -1371,6 +1426,13 @@ namespace Bit.SqliteMigrations.Migrations
b.HasKey("Id");
b.HasIndex("Email")
.IsUnique()
.HasAnnotation("SqlServer:Clustered", false);
b.HasIndex("Premium", "PremiumExpirationDate", "RenewalReminderDate")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("User", (string)null);
});