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

[AC-1682] Bumped up the dates on the migration scripts

This commit is contained in:
Rui Tome
2024-01-12 12:54:34 +00:00
parent 5c08d181a4
commit 19fb7e583e
40 changed files with 7988 additions and 145 deletions

View File

@ -1,28 +0,0 @@
-- Step 1: Create a temporary table to store the groups with AccessAll = 1
CREATE TEMPORARY TABLE IF NOT EXISTS TempGroup AS
SELECT `Id` AS `GroupId`, `OrganizationId`
FROM `Group`
WHERE `AccessAll` = 1;
-- Step 2: Update existing rows in `CollectionGroup`
UPDATE `CollectionGroups` CG
INNER JOIN `Collection` C ON CG.`CollectionId` = C.`Id`
INNER JOIN TempGroup TG ON CG.`GroupId` = TG.`GroupId`
SET
CG.`ReadOnly` = 0,
CG.`HidePasswords` = 0,
CG.`Manage` = 0
WHERE C.`OrganizationId` = TG.`OrganizationId`;
-- Step 3: Insert new rows into `CollectionGroup`
INSERT INTO `CollectionGroups` (`CollectionId`, `GroupId`, `ReadOnly`, `HidePasswords`, `Manage`)
SELECT C.`Id`, TG.`GroupId`, 0, 0, 0
FROM `Collection` C
INNER JOIN TempGroup TG
ON C.`OrganizationId` = TG.`OrganizationId`
LEFT JOIN `CollectionGroups` CG
ON CG.`CollectionId` = C.`Id` AND CG.`GroupId` = TG.`GroupId`
WHERE CG.`CollectionId` IS NULL;
-- Step 4: Drop the temporary table
DROP TEMPORARY TABLE IF EXISTS TempGroup;

View File

@ -0,0 +1,66 @@
-- Step 1: Create a temporary table to store the groups with AccessAll = 1
CREATE TEMPORARY TABLE IF NOT EXISTS TempGroup AS
SELECT `Id` AS `GroupId`, `OrganizationId`
FROM `Group`
WHERE `AccessAll` = 1;
-- Step 2: Create a temporary table to store distinct OrganizationUserIds
CREATE TEMPORARY TABLE IF NOT EXISTS TempOrganizationUsers AS
SELECT DISTINCT GU.`OrganizationUserId`
FROM `GroupUser` GU
JOIN TempGroup TG ON GU.`GroupId` = TG.`GroupId`;
-- Step 3: Update existing rows in `CollectionGroups`
UPDATE `CollectionGroups` CG
INNER JOIN `Collection` C ON CG.`CollectionId` = C.`Id`
INNER JOIN TempGroup TG ON CG.`GroupId` = TG.`GroupId`
SET
CG.`ReadOnly` = 0,
CG.`HidePasswords` = 0,
CG.`Manage` = 0
WHERE C.`OrganizationId` = TG.`OrganizationId`;
-- Step 4: Insert new rows into `CollectionGroups`
INSERT INTO `CollectionGroups` (`CollectionId`, `GroupId`, `ReadOnly`, `HidePasswords`, `Manage`)
SELECT C.`Id`, TG.`GroupId`, 0, 0, 0
FROM `Collection` C
INNER JOIN TempGroup TG
ON C.`OrganizationId` = TG.`OrganizationId`
LEFT JOIN `CollectionGroups` CG
ON CG.`CollectionId` = C.`Id` AND CG.`GroupId` = TG.`GroupId`
WHERE CG.`CollectionId` IS NULL;
-- Step 5: Update Group to clear AccessAll flag
UPDATE `Group` G
INNER JOIN TempGroup TG ON G.`Id` = TG.`GroupId`
SET G.`AccessAll` = 0;
-- Step 6: Update User AccountRevisionDate for each unique OrganizationUserId
DECLARE Step1OrganizationUserId UUID;
DECLARE UniqueOrgUserIdCursor CURSOR FOR
SELECT `OrganizationUserId`
FROM TempOrganizationUsers;
OPEN UniqueOrgUserIdCursor;
FETCH NEXT FROM UniqueOrgUserIdCursor INTO Step1OrganizationUserId;
WHILE (FETCH_STATUS = 0) DO
-- Update User AccountRevisionDate for the current OrganizationUserId
UPDATE `User` U
SET U.`AccountRevisionDate` = UTC_TIMESTAMP()
FROM `User` U
INNER JOIN `OrganizationUser` OU ON OU.`UserId` = U.`Id`
WHERE OU.`Id` = Step1OrganizationUserId
AND OU.`Status` = 2;
-- Fetch the next row
FETCH NEXT FROM UniqueOrgUserIdCursor INTO Step1OrganizationUserId;
END WHILE;
CLOSE UniqueOrgUserIdCursor;
DEALLOCATE UniqueOrgUserIdCursor;
-- Step 7: Drop the temporary tables
DROP TEMPORARY TABLE IF EXISTS TempGroup;
DROP TEMPORARY TABLE IF EXISTS TempOrganizationUsers;

