using Microsoft.EntityFrameworkCore.Migrations;

namespace FamilyBudget.Data.Migrations
{
    public partial class mig4 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_depense_facture_FactureIdFacture",
                table: "depense");

            migrationBuilder.DropIndex(
                name: "IX_depense_FactureIdFacture",
                table: "depense");

            migrationBuilder.DropColumn(
                name: "FactureIdFacture",
                table: "depense");

            migrationBuilder.AddColumn<int>(
                name: "id_compte",
                table: "facture",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.CreateIndex(
                name: "IX_facture_id_compte",
                table: "facture",
                column: "id_compte");

            migrationBuilder.AddForeignKey(
                name: "FK_facture_compte",
                table: "facture",
                column: "id_compte",
                principalTable: "compte",
                principalColumn: "id_compte",
                onDelete: ReferentialAction.Restrict);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_facture_compte",
                table: "facture");

            migrationBuilder.DropIndex(
                name: "IX_facture_id_compte",
                table: "facture");

            migrationBuilder.DropColumn(
                name: "id_compte",
                table: "facture");

            migrationBuilder.AddColumn<int>(
                name: "FactureIdFacture",
                table: "depense",
                type: "int",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_depense_FactureIdFacture",
                table: "depense",
                column: "FactureIdFacture");

            migrationBuilder.AddForeignKey(
                name: "FK_depense_facture_FactureIdFacture",
                table: "depense",
                column: "FactureIdFacture",
                principalTable: "facture",
                principalColumn: "id_facture",
                onDelete: ReferentialAction.Restrict);
        }
    }
}
