Commit MWS backend source tree
The ASP.NET Core solution (mws.api/mws.application/mws.domain/ mws.infrastructure) existed only as untracked working files. Adding it to version control, plus a .gitignore for build output and local tooling directories, so the CQRS/mediator refactor plan has a real git history to branch and diff against.
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Mws.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class SplitProjectMemberPermissions : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "project_member_permissions",
|
||||
columns: table => new
|
||||
{
|
||||
ProjectId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
UserId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Screen = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
||||
CanView = table.Column<bool>(type: "boolean", nullable: false),
|
||||
CanCreate = table.Column<bool>(type: "boolean", nullable: false),
|
||||
CanEdit = table.Column<bool>(type: "boolean", nullable: false),
|
||||
CanDelete = table.Column<bool>(type: "boolean", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_project_member_permissions", x => new { x.ProjectId, x.UserId, x.Screen });
|
||||
table.ForeignKey(
|
||||
name: "FK_project_member_permissions_project_members_ProjectId_UserId",
|
||||
columns: x => new { x.ProjectId, x.UserId },
|
||||
principalTable: "project_members",
|
||||
principalColumns: new[] { "ProjectId", "UserId" },
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.Sql("""
|
||||
INSERT INTO "project_member_permissions" ("ProjectId", "UserId", "Screen", "CanView", "CanCreate", "CanEdit", "CanDelete")
|
||||
SELECT "ProjectId", "UserId", 'documents', "CanViewDocuments", "CanCreateDocuments", "CanEditDocuments", "CanDeleteDocuments"
|
||||
FROM "project_members";
|
||||
""");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CanCreateDocuments",
|
||||
table: "project_members");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CanDeleteDocuments",
|
||||
table: "project_members");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CanEditDocuments",
|
||||
table: "project_members");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CanViewDocuments",
|
||||
table: "project_members");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "CanCreateDocuments",
|
||||
table: "project_members",
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "CanDeleteDocuments",
|
||||
table: "project_members",
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "CanEditDocuments",
|
||||
table: "project_members",
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "CanViewDocuments",
|
||||
table: "project_members",
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.Sql("""
|
||||
UPDATE "project_members" m
|
||||
SET "CanViewDocuments" = p."CanView",
|
||||
"CanCreateDocuments" = p."CanCreate",
|
||||
"CanEditDocuments" = p."CanEdit",
|
||||
"CanDeleteDocuments" = p."CanDelete"
|
||||
FROM "project_member_permissions" p
|
||||
WHERE p."ProjectId" = m."ProjectId" AND p."UserId" = m."UserId" AND p."Screen" = 'documents';
|
||||
""");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "project_member_permissions");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user