View File

@ -5,13 +5,14 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Bit.MySqlMigrations.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20231219154701_FCAccessAllCollectionGroups")]
[Migration("20240112123253_FCAccessAllCollectionGroups")]
partial class FCAccessAllCollectionGroups
{
/// <inheritdoc />
@ -68,6 +69,9 @@ namespace Bit.MySqlMigrations.Migrations
b.Property<DateTime?>("ExpirationDate")
.HasColumnType("datetime(6)");
b.Property<bool>("FlexibleCollections")
.HasColumnType("tinyint(1)");
b.Property<byte?>("Gateway")
.HasColumnType("tinyint unsigned");
@ -203,6 +207,9 @@ namespace Bit.MySqlMigrations.Migrations
b.HasKey("Id");
b.HasIndex("Id", "Enabled")
.HasAnnotation("Npgsql:IndexInclude", new[] { "UseTotp" });
b.ToTable("Organization", (string)null);
});
@ -231,7 +238,12 @@ namespace Bit.MySqlMigrations.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);
});
@ -478,11 +490,13 @@ namespace Bit.MySqlMigrations.Migrations
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Auth.Models.Grant", b =>
{
b.Property<string>("Key")
.HasMaxLength(200)
.HasColumnType("varchar(200)");
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("ClientId")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)");
@ -493,6 +507,7 @@ namespace Bit.MySqlMigrations.Migrations
.HasColumnType("datetime(6)");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Description")
@ -502,6 +517,11 @@ namespace Bit.MySqlMigrations.Migrations
b.Property<DateTime?>("ExpirationDate")
.HasColumnType("datetime(6)");
b.Property<string>("Key")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)");
b.Property<string>("SessionId")
.HasMaxLength(100)
.HasColumnType("varchar(100)");
@ -511,10 +531,15 @@ namespace Bit.MySqlMigrations.Migrations
.HasColumnType("varchar(200)");
b.Property<string>("Type")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.HasKey("Key");
b.HasKey("Id")
.HasAnnotation("SqlServer:Clustered", true);
b.HasIndex("Key")
.IsUnique();
b.ToTable("Grant", (string)null);
});
@ -765,7 +790,15 @@ namespace Bit.MySqlMigrations.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);
});
@ -838,6 +871,9 @@ namespace Bit.MySqlMigrations.Migrations
b.HasKey("Id");
b.HasIndex("Date", "OrganizationId", "ActingUserId", "CipherId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("Event", (string)null);
});
@ -1038,6 +1074,9 @@ namespace Bit.MySqlMigrations.Migrations
b.HasIndex("SponsoringOrganizationId");
b.HasIndex("SponsoringOrganizationUserId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("OrganizationSponsorship", (string)null);
});
@ -1089,9 +1128,15 @@ namespace Bit.MySqlMigrations.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);
});
@ -1146,9 +1191,16 @@ namespace Bit.MySqlMigrations.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);
});
@ -1226,7 +1278,11 @@ namespace Bit.MySqlMigrations.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);
});
@ -1376,6 +1432,13 @@ namespace Bit.MySqlMigrations.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);
});

View File

