Spaces:
Running
Running
| using System; | |
| using Microsoft.EntityFrameworkCore.Migrations; | |
| 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"); | |
| } | |
| } | |
| } | |