using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace NovelSoftware.Infrastructure.Persistence.Migrations { /// public partial class InitialSchema : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Projects", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), Title = table.Column(type: "TEXT", maxLength: 300, nullable: false), Author = table.Column(type: "TEXT", nullable: true), Genre = table.Column(type: "TEXT", nullable: true), Logline = table.Column(type: "TEXT", nullable: true), Synopsis = table.Column(type: "TEXT", nullable: true), Notes = table.Column(type: "TEXT", nullable: true), TargetWordCount = table.Column(type: "INTEGER", nullable: true), CreatedAt = table.Column(type: "INTEGER", nullable: false), UpdatedAt = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Projects", x => x.Id); }); migrationBuilder.CreateTable( name: "Characters", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), ProjectId = table.Column(type: "TEXT", nullable: false), Name = table.Column(type: "TEXT", maxLength: 200, nullable: false), Role = table.Column(type: "TEXT", maxLength: 32, nullable: false), Age = table.Column(type: "TEXT", nullable: true), Pronouns = table.Column(type: "TEXT", nullable: true), Occupation = table.Column(type: "TEXT", nullable: true), Appearance = table.Column(type: "TEXT", nullable: true), Personality = table.Column(type: "TEXT", nullable: true), Backstory = table.Column(type: "TEXT", nullable: true), Want = table.Column(type: "TEXT", nullable: true), Need = table.Column(type: "TEXT", nullable: true), InternalConflict = table.Column(type: "TEXT", nullable: true), ExternalConflict = table.Column(type: "TEXT", nullable: true), ArcSummary = table.Column(type: "TEXT", nullable: true), Voice = table.Column(type: "TEXT", nullable: true), Notes = table.Column(type: "TEXT", nullable: true), CreatedAt = table.Column(type: "INTEGER", nullable: false), UpdatedAt = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Characters", x => x.Id); table.ForeignKey( name: "FK_Characters_Projects_ProjectId", column: x => x.ProjectId, principalTable: "Projects", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Conversations", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), ProjectId = table.Column(type: "TEXT", nullable: false), Title = table.Column(type: "TEXT", maxLength: 200, nullable: false), CreatedAt = table.Column(type: "INTEGER", nullable: false), UpdatedAt = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Conversations", x => x.Id); table.ForeignKey( name: "FK_Conversations_Projects_ProjectId", column: x => x.ProjectId, principalTable: "Projects", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Chapters", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), ProjectId = table.Column(type: "TEXT", nullable: false), Number = table.Column(type: "INTEGER", nullable: false), Title = table.Column(type: "TEXT", maxLength: 300, nullable: false), Summary = table.Column(type: "TEXT", nullable: true), PovCharacterId = table.Column(type: "TEXT", nullable: true), Setting = table.Column(type: "TEXT", nullable: true), Notes = table.Column(type: "TEXT", nullable: true), Status = table.Column(type: "TEXT", maxLength: 32, nullable: false), TargetWordCount = table.Column(type: "INTEGER", nullable: true), CreatedAt = table.Column(type: "INTEGER", nullable: false), UpdatedAt = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Chapters", x => x.Id); table.ForeignKey( name: "FK_Chapters_Characters_PovCharacterId", column: x => x.PovCharacterId, principalTable: "Characters", principalColumn: "Id", onDelete: ReferentialAction.SetNull); table.ForeignKey( name: "FK_Chapters_Projects_ProjectId", column: x => x.ProjectId, principalTable: "Projects", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "CharacterRelationships", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), CharacterId = table.Column(type: "TEXT", nullable: false), RelatedCharacterId = table.Column(type: "TEXT", nullable: false), RelationshipType = table.Column(type: "TEXT", maxLength: 120, nullable: false), Description = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_CharacterRelationships", x => x.Id); table.ForeignKey( name: "FK_CharacterRelationships_Characters_CharacterId", column: x => x.CharacterId, principalTable: "Characters", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_CharacterRelationships_Characters_RelatedCharacterId", column: x => x.RelatedCharacterId, principalTable: "Characters", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "AgentMessages", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), ConversationId = table.Column(type: "TEXT", nullable: false), Role = table.Column(type: "TEXT", maxLength: 16, nullable: false), Sequence = table.Column(type: "INTEGER", nullable: false), Content = table.Column(type: "TEXT", nullable: false), ToolCallsJson = table.Column(type: "TEXT", nullable: true), CreatedAt = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AgentMessages", x => x.Id); table.ForeignKey( name: "FK_AgentMessages_Conversations_ConversationId", column: x => x.ConversationId, principalTable: "Conversations", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "OutlineNodes", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), ProjectId = table.Column(type: "TEXT", nullable: false), ParentId = table.Column(type: "TEXT", nullable: true), NodeType = table.Column(type: "TEXT", maxLength: 32, nullable: false), Title = table.Column(type: "TEXT", maxLength: 300, nullable: false), Summary = table.Column(type: "TEXT", nullable: true), SortOrder = table.Column(type: "INTEGER", nullable: false), ChapterId = table.Column(type: "TEXT", nullable: true), CreatedAt = table.Column(type: "INTEGER", nullable: false), UpdatedAt = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_OutlineNodes", x => x.Id); table.ForeignKey( name: "FK_OutlineNodes_Chapters_ChapterId", column: x => x.ChapterId, principalTable: "Chapters", principalColumn: "Id", onDelete: ReferentialAction.SetNull); table.ForeignKey( name: "FK_OutlineNodes_OutlineNodes_ParentId", column: x => x.ParentId, principalTable: "OutlineNodes", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_OutlineNodes_Projects_ProjectId", column: x => x.ProjectId, principalTable: "Projects", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Scenes", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), ChapterId = table.Column(type: "TEXT", nullable: false), SortOrder = table.Column(type: "INTEGER", nullable: false), Title = table.Column(type: "TEXT", maxLength: 300, nullable: false), Summary = table.Column(type: "TEXT", nullable: true), Goal = table.Column(type: "TEXT", nullable: true), Conflict = table.Column(type: "TEXT", nullable: true), Outcome = table.Column(type: "TEXT", nullable: true), PovCharacterId = table.Column(type: "TEXT", nullable: true), Location = table.Column(type: "TEXT", nullable: true), Prose = table.Column(type: "TEXT", nullable: true), WordCount = table.Column(type: "INTEGER", nullable: false), Status = table.Column(type: "TEXT", maxLength: 32, nullable: false), CreatedAt = table.Column(type: "INTEGER", nullable: false), UpdatedAt = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Scenes", x => x.Id); table.ForeignKey( name: "FK_Scenes_Chapters_ChapterId", column: x => x.ChapterId, principalTable: "Chapters", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Scenes_Characters_PovCharacterId", column: x => x.PovCharacterId, principalTable: "Characters", principalColumn: "Id", onDelete: ReferentialAction.SetNull); }); migrationBuilder.CreateIndex( name: "IX_AgentMessages_ConversationId_Sequence", table: "AgentMessages", columns: new[] { "ConversationId", "Sequence" }, unique: true); migrationBuilder.CreateIndex( name: "IX_Chapters_PovCharacterId", table: "Chapters", column: "PovCharacterId"); migrationBuilder.CreateIndex( name: "IX_Chapters_ProjectId_Number", table: "Chapters", columns: new[] { "ProjectId", "Number" }); migrationBuilder.CreateIndex( name: "IX_CharacterRelationships_CharacterId", table: "CharacterRelationships", column: "CharacterId"); migrationBuilder.CreateIndex( name: "IX_CharacterRelationships_RelatedCharacterId", table: "CharacterRelationships", column: "RelatedCharacterId"); migrationBuilder.CreateIndex( name: "IX_Characters_ProjectId", table: "Characters", column: "ProjectId"); migrationBuilder.CreateIndex( name: "IX_Conversations_ProjectId", table: "Conversations", column: "ProjectId"); migrationBuilder.CreateIndex( name: "IX_OutlineNodes_ChapterId", table: "OutlineNodes", column: "ChapterId"); migrationBuilder.CreateIndex( name: "IX_OutlineNodes_ParentId", table: "OutlineNodes", column: "ParentId"); migrationBuilder.CreateIndex( name: "IX_OutlineNodes_ProjectId_ParentId_SortOrder", table: "OutlineNodes", columns: new[] { "ProjectId", "ParentId", "SortOrder" }); migrationBuilder.CreateIndex( name: "IX_Scenes_ChapterId_SortOrder", table: "Scenes", columns: new[] { "ChapterId", "SortOrder" }); migrationBuilder.CreateIndex( name: "IX_Scenes_PovCharacterId", table: "Scenes", column: "PovCharacterId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "AgentMessages"); migrationBuilder.DropTable( name: "CharacterRelationships"); migrationBuilder.DropTable( name: "OutlineNodes"); migrationBuilder.DropTable( name: "Scenes"); migrationBuilder.DropTable( name: "Conversations"); migrationBuilder.DropTable( name: "Chapters"); migrationBuilder.DropTable( name: "Characters"); migrationBuilder.DropTable( name: "Projects"); } } }