@ -7,7 +7,7 @@ namespace Bit.MySqlMigrations.Migrations;
public partial class FCAccessAllCollectionGroups : Migration
{
private const string _accessAllCollectionGroupsScript = "MySqlMigrations.HelperScripts.2023-12-06_00_AccessAllCollectionGroups.sql";
private const string _accessAllCollectionGroupsScript = "MySqlMigrations.HelperScripts.2024-01-12_00_AccessAllCollectionGroups.sql";
protected override void Up(MigrationBuilder migrationBuilder)
{

View File

@ -5,13 +5,14 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Bit.MySqlMigrations.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20231219154733_FCAccessAllCollectionUsers")]
[Migration("20240112123310_FCAccessAllCollectionUsers")]
partial class FCAccessAllCollectionUsers
{
/// <inheritdoc />
@ -68,6 +69,9 @@ namespace Bit.MySqlMigrations.Migrations
b.Property<DateTime?>("ExpirationDate")
.HasColumnType("datetime(6)");
b.Property<bool>("FlexibleCollections")
.HasColumnType("tinyint(1)");
b.Property<byte?>("Gateway")
.HasColumnType("tinyint unsigned");
@ -203,6 +207,9 @@ namespace Bit.MySqlMigrations.Migrations
b.HasKey("Id");
b.HasIndex("Id", "Enabled")
.HasAnnotation("Npgsql:IndexInclude", new[] { "UseTotp" });
b.ToTable("Organization", (string)null);
});
@ -231,7 +238,12 @@ namespace Bit.MySqlMigrations.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);
});
@ -478,11 +490,13 @@ namespace Bit.MySqlMigrations.Migrations
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Auth.Models.Grant", b =>
{
b.Property<string>("Key")
.HasMaxLength(200)
.HasColumnType("varchar(200)");
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("ClientId")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)");
@ -493,6 +507,7 @@ namespace Bit.MySqlMigrations.Migrations
.HasColumnType("datetime(6)");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Description")
@ -502,6 +517,11 @@ namespace Bit.MySqlMigrations.Migrations
b.Property<DateTime?>("ExpirationDate")
.HasColumnType("datetime(6)");
b.Property<string>("Key")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)");
b.Property<string>("SessionId")
.HasMaxLength(100)
.HasColumnType("varchar(100)");
@ -511,10 +531,15 @@ namespace Bit.MySqlMigrations.Migrations
.HasColumnType("varchar(200)");
b.Property<string>("Type")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.HasKey("Key");
b.HasKey("Id")
.HasAnnotation("SqlServer:Clustered", true);
b.HasIndex("Key")
.IsUnique();
b.ToTable("Grant", (string)null);
});
@ -765,7 +790,15 @@ namespace Bit.MySqlMigrations.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);
});
@ -838,6 +871,9 @@ namespace Bit.MySqlMigrations.Migrations
b.HasKey("Id");
b.HasIndex("Date", "OrganizationId", "ActingUserId", "CipherId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("Event", (string)null);
});
@ -1038,6 +1074,9 @@ namespace Bit.MySqlMigrations.Migrations
b.HasIndex("SponsoringOrganizationId");
b.HasIndex("SponsoringOrganizationUserId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("OrganizationSponsorship", (string)null);
});
@ -1089,9 +1128,15 @@ namespace Bit.MySqlMigrations.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);
});
@ -1146,9 +1191,16 @@ namespace Bit.MySqlMigrations.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);
});
@ -1226,7 +1278,11 @@ namespace Bit.MySqlMigrations.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);
});
@ -1376,6 +1432,13 @@ namespace Bit.MySqlMigrations.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);
});

View File

@ -7,7 +7,7 @@ namespace Bit.MySqlMigrations.Migrations;
public partial class FCAccessAllCollectionUsers : Migration
{
private const string _accessAllCollectionUsersScript = "MySqlMigrations.HelperScripts.2023-12-06_01_AccessAllCollectionUsers.sql";
private const string _accessAllCollectionUsersScript = "MySqlMigrations.HelperScripts.2024-01-12_01_AccessAllCollectionUsers.sql";
protected override void Up(MigrationBuilder migrationBuilder)
{

View File

@ -5,13 +5,14 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Bit.MySqlMigrations.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20231219154825_FCManagersEditAssignedCollectionUsers")]
[Migration("20240112123340_FCManagersEditAssignedCollectionUsers")]
partial class FCManagersEditAssignedCollectionUsers
{
/// <inheritdoc />
@ -68,6 +69,9 @@ namespace Bit.MySqlMigrations.Migrations
b.Property<DateTime?>("ExpirationDate")
.HasColumnType("datetime(6)");
b.Property<bool>("FlexibleCollections")
.HasColumnType("tinyint(1)");
b.Property<byte?>("Gateway")
.HasColumnType("tinyint unsigned");
@ -203,6 +207,9 @@ namespace Bit.MySqlMigrations.Migrations
b.HasKey("Id");
b.HasIndex("Id", "Enabled")
.HasAnnotation("Npgsql:IndexInclude", new[] { "UseTotp" });
b.ToTable("Organization", (string)null);
});
@ -231,7 +238,12 @@ namespace Bit.MySqlMigrations.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);
});
@ -478,11 +490,13 @@ namespace Bit.MySqlMigrations.Migrations
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Auth.Models.Grant", b =>
{
b.Property<string>("Key")
.HasMaxLength(200)
.HasColumnType("varchar(200)");
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("ClientId")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)");
@ -493,6 +507,7 @@ namespace Bit.MySqlMigrations.Migrations
.HasColumnType("datetime(6)");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Description")
@ -502,6 +517,11 @@ namespace Bit.MySqlMigrations.Migrations
b.Property<DateTime?>("ExpirationDate")
.HasColumnType("datetime(6)");
b.Property<string>("Key")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)");
b.Property<string>("SessionId")
.HasMaxLength(100)
.HasColumnType("varchar(100)");
@ -511,10 +531,15 @@ namespace Bit.MySqlMigrations.Migrations
.HasColumnType("varchar(200)");
b.Property<string>("Type")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.HasKey("Key");
b.HasKey("Id")
.HasAnnotation("SqlServer:Clustered", true);
b.HasIndex("Key")
.IsUnique();
b.ToTable("Grant", (string)null);
});
@ -765,7 +790,15 @@ namespace Bit.MySqlMigrations.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);
});
@ -838,6 +871,9 @@ namespace Bit.MySqlMigrations.Migrations
b.HasKey("Id");
b.HasIndex("Date", "OrganizationId", "ActingUserId", "CipherId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("Event", (string)null);
});
@ -1038,6 +1074,9 @@ namespace Bit.MySqlMigrations.Migrations
b.HasIndex("SponsoringOrganizationId");
b.HasIndex("SponsoringOrganizationUserId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("OrganizationSponsorship", (string)null);
});
@ -1089,9 +1128,15 @@ namespace Bit.MySqlMigrations.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);
});
@ -1146,9 +1191,16 @@ namespace Bit.MySqlMigrations.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);
});
@ -1226,7 +1278,11 @@ namespace Bit.MySqlMigrations.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);
});
@ -1376,6 +1432,13 @@ namespace Bit.MySqlMigrations.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);
});

