1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-28 13:15:12 +01:00

⚠️ Do not specify database in migration files (#1628)

* Do not specify database in migration files

* Rename migrations to force them to re-run

* Use new migration files

* Rename EF migrations
This commit is contained in:
Matt Gibson 2021-10-11 10:20:21 -05:00 committed by GitHub
parent 44f30e7948
commit 7802c2b969
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 29 additions and 17 deletions

View File

@ -1,5 +1,5 @@
-- Split Manage Assigned Collections into edit and delete -- Split Manage Assigned Collections into edit and delete
UPDATE [vault_dev].[dbo].[OrganizationUser] UPDATE [dbo].[OrganizationUser]
SET [Permissions] = SET [Permissions] =
JSON_MODIFY( JSON_MODIFY(
JSON_MODIFY( JSON_MODIFY(
@ -27,7 +27,7 @@ WHERE [Permissions] IS NOT NULL
) )
-- Split Manage All Collections into create, edit, and delete -- Split Manage All Collections into create, edit, and delete
UPDATE [vault_dev].[dbo].[OrganizationUser] UPDATE [dbo].[OrganizationUser]
SET [Permissions] = SET [Permissions] =
JSON_MODIFY( JSON_MODIFY(
JSON_MODIFY( JSON_MODIFY(

View File

@ -9,8 +9,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Bit.MySqlMigrations.Migrations namespace Bit.MySqlMigrations.Migrations
{ {
[DbContext(typeof(DatabaseContext))] [DbContext(typeof(DatabaseContext))]
[Migration("20210921200227_SplitManageCollectionsPermissions")] [Migration("20211011144835_SplitManageCollectionsPermissions2")]
partial class SplitManageCollectionsPermissions partial class SplitManageCollectionsPermissions2
{ {
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
{ {
@ -505,6 +505,9 @@ namespace Bit.MySqlMigrations.Migrations
.HasMaxLength(100) .HasMaxLength(100)
.HasColumnType("varchar(100)"); .HasColumnType("varchar(100)");
b.Property<int?>("MaxAutoscaleSeats")
.HasColumnType("int");
b.Property<short?>("MaxCollections") b.Property<short?>("MaxCollections")
.HasColumnType("smallint"); .HasColumnType("smallint");
@ -515,6 +518,9 @@ namespace Bit.MySqlMigrations.Migrations
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnType("varchar(50)"); .HasColumnType("varchar(50)");
b.Property<DateTime?>("OwnersNotifiedOfAutoscaling")
.HasColumnType("datetime(6)");
b.Property<string>("Plan") b.Property<string>("Plan")
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnType("varchar(50)"); .HasColumnType("varchar(50)");

View File

@ -4,10 +4,10 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace Bit.MySqlMigrations.Migrations namespace Bit.MySqlMigrations.Migrations
{ {
public partial class SplitManageCollectionsPermissions : Migration public partial class SplitManageCollectionsPermissions2 : Migration
{ {
private const string _scriptLocation = private const string _scriptLocation =
"MySqlMigrations.Scripts.2021-09-21_00_SplitManageCollectionsPermission.sql"; "MySqlMigrations.Scripts.2021-09-21_01_SplitManageCollectionsPermission.sql";
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {

View File

@ -17,9 +17,9 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Remove="Scripts\2021-09-21_00_SplitManageCollectionsPermission.sql" /> <None Remove="Scripts\2021-09-21_01_SplitManageCollectionsPermission.sql" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Scripts\2021-09-21_00_SplitManageCollectionsPermission.sql" /> <EmbeddedResource Include="Scripts\2021-09-21_01_SplitManageCollectionsPermission.sql" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,5 +1,5 @@
-- Split Manage Assigned Collections into edit and delete -- Split Manage Assigned Collections into edit and delete
UPDATE `bw-vault`.`OrganizationUser` UPDATE `OrganizationUser`
SET `Permissions` = SET `Permissions` =
JSON_INSERT( JSON_INSERT(
`Permissions`, `Permissions`,
@ -24,7 +24,7 @@ WHERE `Permissions` IS NOT NULL
); );
-- Split Manage All Collections into create, edit, and delete -- Split Manage All Collections into create, edit, and delete
UPDATE `bw-vault`.`OrganizationUser` UPDATE `OrganizationUser`
SET `Permissions` = SET `Permissions` =
JSON_INSERT( JSON_INSERT(
`Permissions`, `Permissions`,

View File

@ -10,8 +10,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace Bit.PostgresMigrations.Migrations namespace Bit.PostgresMigrations.Migrations
{ {
[DbContext(typeof(DatabaseContext))] [DbContext(typeof(DatabaseContext))]
[Migration("20210921163012_SplitManageCollectionsPermissions")] [Migration("20211011145128_SplitManageCollectionsPermissions2")]
partial class SplitManageCollectionsPermissions partial class SplitManageCollectionsPermissions2
{ {
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
{ {
@ -509,6 +509,9 @@ namespace Bit.PostgresMigrations.Migrations
.HasMaxLength(100) .HasMaxLength(100)
.HasColumnType("character varying(100)"); .HasColumnType("character varying(100)");
b.Property<int?>("MaxAutoscaleSeats")
.HasColumnType("integer");
b.Property<short?>("MaxCollections") b.Property<short?>("MaxCollections")
.HasColumnType("smallint"); .HasColumnType("smallint");
@ -519,6 +522,9 @@ namespace Bit.PostgresMigrations.Migrations
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnType("character varying(50)"); .HasColumnType("character varying(50)");
b.Property<DateTime?>("OwnersNotifiedOfAutoscaling")
.HasColumnType("timestamp without time zone");
b.Property<string>("Plan") b.Property<string>("Plan")
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnType("character varying(50)"); .HasColumnType("character varying(50)");

View File

@ -4,10 +4,10 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace Bit.PostgresMigrations.Migrations namespace Bit.PostgresMigrations.Migrations
{ {
public partial class SplitManageCollectionsPermissions : Migration public partial class SplitManageCollectionsPermissions2 : Migration
{ {
private const string _scriptLocation = private const string _scriptLocation =
"PostgresMigration.Scripts.2021-09-21_00_SplitManageCollectionsPermission.psql"; "PostgresMigration.Scripts.2021-09-21_01_SplitManageCollectionsPermission.psql";
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {

View File

@ -17,9 +17,9 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Remove="Scripts\2021-09-21_00_SplitManageCollectionsPermission.psql" /> <None Remove="Scripts\2021-09-21_01_SplitManageCollectionsPermission.psql" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Scripts\2021-09-21_00_SplitManageCollectionsPermission.psql" /> <EmbeddedResource Include="Scripts\2021-09-21_01_SplitManageCollectionsPermission.psql" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -35,7 +35,7 @@ CREATE OR REPLACE FUNCTION updatePermissionsJson(permissions jsonb) returns json
END END
$$; $$;
UPDATE public."OrganizationUser" UPDATE "OrganizationUser"
SET "Permissions" = updatePermissionsJson("Permissions"::jsonb)::text SET "Permissions" = updatePermissionsJson("Permissions"::jsonb)::text
WHERE "Permissions" IS NOT NULL; WHERE "Permissions" IS NOT NULL;