20220914122629_Produce.cs 4.0 KB
Newer Older
麦壳饼's avatar
麦壳饼 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace IoTSharp.Data.Sqlite.Migrations
{
    public partial class Produce : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<Guid>(
                name: "ProduceId",
                table: "Device",
                type: "TEXT",
                nullable: true);

18 19 20 21 22 23
            migrationBuilder.AddColumn<Guid>(
                name: "OwnerId",
                table: "DataStorage",
                type: "TEXT",
                nullable: true);

麦壳饼's avatar
麦壳饼 已提交
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
            migrationBuilder.CreateTable(
                name: "Produce",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "TEXT", nullable: false),
                    Name = table.Column<string>(type: "TEXT", nullable: true, collation: "NOCASE"),
                    DefaultTimeout = table.Column<int>(type: "INTEGER", nullable: false),
                    TenantId = table.Column<Guid>(type: "TEXT", nullable: true),
                    CustomerId = table.Column<Guid>(type: "TEXT", nullable: true),
                    DefaultIdentityType = table.Column<int>(type: "INTEGER", nullable: false),
                    Description = table.Column<string>(type: "TEXT", nullable: true, collation: "NOCASE")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Produce", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Produce_Customer_CustomerId",
                        column: x => x.CustomerId,
                        principalTable: "Customer",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_Produce_Tenant_TenantId",
                        column: x => x.TenantId,
                        principalTable: "Tenant",
                        principalColumn: "Id");
                });

            migrationBuilder.CreateIndex(
                name: "IX_Device_ProduceId",
                table: "Device",
                column: "ProduceId");

            migrationBuilder.CreateIndex(
57
                name: "IX_DataStorage_OwnerId",
麦壳饼's avatar
麦壳饼 已提交
58
                table: "DataStorage",
59
                column: "OwnerId");
麦壳饼's avatar
麦壳饼 已提交
60 61 62 63 64 65 66 67 68 69 70 71

            migrationBuilder.CreateIndex(
                name: "IX_Produce_CustomerId",
                table: "Produce",
                column: "CustomerId");

            migrationBuilder.CreateIndex(
                name: "IX_Produce_TenantId",
                table: "Produce",
                column: "TenantId");

            migrationBuilder.AddForeignKey(
72
                name: "FK_DataStorage_Produce_OwnerId",
麦壳饼's avatar
麦壳饼 已提交
73
                table: "DataStorage",
74
                column: "OwnerId",
麦壳饼's avatar
麦壳饼 已提交
75
                principalTable: "Produce",
76
                principalColumn: "Id");
麦壳饼's avatar
麦壳饼 已提交
77 78 79 80 81 82 83 84 85 86 87 88

            migrationBuilder.AddForeignKey(
                name: "FK_Device_Produce_ProduceId",
                table: "Device",
                column: "ProduceId",
                principalTable: "Produce",
                principalColumn: "Id");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
89
                name: "FK_DataStorage_Produce_OwnerId",
麦壳饼's avatar
麦壳饼 已提交
90 91 92 93 94 95 96 97 98 99 100 101 102 103
                table: "DataStorage");

            migrationBuilder.DropForeignKey(
                name: "FK_Device_Produce_ProduceId",
                table: "Device");

            migrationBuilder.DropTable(
                name: "Produce");

            migrationBuilder.DropIndex(
                name: "IX_Device_ProduceId",
                table: "Device");

            migrationBuilder.DropIndex(
104
                name: "IX_DataStorage_OwnerId",
麦壳饼's avatar
麦壳饼 已提交
105 106 107 108 109
                table: "DataStorage");

            migrationBuilder.DropColumn(
                name: "ProduceId",
                table: "Device");
110 111 112 113

            migrationBuilder.DropColumn(
                name: "OwnerId",
                table: "DataStorage");
麦壳饼's avatar
麦壳饼 已提交
114 115 116
        }
    }
}