View File

@ -7,7 +7,7 @@ namespace Bit.MySqlMigrations.Migrations;
public partial class FCManagersEditAssignedCollectionUsers : Migration
{
private const string _managersEditAssignedCollectionUsersScript = "MySqlMigrations.HelperScripts.2023-12-06_02_ManagersEditAssignedCollectionUsers.sql";
private const string _managersEditAssignedCollectionUsersScript = "MySqlMigrations.HelperScripts.2024-01-12_02_ManagersEditAssignedCollectionUsers.sql";
protected override void Up(MigrationBuilder migrationBuilder)
{

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,21 @@
using Bit.Core.Utilities;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.MySqlMigrations.Migrations;
public partial class FCEnableOrgsFlexibleCollections : Migration
{
private const string _enableOrgsFlexibleCollectionsScript = "MySqlMigrations.HelperScripts.2024-01-12_03_EnableOrgsFlexibleCollections.sql";
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(CoreHelpers.GetEmbeddedResourceContentsAsync(_enableOrgsFlexibleCollectionsScript));
}
protected override void Down(MigrationBuilder migrationBuilder)
{
throw new Exception("Irreversible migration");
}
}

View File

@ -29,8 +29,9 @@
<EmbeddedResource Include="HelperScripts\2021-10-21_00_SetMaxAutoscaleSeatCount.sql" />
<EmbeddedResource Include="HelperScripts\2022-03-01_00_Up_MigrateOrganizationApiKeys.sql" />
<EmbeddedResource Include="HelperScripts\2022-03-01_00_Down_MigrateOrganizationApiKeys.sql" />
<EmbeddedResource Include="HelperScripts\2023-12-06_00_AccessAllCollectionGroups.sql" />
<EmbeddedResource Include="HelperScripts\2023-12-06_01_AccessAllCollectionUsers.sql" />
<EmbeddedResource Include="HelperScripts\2023-12-06_02_ManagersEditAssignedCollectionUsers.sql" />
<EmbeddedResource Include="HelperScripts\2024-01-12_00_AccessAllCollectionGroups.sql" />
<EmbeddedResource Include="HelperScripts\2024-01-12_01_AccessAllCollectionUsers.sql" />
<EmbeddedResource Include="HelperScripts\2024-01-12_02_ManagersEditAssignedCollectionUsers.sql" />
<EmbeddedResource Include="HelperScripts\2024-01-12_03_EnableOrgsFlexibleCollections.sql" />
</ItemGroup>
</Project>

View File

@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace Bit.PostgresMigrations.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20231219154705_FCAccessAllCollectionGroups")]
[Migration("20240112123257_FCAccessAllCollectionGroups")]
partial class FCAccessAllCollectionGroups
{
/// <inheritdoc />
@ -72,6 +72,9 @@ namespace Bit.PostgresMigrations.Migrations
b.Property<DateTime?>("ExpirationDate")
.HasColumnType("timestamp with time zone");
b.Property<bool>("FlexibleCollections")
.HasColumnType("boolean");
b.Property<byte?>("Gateway")
.HasColumnType("smallint");
@ -208,6 +211,10 @@ namespace Bit.PostgresMigrations.Migrations
b.HasKey("Id");
b.HasIndex("Id", "Enabled");
NpgsqlIndexBuilderExtensions.IncludeProperties(b.HasIndex("Id", "Enabled"), new[] { "UseTotp" });
b.ToTable("Organization", (string)null);
});
@ -236,7 +243,12 @@ namespace Bit.PostgresMigrations.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);
});
@ -483,11 +495,14 @@ namespace Bit.PostgresMigrations.Migrations
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Auth.Models.Grant", b =>
{
b.Property<string>("Key")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClientId")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
@ -498,6 +513,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("timestamp with time zone");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Description")
@ -507,6 +523,11 @@ namespace Bit.PostgresMigrations.Migrations
b.Property<DateTime?>("ExpirationDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Key")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("SessionId")
.HasMaxLength(100)
.HasColumnType("character varying(100)");
@ -516,10 +537,15 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("character varying(200)");
b.Property<string>("Type")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.HasKey("Key");
b.HasKey("Id")
.HasAnnotation("SqlServer:Clustered", true);
b.HasIndex("Key")
.IsUnique();
b.ToTable("Grant", (string)null);
});
@ -775,7 +801,15 @@ namespace Bit.PostgresMigrations.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);
});
@ -848,6 +882,9 @@ namespace Bit.PostgresMigrations.Migrations
b.HasKey("Id");
b.HasIndex("Date", "OrganizationId", "ActingUserId", "CipherId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("Event", (string)null);
});
@ -1048,6 +1085,9 @@ namespace Bit.PostgresMigrations.Migrations
b.HasIndex("SponsoringOrganizationId");
b.HasIndex("SponsoringOrganizationUserId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("OrganizationSponsorship", (string)null);
});
@ -1099,9 +1139,16 @@ namespace Bit.PostgresMigrations.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("SqlServer:Clustered", false);
NpgsqlIndexBuilderExtensions.IncludeProperties(b.HasIndex("UserId", "OrganizationId", "Status"), new[] { "AccessAll" });
b.ToTable("OrganizationUser", (string)null);
});
@ -1156,9 +1203,16 @@ namespace Bit.PostgresMigrations.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);
});
@ -1236,7 +1290,11 @@ namespace Bit.PostgresMigrations.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);
});
@ -1387,6 +1445,13 @@ namespace Bit.PostgresMigrations.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);
});

