using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace FlowAPI.Infrastructure.Migrations { /// public partial class InitialWithDecision : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Users", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), Email = table.Column(type: "TEXT", maxLength: 256, nullable: false), PasswordHash = table.Column(type: "TEXT", nullable: false), DisplayName = table.Column(type: "TEXT", maxLength: 100, nullable: false), IsPremium = table.Column(type: "INTEGER", nullable: false), CreatedAt = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); }); migrationBuilder.CreateTable( name: "Graphs", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), UserId = table.Column(type: "TEXT", nullable: false), Title = table.Column(type: "TEXT", maxLength: 200, nullable: false), Description = table.Column(type: "TEXT", maxLength: 1000, nullable: true), CreatedAt = table.Column(type: "TEXT", nullable: false), UpdatedAt = table.Column(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(type: "TEXT", nullable: false), UserId = table.Column(type: "TEXT", nullable: false), HabitName = table.Column(type: "TEXT", maxLength: 100, nullable: false), CheckedDate = table.Column(type: "TEXT", nullable: false), StreakCount = table.Column(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(type: "TEXT", nullable: false), GraphId = table.Column(type: "TEXT", nullable: false), Label = table.Column(type: "TEXT", maxLength: 30, nullable: false), PosX = table.Column(type: "REAL", nullable: false), PosY = table.Column(type: "REAL", nullable: false), Type = table.Column(type: "TEXT", maxLength: 50, nullable: false, defaultValue: "sketch"), Decision = table.Column(type: "TEXT", maxLength: 50, nullable: true), State = table.Column(type: "TEXT", nullable: false, defaultValue: "Pending"), CreatedAt = table.Column(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(type: "TEXT", nullable: false), GraphId = table.Column(type: "TEXT", nullable: false), FromNodeId = table.Column(type: "TEXT", nullable: false), ToNodeId = table.Column(type: "TEXT", nullable: false), Condition = table.Column(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); } /// 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"); } } }