using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace UserManagement.Domain.Migrations
{
///
public partial class VERSION_V2_MY_SQL : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn(
name: "Id",
table: "UserClaims",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "int")
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);
migrationBuilder.AlterColumn(
name: "Id",
table: "RoleClaims",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "int")
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);
migrationBuilder.CreateTable(
name: "CompanyProfiles",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Name = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
LogoUrl = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
BannerUrl = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedDate = table.Column(type: "datetime", nullable: false),
CreatedBy = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
ModifiedDate = table.Column(type: "datetime", nullable: false),
ModifiedBy = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
DeletedDate = table.Column(type: "datetime", nullable: true),
DeletedBy = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
IsDeleted = table.Column(type: "tinyint(1)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CompanyProfiles", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "PageHelpers",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Code = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Name = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Description = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedDate = table.Column(type: "datetime", nullable: false),
CreatedBy = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
ModifiedDate = table.Column(type: "datetime", nullable: false),
ModifiedBy = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
DeletedDate = table.Column(type: "datetime", nullable: true),
DeletedBy = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
IsDeleted = table.Column(type: "tinyint(1)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PageHelpers", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Reminders",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Subject = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Message = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Frequency = table.Column(type: "int", nullable: true),
StartDate = table.Column(type: "datetime(6)", nullable: false),
EndDate = table.Column(type: "datetime(6)", nullable: true),
DayOfWeek = table.Column(type: "int", nullable: true),
IsRepeated = table.Column(type: "tinyint(1)", nullable: false),
IsEmailNotification = table.Column(type: "tinyint(1)", nullable: false),
CreatedDate = table.Column(type: "datetime", nullable: false),
CreatedBy = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
ModifiedDate = table.Column(type: "datetime", nullable: false),
ModifiedBy = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
DeletedDate = table.Column(type: "datetime", nullable: true),
DeletedBy = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
IsDeleted = table.Column(type: "tinyint(1)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Reminders", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "ReminderSchedulers",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Duration = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(type: "tinyint(1)", nullable: false),
Frequency = table.Column(type: "int", nullable: true),
CreatedDate = table.Column(type: "datetime(6)", nullable: false),
UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
IsRead = table.Column(type: "tinyint(1)", nullable: false),
IsEmailNotification = table.Column(type: "tinyint(1)", nullable: false),
Subject = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Message = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_ReminderSchedulers", x => x.Id);
table.ForeignKey(
name: "FK_ReminderSchedulers_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "UserNotifications",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Message = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
IsRead = table.Column(type: "tinyint(1)", nullable: false),
NotificationsType = table.Column(type: "int", nullable: false),
CreatedDate = table.Column(type: "datetime", nullable: false),
CreatedBy = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
ModifiedDate = table.Column(type: "datetime", nullable: false),
ModifiedBy = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
DeletedDate = table.Column(type: "datetime", nullable: true),
DeletedBy = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
IsDeleted = table.Column(type: "tinyint(1)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserNotifications", x => x.Id);
table.ForeignKey(
name: "FK_UserNotifications_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id");
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "DailyReminders",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
ReminderId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
DayOfWeek = table.Column(type: "int", nullable: false),
IsActive = table.Column(type: "tinyint(1)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DailyReminders", x => x.Id);
table.ForeignKey(
name: "FK_DailyReminders_Reminders_ReminderId",
column: x => x.ReminderId,
principalTable: "Reminders",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "HalfYearlyReminders",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
ReminderId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Day = table.Column(type: "int", nullable: false),
Month = table.Column(type: "int", nullable: false),
Quarter = table.Column(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_HalfYearlyReminders", x => x.Id);
table.ForeignKey(
name: "FK_HalfYearlyReminders_Reminders_ReminderId",
column: x => x.ReminderId,
principalTable: "Reminders",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "QuarterlyReminders",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
ReminderId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Day = table.Column(type: "int", nullable: false),
Month = table.Column(type: "int", nullable: false),
Quarter = table.Column(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_QuarterlyReminders", x => x.Id);
table.ForeignKey(
name: "FK_QuarterlyReminders_Reminders_ReminderId",
column: x => x.ReminderId,
principalTable: "Reminders",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "ReminderNotifications",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
ReminderId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Subject = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Description = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
FetchDateTime = table.Column(type: "datetime(6)", nullable: false),
IsDeleted = table.Column(type: "tinyint(1)", nullable: false),
IsEmailNotification = table.Column(type: "tinyint(1)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ReminderNotifications", x => x.Id);
table.ForeignKey(
name: "FK_ReminderNotifications_Reminders_ReminderId",
column: x => x.ReminderId,
principalTable: "Reminders",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "ReminderUsers",
columns: table => new
{
ReminderId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_ReminderUsers", x => new { x.ReminderId, x.UserId });
table.ForeignKey(
name: "FK_ReminderUsers_Reminders_ReminderId",
column: x => x.ReminderId,
principalTable: "Reminders",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ReminderUsers_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id");
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_DailyReminders_ReminderId",
table: "DailyReminders",
column: "ReminderId");
migrationBuilder.CreateIndex(
name: "IX_HalfYearlyReminders_ReminderId",
table: "HalfYearlyReminders",
column: "ReminderId");
migrationBuilder.CreateIndex(
name: "IX_QuarterlyReminders_ReminderId",
table: "QuarterlyReminders",
column: "ReminderId");
migrationBuilder.CreateIndex(
name: "IX_ReminderNotifications_ReminderId",
table: "ReminderNotifications",
column: "ReminderId");
migrationBuilder.CreateIndex(
name: "IX_ReminderSchedulers_UserId",
table: "ReminderSchedulers",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_ReminderUsers_UserId",
table: "ReminderUsers",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_UserNotifications_UserId",
table: "UserNotifications",
column: "UserId");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CompanyProfiles");
migrationBuilder.DropTable(
name: "DailyReminders");
migrationBuilder.DropTable(
name: "HalfYearlyReminders");
migrationBuilder.DropTable(
name: "PageHelpers");
migrationBuilder.DropTable(
name: "QuarterlyReminders");
migrationBuilder.DropTable(
name: "ReminderNotifications");
migrationBuilder.DropTable(
name: "ReminderSchedulers");
migrationBuilder.DropTable(
name: "ReminderUsers");
migrationBuilder.DropTable(
name: "UserNotifications");
migrationBuilder.DropTable(
name: "Reminders");
migrationBuilder.AlterColumn(
name: "Id",
table: "UserClaims",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "int")
.OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);
migrationBuilder.AlterColumn(
name: "Id",
table: "RoleClaims",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "int")
.OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);
}
}
}