View File

@ -7,7 +7,7 @@ namespace Bit.PostgresMigrations.Migrations;
public partial class FCAccessAllCollectionGroups : Migration
{
private const string _accessAllCollectionGroupsScript = "PostgresMigrations.HelperScripts.2023-12-06_00_AccessAllCollectionGroups.psql";
private const string _accessAllCollectionGroupsScript = "PostgresMigrations.HelperScripts.2024-01-12_00_AccessAllCollectionGroups.psql";
protected override void Up(MigrationBuilder migrationBuilder)
{

View File

@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace Bit.PostgresMigrations.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20231219154729_FCAccessAllCollectionUsers")]
[Migration("20240112123314_FCAccessAllCollectionUsers")]
partial class FCAccessAllCollectionUsers
{
/// <inheritdoc />
@ -72,6 +72,9 @@ namespace Bit.PostgresMigrations.Migrations
b.Property<DateTime?>("ExpirationDate")
.HasColumnType("timestamp with time zone");
b.Property<bool>("FlexibleCollections")
.HasColumnType("boolean");
b.Property<byte?>("Gateway")
.HasColumnType("smallint");
@ -208,6 +211,10 @@ namespace Bit.PostgresMigrations.Migrations
b.HasKey("Id");
b.HasIndex("Id", "Enabled");
NpgsqlIndexBuilderExtensions.IncludeProperties(b.HasIndex("Id", "Enabled"), new[] { "UseTotp" });
b.ToTable("Organization", (string)null);
});
@ -236,7 +243,12 @@ namespace Bit.PostgresMigrations.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);
});
@ -483,11 +495,14 @@ namespace Bit.PostgresMigrations.Migrations
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Auth.Models.Grant", b =>
{
b.Property<string>("Key")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClientId")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
@ -498,6 +513,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("timestamp with time zone");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Description")
@ -507,6 +523,11 @@ namespace Bit.PostgresMigrations.Migrations
b.Property<DateTime?>("ExpirationDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Key")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("SessionId")
.HasMaxLength(100)
.HasColumnType("character varying(100)");
@ -516,10 +537,15 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("character varying(200)");
b.Property<string>("Type")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.HasKey("Key");
b.HasKey("Id")
.HasAnnotation("SqlServer:Clustered", true);
b.HasIndex("Key")
.IsUnique();
b.ToTable("Grant", (string)null);
});
@ -775,7 +801,15 @@ namespace Bit.PostgresMigrations.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);
});
@ -848,6 +882,9 @@ namespace Bit.PostgresMigrations.Migrations
b.HasKey("Id");
b.HasIndex("Date", "OrganizationId", "ActingUserId", "CipherId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("Event", (string)null);
});
@ -1048,6 +1085,9 @@ namespace Bit.PostgresMigrations.Migrations
b.HasIndex("SponsoringOrganizationId");
b.HasIndex("SponsoringOrganizationUserId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("OrganizationSponsorship", (string)null);
});
@ -1099,9 +1139,16 @@ namespace Bit.PostgresMigrations.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("SqlServer:Clustered", false);
NpgsqlIndexBuilderExtensions.IncludeProperties(b.HasIndex("UserId", "OrganizationId", "Status"), new[] { "AccessAll" });
b.ToTable("OrganizationUser", (string)null);
});
@ -1156,9 +1203,16 @@ namespace Bit.PostgresMigrations.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);
});
@ -1236,7 +1290,11 @@ namespace Bit.PostgresMigrations.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);
});
@ -1387,6 +1445,13 @@ namespace Bit.PostgresMigrations.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);
});

View File

