using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional

namespace BlazorPolicyAuth.Migrations
{
    /// <inheritdoc />
    public partial class useraccountwithpolicies : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "user_account",
                columns: table => new
                {
                    id = table.Column<int>(type: "INTEGER", nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    user_name = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
                    password = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_user_account", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "user_account_policy",
                columns: table => new
                {
                    id = table.Column<int>(type: "INTEGER", nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    user_account_policy = table.Column<int>(type: "INTEGER", nullable: false),
                    user_policy = table.Column<string>(type: "TEXT", nullable: true),
                    is_enabled = table.Column<bool>(type: "INTEGER", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_user_account_policy", x => x.id);
                });

            migrationBuilder.InsertData(
                table: "user_account",
                columns: new[] { "id", "password", "user_name" },
                values: new object[,]
                {
                    { 1, "user1", "user1" },
                    { 2, "user2", "user2" },
                    { 3, "user3", "user3" },
                    { 4, "user4", "user4" },
                    { 5, "user5", "user5" }
                });

            migrationBuilder.InsertData(
                table: "user_account_policy",
                columns: new[] { "id", "is_enabled", "user_account_policy", "user_policy" },
                values: new object[,]
                {
                    { 1, false, 1, "VIEW_PRODUCT" },
                    { 2, false, 1, "ADD_PRODUCT" },
                    { 3, false, 1, "EDIT_PRODUCT" },
                    { 4, false, 1, "DELETE_PRODUCT" },
                    { 5, true, 2, "VIEW_PRODUCT" },
                    { 6, false, 2, "ADD_PRODUCT" },
                    { 7, false, 2, "EDIT_PRODUCT" },
                    { 8, false, 2, "DELETE_PRODUCT" },
                    { 9, true, 3, "VIEW_PRODUCT" },
                    { 10, true, 3, "ADD_PRODUCT" },
                    { 11, false, 3, "EDIT_PRODUCT" },
                    { 12, false, 3, "DELETE_PRODUCT" },
                    { 13, true, 4, "VIEW_PRODUCT" },
                    { 14, true, 4, "ADD_PRODUCT" },
                    { 15, true, 4, "EDIT_PRODUCT" },
                    { 16, false, 4, "DELETE_PRODUCT" },
                    { 17, true, 5, "VIEW_PRODUCT" },
                    { 18, true, 5, "ADD_PRODUCT" },
                    { 19, true, 5, "EDIT_PRODUCT" },
                    { 20, true, 5, "DELETE_PRODUCT" }
                });
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "user_account");

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