using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace backend.Migrations { /// public partial class AddConversationsAndTurns : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Conversations", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), DeviceId = table.Column(type: "TEXT", nullable: false), StartedAt = table.Column(type: "TEXT", nullable: false), EndedAt = table.Column(type: "TEXT", nullable: true), EndReason = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Conversations", x => x.Id); }); migrationBuilder.CreateTable( name: "Turns", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), ConversationId = table.Column(type: "TEXT", nullable: false), Index = table.Column(type: "INTEGER", nullable: false), Role = table.Column(type: "INTEGER", nullable: false), Text = table.Column(type: "TEXT", nullable: true), ToolName = table.Column(type: "TEXT", nullable: true), ToolArgsJson = table.Column(type: "TEXT", nullable: true), ToolResultJson = table.Column(type: "TEXT", nullable: true), CreatedAt = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Turns", x => x.Id); table.ForeignKey( name: "FK_Turns_Conversations_ConversationId", column: x => x.ConversationId, principalTable: "Conversations", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Conversations_DeviceId", table: "Conversations", column: "DeviceId"); migrationBuilder.CreateIndex( name: "IX_Turns_ConversationId_Index", table: "Turns", columns: new[] { "ConversationId", "Index" }, unique: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Turns"); migrationBuilder.DropTable( name: "Conversations"); } } }