@ -7,7 +7,7 @@ namespace Bit.PostgresMigrations.Migrations;
public partial class FCAccessAllCollectionUsers : Migration
{
private const string _accessAllCollectionUsersScript = "PostgresMigrations.HelperScripts.2023-12-06_01_AccessAllCollectionUsers.psql";
private const string _accessAllCollectionUsersScript = "PostgresMigrations.HelperScripts.2024-01-12_01_AccessAllCollectionUsers.psql";
protected override void Up(MigrationBuilder migrationBuilder)
{

View File

@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace Bit.PostgresMigrations.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20231219154829_FCManagersEditAssignedCollectionUsers")]
[Migration("20240112123331_FCManagersEditAssignedCollectionUsers")]
partial class FCManagersEditAssignedCollectionUsers
{
/// <inheritdoc />
@ -72,6 +72,9 @@ namespace Bit.PostgresMigrations.Migrations
b.Property<DateTime?>("ExpirationDate")
.HasColumnType("timestamp with time zone");
b.Property<bool>("FlexibleCollections")
.HasColumnType("boolean");
b.Property<byte?>("Gateway")
.HasColumnType("smallint");
@ -208,6 +211,10 @@ namespace Bit.PostgresMigrations.Migrations
b.HasKey("Id");
b.HasIndex("Id", "Enabled");
NpgsqlIndexBuilderExtensions.IncludeProperties(b.HasIndex("Id", "Enabled"), new[] { "UseTotp" });
b.ToTable("Organization", (string)null);
});
@ -236,7 +243,12 @@ namespace Bit.PostgresMigrations.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);
});
@ -483,11 +495,14 @@ namespace Bit.PostgresMigrations.Migrations
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Auth.Models.Grant", b =>
{
b.Property<string>("Key")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClientId")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
@ -498,6 +513,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("timestamp with time zone");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Description")
@ -507,6 +523,11 @@ namespace Bit.PostgresMigrations.Migrations
b.Property<DateTime?>("ExpirationDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Key")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("SessionId")
.HasMaxLength(100)
.HasColumnType("character varying(100)");
@ -516,10 +537,15 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("character varying(200)");
b.Property<string>("Type")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.HasKey("Key");
b.HasKey("Id")
.HasAnnotation("SqlServer:Clustered", true);
b.HasIndex("Key")
.IsUnique();
b.ToTable("Grant", (string)null);
});
@ -775,7 +801,15 @@ namespace Bit.PostgresMigrations.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);
});
@ -848,6 +882,9 @@ namespace Bit.PostgresMigrations.Migrations
b.HasKey("Id");
b.HasIndex("Date", "OrganizationId", "ActingUserId", "CipherId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("Event", (string)null);
});
@ -1048,6 +1085,9 @@ namespace Bit.PostgresMigrations.Migrations
b.HasIndex("SponsoringOrganizationId");
b.HasIndex("SponsoringOrganizationUserId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("OrganizationSponsorship", (string)null);
});
@ -1099,9 +1139,16 @@ namespace Bit.PostgresMigrations.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("SqlServer:Clustered", false);
NpgsqlIndexBuilderExtensions.IncludeProperties(b.HasIndex("UserId", "OrganizationId", "Status"), new[] { "AccessAll" });
b.ToTable("OrganizationUser", (string)null);
});
@ -1156,9 +1203,16 @@ namespace Bit.PostgresMigrations.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);
});
@ -1236,7 +1290,11 @@ namespace Bit.PostgresMigrations.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);
});
@ -1387,6 +1445,13 @@ namespace Bit.PostgresMigrations.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);
});

View File

