using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace TwilioSMSReceiver.Data.Migrations
{
    public partial class InitialMigration : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "MSTeamsWebHooks",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    WebHookUri = table.Column<string>(type: "TEXT", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MSTeamsWebHooks", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "SMSMessages",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    ReceivedNumber = table.Column<string>(type: "TEXT", nullable: false),
                    SenderNumber = table.Column<string>(type: "TEXT", nullable: false),
                    TimeReceived = table.Column<DateTime>(type: "TEXT", nullable: false),
                    MessageContents = table.Column<string>(type: "TEXT", nullable: true),
                    IsForwardedYet = table.Column<bool>(type: "INTEGER", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SMSMessages", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "MMSMessages",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    SMSModelId = table.Column<int>(type: "INTEGER", nullable: false),
                    OriginalMMSData = table.Column<string>(type: "TEXT", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MMSMessages", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MMSMessages_SMSMessages_SMSModelId",
                        column: x => x.SMSModelId,
                        principalTable: "SMSMessages",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_MMSMessages_SMSModelId",
                table: "MMSMessages",
                column: "SMSModelId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "MMSMessages");

            migrationBuilder.DropTable(
                name: "MSTeamsWebHooks");

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