186 lines
9.1 KiB
C#
186 lines
9.1 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Metadata;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace SPMS.Infrastructure.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddPublicApiTables : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "AppConfig",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
ServiceId = table.Column<long>(type: "bigint", nullable: false),
|
|
ConfigKey = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
ConfigValue = table.Column<string>(type: "text", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_AppConfig", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_AppConfig_Service_ServiceId",
|
|
column: x => x.ServiceId,
|
|
principalTable: "Service",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Banner",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
ServiceId = table.Column<long>(type: "bigint", nullable: false),
|
|
Title = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
ImageUrl = table.Column<string>(type: "varchar(500)", maxLength: 500, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
LinkUrl = table.Column<string>(type: "varchar(500)", maxLength: 500, nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
LinkType = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Position = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
SortOrder = table.Column<int>(type: "int", nullable: false),
|
|
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: true),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
|
IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Banner", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Banner_Service_ServiceId",
|
|
column: x => x.ServiceId,
|
|
principalTable: "Service",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Faq",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
ServiceId = table.Column<long>(type: "bigint", nullable: false),
|
|
Category = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Question = table.Column<string>(type: "varchar(500)", maxLength: 500, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Answer = table.Column<string>(type: "text", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
SortOrder = table.Column<int>(type: "int", nullable: false),
|
|
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: true),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Faq", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Faq_Service_ServiceId",
|
|
column: x => x.ServiceId,
|
|
principalTable: "Service",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Notice",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
ServiceId = table.Column<long>(type: "bigint", nullable: false),
|
|
Title = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Content = table.Column<string>(type: "text", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
IsPinned = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false),
|
|
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: true),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
CreatedBy = table.Column<long>(type: "bigint", nullable: false),
|
|
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
|
IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Notice", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Notice_Admin_CreatedBy",
|
|
column: x => x.CreatedBy,
|
|
principalTable: "Admin",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_Notice_Service_ServiceId",
|
|
column: x => x.ServiceId,
|
|
principalTable: "Service",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_AppConfig_ServiceId_ConfigKey",
|
|
table: "AppConfig",
|
|
columns: new[] { "ServiceId", "ConfigKey" },
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Banner_ServiceId",
|
|
table: "Banner",
|
|
column: "ServiceId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Faq_ServiceId",
|
|
table: "Faq",
|
|
column: "ServiceId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Notice_CreatedBy",
|
|
table: "Notice",
|
|
column: "CreatedBy");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Notice_ServiceId",
|
|
table: "Notice",
|
|
column: "ServiceId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "AppConfig");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Banner");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Faq");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Notice");
|
|
}
|
|
}
|
|
}
|