using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace UWLib.Migrations
{
    /// <inheritdoc />
    public partial class Init : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Lectures",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false),
                    Semester = table.Column<string>(type: "TEXT", nullable: false),
                    Title = table.Column<string>(type: "TEXT", nullable: false),
                    Url = table.Column<string>(type: "TEXT", nullable: false),
                    Description = table.Column<string>(type: "TEXT", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Lectures", x => new { x.Id, x.Semester });
                });

            migrationBuilder.CreateTable(
                name: "LectureEvents",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    From = table.Column<DateTime>(type: "TEXT", nullable: false),
                    To = table.Column<DateTime>(type: "TEXT", nullable: false),
                    Location = table.Column<string>(type: "TEXT", nullable: false),
                    LectureId = table.Column<int>(type: "INTEGER", nullable: false),
                    LectureSemester = table.Column<string>(type: "TEXT", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_LectureEvents", x => x.Id);
                    table.ForeignKey(
                        name: "FK_LectureEvents_Lectures_LectureId_LectureSemester",
                        columns: x => new { x.LectureId, x.LectureSemester },
                        principalTable: "Lectures",
                        principalColumns: ["Id", "Semester"],
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_LectureEvents_LectureId_LectureSemester",
                table: "LectureEvents",
                columns: ["LectureId", "LectureSemester"]);
        }

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

            migrationBuilder.DropTable(
                name: "Lectures");
        }
    }
}
