1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-05 14:23:30 +01:00
bitwarden-server/util/PostgresMigrations/Migrations/20240925202400_SyncOrganizationLimitCollectionCreationDeletionColumn.cs
Addison Beck 6a51e3b1a9
Split LimitCollectionCreationDeletion into two database columns (#4709)
* Add new columns to `dbo.Organization` & its references

* Feed existing data into new `dbo.Organization` column

* Update Entity Framework database definitions

* Move new EF columns out of the core entity definition

* Generate Entity Framework migrations

* Feed existing data into new `Organization` Entity Framework columns

* Add a where clause to SQL migration
2024-10-03 13:43:54 -04:00

32 lines
963 B
C#

using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.PostgresMigrations.Migrations;
/// <inheritdoc />
public partial class SyncOrganizationLimitCollectionCreationDeletionColumn : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
// Postgres is particular about the casing of entities. It wants to
// lowercase everything by default, and convert casings
// automatically. Quoting the entity names here provides explicit &
// correct casing.
migrationBuilder.Sql(
@"
UPDATE ""Organization""
SET
""LimitCollectionCreation"" = ""LimitCollectionCreationDeletion"",
""LimitCollectionDeletion"" = ""LimitCollectionCreationDeletion"";
");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}