using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace MaBibli.Api.Data.Migrations
{
///
public partial class SagasEtCycles : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Series",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Titre = table.Column(type: "TEXT", nullable: false),
TitreNormalise = table.Column(type: "TEXT", nullable: false),
SerieParenteId = table.Column(type: "INTEGER", nullable: true),
Position = table.Column(type: "INTEGER", nullable: false),
DateAjout = table.Column(type: "TEXT", nullable: false),
AjoutePar = table.Column(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Series", x => x.Id);
table.ForeignKey(
name: "FK_Series_Series_SerieParenteId",
column: x => x.SerieParenteId,
principalTable: "Series",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "ElementsSerie",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
SerieId = table.Column(type: "INTEGER", nullable: false),
Position = table.Column(type: "INTEGER", nullable: false),
LivreId = table.Column(type: "INTEGER", nullable: true),
Titre = table.Column(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ElementsSerie", x => x.Id);
table.ForeignKey(
name: "FK_ElementsSerie_Livres_LivreId",
column: x => x.LivreId,
principalTable: "Livres",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_ElementsSerie_Series_SerieId",
column: x => x.SerieId,
principalTable: "Series",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_ElementsSerie_LivreId",
table: "ElementsSerie",
column: "LivreId");
migrationBuilder.CreateIndex(
name: "IX_ElementsSerie_SerieId",
table: "ElementsSerie",
column: "SerieId");
migrationBuilder.CreateIndex(
name: "IX_ElementsSerie_SerieId_LivreId",
table: "ElementsSerie",
columns: new[] { "SerieId", "LivreId" },
unique: true,
filter: "\"LivreId\" IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_Series_SerieParenteId",
table: "Series",
column: "SerieParenteId");
migrationBuilder.CreateIndex(
name: "IX_Series_TitreNormalise",
table: "Series",
column: "TitreNormalise",
unique: true);
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ElementsSerie");
migrationBuilder.DropTable(
name: "Series");
}
}
}