@ -7,7 +7,7 @@ namespace Bit.PostgresMigrations.Migrations;
public partial class FCManagersEditAssignedCollectionUsers : Migration
{
private const string _managersEditAssignedCollectionUsersScript = "PostgresMigrations.HelperScripts.2023-12-06_02_ManagersEditAssignedCollectionUsers.psql";
private const string _managersEditAssignedCollectionUsersScript = "PostgresMigrations.HelperScripts.2024-01-12_02_ManagersEditAssignedCollectionUsers.psql";
protected override void Up(MigrationBuilder migrationBuilder)
{

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,21 @@
using Bit.Core.Utilities;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.PostgresMigrations.Migrations;
public partial class FCEnableOrgsFlexibleCollections : Migration
{
private const string _enableOrgsFlexibleCollectionsScript = "PostgresMigrations.HelperScripts.2024-01-12_03_EnableOrgsFlexibleCollections.psql";
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(CoreHelpers.GetEmbeddedResourceContentsAsync(_enableOrgsFlexibleCollectionsScript));
}
protected override void Down(MigrationBuilder migrationBuilder)
{
throw new Exception("Irreversible migration");
}
}

View File

@ -24,8 +24,9 @@
<EmbeddedResource Include="HelperScripts\2021-10-21_00_SetMaxAutoscaleSeatCount.psql" />
<EmbeddedResource Include="HelperScripts\2022-03-01_00_Up_MigrateOrganizationApiKeys.psql" />
<EmbeddedResource Include="HelperScripts\2022-03-01_00_Down_MigrateOrganizationApiKeys.psql" />
<EmbeddedResource Include="HelperScripts\2023-12-06_00_AccessAllCollectionGroups.psql" />
<EmbeddedResource Include="HelperScripts\2023-12-06_01_AccessAllCollectionUsers.psql" />
<EmbeddedResource Include="HelperScripts\2023-12-06_02_ManagersEditAssignedCollectionUsers.psql" />
<EmbeddedResource Include="HelperScripts\2024-01-12_00_AccessAllCollectionGroups.psql" />
<EmbeddedResource Include="HelperScripts\2024-01-12_01_AccessAllCollectionUsers.psql" />
<EmbeddedResource Include="HelperScripts\2024-01-12_02_ManagersEditAssignedCollectionUsers.psql" />
<EmbeddedResource Include="HelperScripts\2024-01-12_03_EnableOrgsFlexibleCollections.psql" />
</ItemGroup>
</Project>

View File

@ -5,13 +5,14 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Bit.SqliteMigrations.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20231219154710_FCAccessAllCollectionGroups")]
[Migration("20240112123248_FCAccessAllCollectionGroups")]
partial class FCAccessAllCollectionGroups
{
/// <inheritdoc />
@ -66,6 +67,9 @@ namespace Bit.SqliteMigrations.Migrations
b.Property<DateTime?>("ExpirationDate")
.HasColumnType("TEXT");
b.Property<bool>("FlexibleCollections")
.HasColumnType("INTEGER");
b.Property<byte?>("Gateway")
.HasColumnType("INTEGER");
@ -201,6 +205,9 @@ namespace Bit.SqliteMigrations.Migrations
b.HasKey("Id");
b.HasIndex("Id", "Enabled")
.HasAnnotation("Npgsql:IndexInclude", new[] { "UseTotp" });
b.ToTable("Organization", (string)null);
});
@ -229,7 +236,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);
});
@ -476,11 +488,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("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("ClientId")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("TEXT");
@ -491,6 +505,7 @@ namespace Bit.SqliteMigrations.Migrations
.HasColumnType("TEXT");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Description")
@ -500,6 +515,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");
@ -509,10 +529,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);
});
@ -763,7 +788,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);
});
@ -836,6 +869,9 @@ namespace Bit.SqliteMigrations.Migrations
b.HasKey("Id");
b.HasIndex("Date", "OrganizationId", "ActingUserId", "CipherId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("Event", (string)null);
});
@ -1036,6 +1072,9 @@ namespace Bit.SqliteMigrations.Migrations
b.HasIndex("SponsoringOrganizationId");
b.HasIndex("SponsoringOrganizationUserId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("OrganizationSponsorship", (string)null);
});
@ -1087,9 +1126,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);
});
@ -1144,9 +1189,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);
});
@ -1224,7 +1276,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);
});
@ -1374,6 +1430,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);
});

View File

@ -7,7 +7,7 @@ namespace Bit.SqliteMigrations.Migrations;
public partial class FCAccessAllCollectionGroups : Migration
{
private const string _accessAllCollectionGroupsScript = "SqliteMigrations.HelperScripts.2023-12-06_00_AccessAllCollectionGroups.sql";
private const string _accessAllCollectionGroupsScript = "SqliteMigrations.HelperScripts.2024-01-12_00_AccessAllCollectionGroups.sql";
protected override void Up(MigrationBuilder migrationBuilder)
{

View File

@ -5,13 +5,14 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Bit.SqliteMigrations.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20231219154737_FCAccessAllCollectionUsers")]
[Migration("20240112123318_FCAccessAllCollectionUsers")]
partial class FCAccessAllCollectionUsers
{
/// <inheritdoc />
@ -66,6 +67,9 @@ namespace Bit.SqliteMigrations.Migrations
b.Property<DateTime?>("ExpirationDate")
.HasColumnType("TEXT");
b.Property<bool>("FlexibleCollections")
.HasColumnType("INTEGER");
b.Property<byte?>("Gateway")
.HasColumnType("INTEGER");
@ -201,6 +205,9 @@ namespace Bit.SqliteMigrations.Migrations
b.HasKey("Id");
b.HasIndex("Id", "Enabled")
.HasAnnotation("Npgsql:IndexInclude", new[] { "UseTotp" });
b.ToTable("Organization", (string)null);
});
@ -229,7 +236,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);
});
@ -476,11 +488,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("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("ClientId")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("TEXT");
@ -491,6 +505,7 @@ namespace Bit.SqliteMigrations.Migrations
.HasColumnType("TEXT");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Description")
@ -500,6 +515,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");
@ -509,10 +529,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);
});
@ -763,7 +788,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);
});
@ -836,6 +869,9 @@ namespace Bit.SqliteMigrations.Migrations
b.HasKey("Id");
b.HasIndex("Date", "OrganizationId", "ActingUserId", "CipherId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("Event", (string)null);
});
@ -1036,6 +1072,9 @@ namespace Bit.SqliteMigrations.Migrations
b.HasIndex("SponsoringOrganizationId");
b.HasIndex("SponsoringOrganizationUserId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("OrganizationSponsorship", (string)null);
});
@ -1087,9 +1126,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);
});
@ -1144,9 +1189,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);
});
@ -1224,7 +1276,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);
});
@ -1374,6 +1430,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);
});

