using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Marco.Pms.DataAccess.Migrations
{
    /// 
    public partial class Added_Mail_Related_Tables : Migration
    {
        /// 
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "MailingList",
                columns: table => new
                {
                    Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Title = table.Column(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Body = table.Column(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Keywords = table.Column(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    TenantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MailingList", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");
            migrationBuilder.CreateTable(
                name: "MailLogs",
                columns: table => new
                {
                    Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    ProjectId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Body = table.Column(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    EmailId = table.Column(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    TimeStamp = table.Column(type: "datetime(6)", nullable: false),
                    TenantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    EmployeeId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MailLogs", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");
            migrationBuilder.CreateTable(
                name: "MailDetails",
                columns: table => new
                {
                    Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    ProjectId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Recipient = table.Column(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Subject = table.Column(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Schedule = table.Column(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    MailListId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    TenantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MailDetails", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MailDetails_MailingList_MailListId",
                        column: x => x.MailListId,
                        principalTable: "MailingList",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");
            migrationBuilder.CreateIndex(
                name: "IX_MailDetails_MailListId",
                table: "MailDetails",
                column: "MailListId");
        }
        /// 
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "MailDetails");
            migrationBuilder.DropTable(
                name: "MailLogs");
            migrationBuilder.DropTable(
                name: "MailingList");
        }
    }
}