FlowAPI / FlowAPI.Infrastructure /Migrations /20260518170308_AddSharedGraphs.cs
danylokhodus's picture
init
b9c7f0e
Raw
History Blame Contribute Delete
2.36 kB
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace FlowAPI.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddSharedGraphs : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "SharedGraphs",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
GraphId = table.Column<Guid>(type: "TEXT", nullable: false),
SharedWithUserId = table.Column<Guid>(type: "TEXT", nullable: false),
Permission = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false, defaultValue: "Read"),
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SharedGraphs", x => x.Id);
table.ForeignKey(
name: "FK_SharedGraphs_Graphs_GraphId",
column: x => x.GraphId,
principalTable: "Graphs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_SharedGraphs_Users_SharedWithUserId",
column: x => x.SharedWithUserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_SharedGraphs_GraphId_SharedWithUserId",
table: "SharedGraphs",
columns: new[] { "GraphId", "SharedWithUserId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_SharedGraphs_SharedWithUserId",
table: "SharedGraphs",
column: "SharedWithUserId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "SharedGraphs");
}
}
}