View File

@ -7,7 +7,7 @@ namespace Bit.SqliteMigrations.Migrations;
public partial class FCAccessAllCollectionUsers : Migration
{
private const string _accessAllCollectionUsersScript = "SqliteMigrations.HelperScripts.2023-12-06_01_AccessAllCollectionUsers.sql";
private const string _accessAllCollectionUsersScript = "SqliteMigrations.HelperScripts.2024-01-12_01_AccessAllCollectionUsers.sql";
protected override void Up(MigrationBuilder migrationBuilder)
{

View File

@ -5,13 +5,14 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Bit.SqliteMigrations.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20231219154820_FCManagersEditAssignedCollectionUsers")]
[Migration("20240112123335_FCManagersEditAssignedCollectionUsers")]
partial class FCManagersEditAssignedCollectionUsers
{
/// <inheritdoc />
@ -66,6 +67,9 @@ namespace Bit.SqliteMigrations.Migrations
b.Property<DateTime?>("ExpirationDate")
.HasColumnType("TEXT");
b.Property<bool>("FlexibleCollections")
.HasColumnType("INTEGER");
b.Property<byte?>("Gateway")
.HasColumnType("INTEGER");
@ -201,6 +205,9 @@ namespace Bit.SqliteMigrations.Migrations
b.HasKey("Id");
b.HasIndex("Id", "Enabled")
.HasAnnotation("Npgsql:IndexInclude", new[] { "UseTotp" });
b.ToTable("Organization", (string)null);
});
@ -229,7 +236,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);
});
@ -476,11 +488,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("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("ClientId")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("TEXT");
@ -491,6 +505,7 @@ namespace Bit.SqliteMigrations.Migrations
.HasColumnType("TEXT");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Description")
@ -500,6 +515,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");
@ -509,10 +529,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);
});
@ -763,7 +788,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);
});
@ -836,6 +869,9 @@ namespace Bit.SqliteMigrations.Migrations
b.HasKey("Id");
b.HasIndex("Date", "OrganizationId", "ActingUserId", "CipherId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("Event", (string)null);
});
@ -1036,6 +1072,9 @@ namespace Bit.SqliteMigrations.Migrations
b.HasIndex("SponsoringOrganizationId");
b.HasIndex("SponsoringOrganizationUserId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("OrganizationSponsorship", (string)null);
});
@ -1087,9 +1126,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);
});
@ -1144,9 +1189,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);
});
@ -1224,7 +1276,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);
});
@ -1374,6 +1430,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);
});

View File

@ -7,7 +7,7 @@ namespace Bit.SqliteMigrations.Migrations;
public partial class FCManagersEditAssignedCollectionUsers : Migration
{
private const string _managersEditAssignedCollectionUsersScript = "SqliteMigrations.HelperScripts.2023-12-06_02_ManagersEditAssignedCollectionUsers.sql";
private const string _managersEditAssignedCollectionUsersScript = "SqliteMigrations.HelperScripts.2024-01-12_02_ManagersEditAssignedCollectionUsers.sql";
protected override void Up(MigrationBuilder migrationBuilder)
{

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,21 @@
using Bit.Core.Utilities;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.SqliteMigrations.Migrations;
public partial class FCEnableOrgsFlexibleCollections : Migration
{
private const string _enableOrgsFlexibleCollectionsScript = "SqliteMigrations.HelperScripts.2024-01-12_03_EnableOrgsFlexibleCollections.sql";
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(CoreHelpers.GetEmbeddedResourceContentsAsync(_enableOrgsFlexibleCollectionsScript));
}
protected override void Down(MigrationBuilder migrationBuilder)
{
throw new Exception("Irreversible migration");
}
}

View File

@ -23,9 +23,10 @@
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="HelperScripts\2023-12-06_00_AccessAllCollectionGroups.sql" />
<EmbeddedResource Include="HelperScripts\2023-12-06_01_AccessAllCollectionUsers.sql" />
<EmbeddedResource Include="HelperScripts\2023-12-06_02_ManagersEditAssignedCollectionUsers.sql" />
<EmbeddedResource Include="HelperScripts\2024-01-12_00_AccessAllCollectionGroups.sql" />
<EmbeddedResource Include="HelperScripts\2024-01-12_01_AccessAllCollectionUsers.sql" />
<EmbeddedResource Include="HelperScripts\2024-01-12_02_ManagersEditAssignedCollectionUsers.sql" />
<EmbeddedResource Include="HelperScripts\2024-01-12_03_EnableOrgsFlexibleCollections.sql" />
</ItemGroup>
</Project>