﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;

namespace KingYSoft.Foretch.Migrations
{
    public partial class Foretch_02 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_QuestionTags_QuestionApproves_QuestionApproveId",
                table: "QuestionTags");

            migrationBuilder.DropForeignKey(
                name: "FK_QuestionTags_QuestionHistories_QuestionHistoryId",
                table: "QuestionTags");

            migrationBuilder.DropIndex(
                name: "IX_QuestionTags_QuestionApproveId",
                table: "QuestionTags");

            migrationBuilder.DropIndex(
                name: "IX_QuestionTags_QuestionHistoryId",
                table: "QuestionTags");

            migrationBuilder.DropColumn(
                name: "QuestionApproveId",
                table: "QuestionTags");

            migrationBuilder.DropColumn(
                name: "QuestionHistoryId",
                table: "QuestionTags");

            migrationBuilder.AddColumn<string>(
                name: "Remark",
                table: "UserReputations",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "UserReputationType",
                table: "UserReputations",
                nullable: false,
                defaultValue: 0);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "Remark",
                table: "UserReputations");

            migrationBuilder.DropColumn(
                name: "UserReputationType",
                table: "UserReputations");

            migrationBuilder.AddColumn<long>(
                name: "QuestionApproveId",
                table: "QuestionTags",
                nullable: true);

            migrationBuilder.AddColumn<long>(
                name: "QuestionHistoryId",
                table: "QuestionTags",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_QuestionTags_QuestionApproveId",
                table: "QuestionTags",
                column: "QuestionApproveId");

            migrationBuilder.CreateIndex(
                name: "IX_QuestionTags_QuestionHistoryId",
                table: "QuestionTags",
                column: "QuestionHistoryId");

            migrationBuilder.AddForeignKey(
                name: "FK_QuestionTags_QuestionApproves_QuestionApproveId",
                table: "QuestionTags",
                column: "QuestionApproveId",
                principalTable: "QuestionApproves",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_QuestionTags_QuestionHistories_QuestionHistoryId",
                table: "QuestionTags",
                column: "QuestionHistoryId",
                principalTable: "QuestionHistories",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
    }
}
