Spaces:
Running
Running
| using System; | |
| using Microsoft.EntityFrameworkCore.Migrations; | |
| namespace FlowAPI.Infrastructure.Migrations | |
| { | |
| /// <inheritdoc /> | |
| public partial class InitialWithDecision : Migration | |
| { | |
| /// <inheritdoc /> | |
| protected override void Up(MigrationBuilder migrationBuilder) | |
| { | |
| migrationBuilder.CreateTable( | |
| name: "Users", | |
| columns: table => new | |
| { | |
| Id = table.Column<Guid>(type: "TEXT", nullable: false), | |
| Email = table.Column<string>(type: "TEXT", maxLength: 256, nullable: false), | |
| PasswordHash = table.Column<string>(type: "TEXT", nullable: false), | |
| DisplayName = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false), | |
| IsPremium = table.Column<bool>(type: "INTEGER", nullable: false), | |
| CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: false) | |
| }, | |
| constraints: table => | |
| { | |
| table.PrimaryKey("PK_Users", x => x.Id); | |
| }); | |
| migrationBuilder.CreateTable( | |
| name: "Graphs", | |
| columns: table => new | |
| { | |
| Id = table.Column<Guid>(type: "TEXT", nullable: false), | |
| UserId = table.Column<Guid>(type: "TEXT", nullable: false), | |
| Title = table.Column<string>(type: "TEXT", maxLength: 200, nullable: false), | |
| Description = table.Column<string>(type: "TEXT", maxLength: 1000, nullable: true), | |
| CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: false), | |
| UpdatedAt = table.Column<DateTime>(type: "TEXT", nullable: false) | |
| }, | |
| constraints: table => | |
| { | |
| table.PrimaryKey("PK_Graphs", x => x.Id); | |
| table.ForeignKey( | |
| name: "FK_Graphs_Users_UserId", | |
| column: x => x.UserId, | |
| principalTable: "Users", | |
| principalColumn: "Id", | |
| onDelete: ReferentialAction.Cascade); | |
| }); | |
| migrationBuilder.CreateTable( | |
| name: "HabitRecords", | |
| columns: table => new | |
| { | |
| Id = table.Column<Guid>(type: "TEXT", nullable: false), | |
| UserId = table.Column<Guid>(type: "TEXT", nullable: false), | |
| HabitName = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false), | |
| CheckedDate = table.Column<DateTime>(type: "TEXT", nullable: false), | |
| StreakCount = table.Column<int>(type: "INTEGER", nullable: false) | |
| }, | |
| constraints: table => | |
| { | |
| table.PrimaryKey("PK_HabitRecords", x => x.Id); | |
| table.ForeignKey( | |
| name: "FK_HabitRecords_Users_UserId", | |
| column: x => x.UserId, | |
| principalTable: "Users", | |
| principalColumn: "Id", | |
| onDelete: ReferentialAction.Cascade); | |
| }); | |
| migrationBuilder.CreateTable( | |
| name: "TaskNodes", | |
| columns: table => new | |
| { | |
| Id = table.Column<Guid>(type: "TEXT", nullable: false), | |
| GraphId = table.Column<Guid>(type: "TEXT", nullable: false), | |
| Label = table.Column<string>(type: "TEXT", maxLength: 30, nullable: false), | |
| PosX = table.Column<double>(type: "REAL", nullable: false), | |
| PosY = table.Column<double>(type: "REAL", nullable: false), | |
| Type = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false, defaultValue: "sketch"), | |
| Decision = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true), | |
| State = table.Column<string>(type: "TEXT", nullable: false, defaultValue: "Pending"), | |
| CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: false) | |
| }, | |
| constraints: table => | |
| { | |
| table.PrimaryKey("PK_TaskNodes", x => x.Id); | |
| table.ForeignKey( | |
| name: "FK_TaskNodes_Graphs_GraphId", | |
| column: x => x.GraphId, | |
| principalTable: "Graphs", | |
| principalColumn: "Id", | |
| onDelete: ReferentialAction.Cascade); | |
| }); | |
| migrationBuilder.CreateTable( | |
| name: "Edges", | |
| columns: table => new | |
| { | |
| Id = table.Column<Guid>(type: "TEXT", nullable: false), | |
| GraphId = table.Column<Guid>(type: "TEXT", nullable: false), | |
| FromNodeId = table.Column<Guid>(type: "TEXT", nullable: false), | |
| ToNodeId = table.Column<Guid>(type: "TEXT", nullable: false), | |
| Condition = table.Column<int>(type: "INTEGER", maxLength: 50, nullable: false) | |
| }, | |
| constraints: table => | |
| { | |
| table.PrimaryKey("PK_Edges", x => x.Id); | |
| table.ForeignKey( | |
| name: "FK_Edges_Graphs_GraphId", | |
| column: x => x.GraphId, | |
| principalTable: "Graphs", | |
| principalColumn: "Id", | |
| onDelete: ReferentialAction.Cascade); | |
| table.ForeignKey( | |
| name: "FK_Edges_TaskNodes_FromNodeId", | |
| column: x => x.FromNodeId, | |
| principalTable: "TaskNodes", | |
| principalColumn: "Id", | |
| onDelete: ReferentialAction.Restrict); | |
| table.ForeignKey( | |
| name: "FK_Edges_TaskNodes_ToNodeId", | |
| column: x => x.ToNodeId, | |
| principalTable: "TaskNodes", | |
| principalColumn: "Id", | |
| onDelete: ReferentialAction.Restrict); | |
| }); | |
| migrationBuilder.CreateIndex( | |
| name: "IX_Edges_FromNodeId", | |
| table: "Edges", | |
| column: "FromNodeId"); | |
| migrationBuilder.CreateIndex( | |
| name: "IX_Edges_GraphId", | |
| table: "Edges", | |
| column: "GraphId"); | |
| migrationBuilder.CreateIndex( | |
| name: "IX_Edges_ToNodeId", | |
| table: "Edges", | |
| column: "ToNodeId"); | |
| migrationBuilder.CreateIndex( | |
| name: "IX_Graphs_UserId", | |
| table: "Graphs", | |
| column: "UserId"); | |
| migrationBuilder.CreateIndex( | |
| name: "IX_HabitRecords_UserId", | |
| table: "HabitRecords", | |
| column: "UserId"); | |
| migrationBuilder.CreateIndex( | |
| name: "IX_TaskNodes_GraphId", | |
| table: "TaskNodes", | |
| column: "GraphId"); | |
| migrationBuilder.CreateIndex( | |
| name: "IX_Users_Email", | |
| table: "Users", | |
| column: "Email", | |
| unique: true); | |
| } | |
| /// <inheritdoc /> | |
| protected override void Down(MigrationBuilder migrationBuilder) | |
| { | |
| migrationBuilder.DropTable( | |
| name: "Edges"); | |
| migrationBuilder.DropTable( | |
| name: "HabitRecords"); | |
| migrationBuilder.DropTable( | |
| name: "TaskNodes"); | |
| migrationBuilder.DropTable( | |
| name: "Graphs"); | |
| migrationBuilder.DropTable( | |
| name: "Users"); | |
| } | |
| } | |
| } | |