using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace SIFinance.Shared.Migrations { /// public partial class AddContratsAndPaiementStatut : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "statut", schema: "fin", table: "paiements", type: "varchar(20)", unicode: false, maxLength: 20, nullable: false, defaultValue: "PROGRAMME"); migrationBuilder.AddColumn( 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(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), fournisseur_id = table.Column(type: "int", nullable: false), reference = table.Column(type: "varchar(50)", unicode: false, maxLength: 50, nullable: true), objet = table.Column(type: "varchar(255)", unicode: false, maxLength: 255, nullable: false), date_signature = table.Column(type: "date", nullable: true), date_debut = table.Column(type: "date", nullable: false), date_fin = table.Column(type: "date", nullable: false), montant_total = table.Column(type: "decimal(18,2)", nullable: false), periodicite = table.Column(type: "varchar(20)", unicode: false, maxLength: 20, nullable: false, defaultValue: "mensuelle"), statut = table.Column(type: "varchar(20)", unicode: false, maxLength: 20, nullable: false, defaultValue: "ACTIF"), saisie_par_id = table.Column(type: "int", nullable: false), date_creation = table.Column(type: "datetime", nullable: true, defaultValueSql: "(getdate())"), date_derniere_maj = table.Column(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(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), contrat_id = table.Column(type: "int", nullable: false), date_echeance = table.Column(type: "date", nullable: false), montant = table.Column(type: "decimal(18,2)", nullable: false), statut = table.Column(type: "varchar(20)", unicode: false, maxLength: 20, nullable: false, defaultValue: "A_VENIR"), justificatif_id = table.Column(type: "int", nullable: true), date_creation = table.Column(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"); } /// 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"); } } }