Files
SIFINANCE/SIFinance.Shared/Migrations/20260727094858_AddContratsAndPaiementStatut.cs
2026-09-11 14:55:41 +02:00

149 lines
6.5 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SIFinance.Shared.Migrations
{
/// <inheritdoc />
public partial class AddContratsAndPaiementStatut : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "statut",
schema: "fin",
table: "paiements",
type: "varchar(20)",
unicode: false,
maxLength: 20,
nullable: false,
defaultValue: "PROGRAMME");
migrationBuilder.AddColumn<bool>(
name: "rapproche",
schema: "fin",
table: "paiements",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.CreateTable(
name: "contrats_fournisseurs",
schema: "achats",
columns: table => new
{
id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
fournisseur_id = table.Column<int>(type: "int", nullable: false),
reference = table.Column<string>(type: "varchar(50)", unicode: false, maxLength: 50, nullable: true),
objet = table.Column<string>(type: "varchar(255)", unicode: false, maxLength: 255, nullable: false),
date_signature = table.Column<DateOnly>(type: "date", nullable: true),
date_debut = table.Column<DateOnly>(type: "date", nullable: false),
date_fin = table.Column<DateOnly>(type: "date", nullable: false),
montant_total = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
periodicite = table.Column<string>(type: "varchar(20)", unicode: false, maxLength: 20, nullable: false, defaultValue: "mensuelle"),
statut = table.Column<string>(type: "varchar(20)", unicode: false, maxLength: 20, nullable: false, defaultValue: "ACTIF"),
saisie_par_id = table.Column<int>(type: "int", nullable: false),
date_creation = table.Column<DateTime>(type: "datetime", nullable: true, defaultValueSql: "(getdate())"),
date_derniere_maj = table.Column<DateTime>(type: "datetime", nullable: true, defaultValueSql: "(getdate())")
},
constraints: table =>
{
table.PrimaryKey("PK__contrats_fournisseurs", x => x.id);
table.ForeignKey(
name: "FK__contrats_fournisseurs__fournisseur",
column: x => x.fournisseur_id,
principalSchema: "ref",
principalTable: "fournisseurs",
principalColumn: "id");
table.ForeignKey(
name: "FK__contrats_fournisseurs__saisie_par",
column: x => x.saisie_par_id,
principalSchema: "core",
principalTable: "utilisateurs",
principalColumn: "id");
});
migrationBuilder.CreateTable(
name: "contrats_echeances",
schema: "achats",
columns: table => new
{
id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
contrat_id = table.Column<int>(type: "int", nullable: false),
date_echeance = table.Column<DateOnly>(type: "date", nullable: false),
montant = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
statut = table.Column<string>(type: "varchar(20)", unicode: false, maxLength: 20, nullable: false, defaultValue: "A_VENIR"),
justificatif_id = table.Column<int>(type: "int", nullable: true),
date_creation = table.Column<DateTime>(type: "datetime", nullable: true, defaultValueSql: "(getdate())")
},
constraints: table =>
{
table.PrimaryKey("PK__contrats_echeances", x => x.id);
table.ForeignKey(
name: "FK__contrats_echeances__contrat",
column: x => x.contrat_id,
principalSchema: "achats",
principalTable: "contrats_fournisseurs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK__contrats_echeances__justificatif",
column: x => x.justificatif_id,
principalSchema: "core",
principalTable: "pieces_jointes",
principalColumn: "id");
});
migrationBuilder.CreateIndex(
name: "IX_ctf_fournisseur",
schema: "achats",
table: "contrats_fournisseurs",
column: "fournisseur_id");
migrationBuilder.CreateIndex(
name: "IX_ctf_saisie_par",
schema: "achats",
table: "contrats_fournisseurs",
column: "saisie_par_id");
migrationBuilder.CreateIndex(
name: "IX_cte_contrat",
schema: "achats",
table: "contrats_echeances",
column: "contrat_id");
migrationBuilder.CreateIndex(
name: "IX_cte_justif",
schema: "achats",
table: "contrats_echeances",
column: "justificatif_id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "contrats_echeances",
schema: "achats");
migrationBuilder.DropTable(
name: "contrats_fournisseurs",
schema: "achats");
migrationBuilder.DropColumn(
name: "rapproche",
schema: "fin",
table: "paiements");
migrationBuilder.DropColumn(
name: "statut",
schema: "fin",
table: "paiements");
}
}
}