using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace ClaudeDo.Data.Migrations
{
    /// <inheritdoc />
    public partial class WeeklyReport : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<string>(
                name: "report_excluded_paths",
                table: "app_settings",
                type: "TEXT",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "standup_weekday",
                table: "app_settings",
                type: "INTEGER",
                nullable: false,
                defaultValue: 3);

            migrationBuilder.CreateTable(
                name: "daily_notes",
                columns: table => new
                {
                    id = table.Column<string>(type: "TEXT", nullable: false),
                    note_date = table.Column<DateOnly>(type: "TEXT", nullable: false),
                    text = table.Column<string>(type: "TEXT", nullable: false),
                    sort_order = table.Column<int>(type: "INTEGER", nullable: false),
                    created_at = table.Column<DateTime>(type: "TEXT", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_daily_notes", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "week_reports",
                columns: table => new
                {
                    id = table.Column<string>(type: "TEXT", nullable: false),
                    start_date = table.Column<DateOnly>(type: "TEXT", nullable: false),
                    end_date = table.Column<DateOnly>(type: "TEXT", nullable: false),
                    markdown = table.Column<string>(type: "TEXT", nullable: false),
                    generated_at = table.Column<DateTime>(type: "TEXT", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_week_reports", x => x.id);
                });

            migrationBuilder.UpdateData(
                table: "app_settings",
                keyColumn: "id",
                keyValue: 1,
                columns: new[] { "report_excluded_paths", "standup_weekday" },
                values: new object[] { null, 3 });

            migrationBuilder.CreateIndex(
                name: "IX_daily_notes_note_date",
                table: "daily_notes",
                column: "note_date");

            migrationBuilder.CreateIndex(
                name: "IX_week_reports_start_date_end_date",
                table: "week_reports",
                columns: new[] { "start_date", "end_date" },
                unique: true);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "daily_notes");

            migrationBuilder.DropTable(
                name: "week_reports");

            migrationBuilder.DropColumn(
                name: "report_excluded_paths",
                table: "app_settings");

            migrationBuilder.DropColumn(
                name: "standup_weekday",
                table: "app_settings");
        }
    }
}
