using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace Marco.Pms.DataAccess.Migrations
{
///
public partial class Added_Subscription_Related_Tables : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "CurrencyMaster",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
CurrencyCode = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
CurrencyName = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Symbol = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
IsActive = table.Column(type: "tinyint(1)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CurrencyMaster", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "SubscriptionStatus",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Name = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_SubscriptionStatus", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "SubscriptionPlans",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
PlanName = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Description = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
PriceQuarterly = table.Column(type: "double", nullable: false),
PriceMonthly = table.Column(type: "double", nullable: false),
PriceHalfMonthly = table.Column(type: "double", nullable: false),
PriceYearly = table.Column(type: "double", nullable: false),
TrialDays = table.Column(type: "int", nullable: false),
MaxUser = table.Column(type: "double", nullable: false),
MaxStorage = table.Column(type: "double", nullable: false),
FeaturesId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
CreateAt = table.Column(type: "datetime(6)", nullable: false),
UpdateAt = table.Column(type: "datetime(6)", nullable: true),
CurrencyId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
CreatedById = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
UpdatedById = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
IsActive = table.Column(type: "tinyint(1)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SubscriptionPlans", x => x.Id);
table.ForeignKey(
name: "FK_SubscriptionPlans_CurrencyMaster_CurrencyId",
column: x => x.CurrencyId,
principalTable: "CurrencyMaster",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_SubscriptionPlans_Employees_CreatedById",
column: x => x.CreatedById,
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_SubscriptionPlans_Employees_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Employees",
principalColumn: "Id");
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "TenantSubscriptions",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
PlanId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
StartDate = table.Column(type: "datetime(6)", nullable: false),
EndDate = table.Column(type: "datetime(6)", nullable: false),
IsTrial = table.Column(type: "tinyint(1)", nullable: false),
StatusId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
CurrencyId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
NextBillingDate = table.Column(type: "datetime(6)", nullable: false),
CancellationDate = table.Column(type: "datetime(6)", nullable: true),
AutoRemew = table.Column(type: "tinyint(1)", nullable: false),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
UpdateAt = table.Column(type: "datetime(6)", nullable: true),
CreatedById = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
UpdatedById = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
TenantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_TenantSubscriptions", x => x.Id);
table.ForeignKey(
name: "FK_TenantSubscriptions_CurrencyMaster_CurrencyId",
column: x => x.CurrencyId,
principalTable: "CurrencyMaster",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_TenantSubscriptions_Employees_CreatedById",
column: x => x.CreatedById,
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_TenantSubscriptions_Employees_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Employees",
principalColumn: "Id");
table.ForeignKey(
name: "FK_TenantSubscriptions_SubscriptionPlans_PlanId",
column: x => x.PlanId,
principalTable: "SubscriptionPlans",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_TenantSubscriptions_SubscriptionStatus_StatusId",
column: x => x.StatusId,
principalTable: "SubscriptionStatus",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_TenantSubscriptions_Tenants_TenantId",
column: x => x.TenantId,
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.InsertData(
table: "CurrencyMaster",
columns: new[] { "Id", "CurrencyCode", "CurrencyName", "IsActive", "Symbol" },
values: new object[,]
{
{ new Guid("297e237a-56d3-48f6-b39d-ec3991dea8bf"), "JPY", "Japanese Yen", true, "¥" },
{ new Guid("2f672568-a67b-4961-acb2-a8c7834e1762"), "USD", "US Dollar", true, "$" },
{ new Guid("3e456237-ef06-4ea1-a261-188c9b0c6df6"), "GBP", "Pound Sterling", true, "£" },
{ new Guid("4d1155bb-1448-4d97-a732-96c92eb99c45"), "EUR", "Euro", true, "€" },
{ new Guid("78e96e4a-7ce0-4164-ae3a-c833ad45ec2c"), "INR", "Indian Rupee", true, "₹" },
{ new Guid("b960166a-f7e9-49e3-bb4b-28511f126c08"), "CNY", "Chinese Yuan (Renminbi)", true, "¥" },
{ new Guid("efe9b4f6-64d6-446e-a42d-1c7aaf6dd70d"), "RUB", "Russian Ruble", true, "₽" }
});
migrationBuilder.InsertData(
table: "SubscriptionStatus",
columns: new[] { "Id", "Name" },
values: new object[,]
{
{ new Guid("1c0e422e-01b6-412f-b72a-1db004cc8a7f"), "Suspended" },
{ new Guid("4ed487b1-af22-4e25-aecd-b63fd850cf2d"), "InActive" },
{ new Guid("cd3a68ea-41fd-42f0-bd0c-c871c7337727"), "Active" }
});
migrationBuilder.CreateIndex(
name: "IX_SubscriptionPlans_CreatedById",
table: "SubscriptionPlans",
column: "CreatedById");
migrationBuilder.CreateIndex(
name: "IX_SubscriptionPlans_CurrencyId",
table: "SubscriptionPlans",
column: "CurrencyId");
migrationBuilder.CreateIndex(
name: "IX_SubscriptionPlans_UpdatedById",
table: "SubscriptionPlans",
column: "UpdatedById");
migrationBuilder.CreateIndex(
name: "IX_TenantSubscriptions_CreatedById",
table: "TenantSubscriptions",
column: "CreatedById");
migrationBuilder.CreateIndex(
name: "IX_TenantSubscriptions_CurrencyId",
table: "TenantSubscriptions",
column: "CurrencyId");
migrationBuilder.CreateIndex(
name: "IX_TenantSubscriptions_PlanId",
table: "TenantSubscriptions",
column: "PlanId");
migrationBuilder.CreateIndex(
name: "IX_TenantSubscriptions_StatusId",
table: "TenantSubscriptions",
column: "StatusId");
migrationBuilder.CreateIndex(
name: "IX_TenantSubscriptions_TenantId",
table: "TenantSubscriptions",
column: "TenantId");
migrationBuilder.CreateIndex(
name: "IX_TenantSubscriptions_UpdatedById",
table: "TenantSubscriptions",
column: "UpdatedById");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "TenantSubscriptions");
migrationBuilder.DropTable(
name: "SubscriptionPlans");
migrationBuilder.DropTable(
name: "SubscriptionStatus");
migrationBuilder.DropTable(
name: "CurrencyMaster");
}
}
}