using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SIFinance.Shared.Migrations
{
///
public partial class AddSousTraitantsOrganismesContrats : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "st");
migrationBuilder.CreateTable(
name: "organismes",
schema: "st",
columns: table => new
{
id = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
raison_sociale = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false),
siret = table.Column(type: "varchar(20)", unicode: false, maxLength: 20, nullable: true),
email = table.Column(type: "varchar(255)", unicode: false, maxLength: 255, nullable: true),
telephone = table.Column(type: "varchar(30)", unicode: false, maxLength: 30, nullable: true),
adresse = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true),
statut = table.Column(type: "varchar(20)", unicode: false, maxLength: 20, nullable: false, defaultValue: "ACTIF"),
date_creation = table.Column(type: "datetime", nullable: true, defaultValueSql: "(getdate())")
},
constraints: table =>
{
table.PrimaryKey("PK__organismes", x => x.id);
});
migrationBuilder.CreateTable(
name: "contrats_prestataires",
schema: "st",
columns: table => new
{
id = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
organisme_id = table.Column(type: "int", nullable: false),
reference = table.Column(type: "varchar(50)", unicode: false, maxLength: 50, nullable: false),
objet = table.Column(type: "nvarchar(255)", 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),
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())")
},
constraints: table =>
{
table.PrimaryKey("PK__contrats_prestataires", x => x.id);
table.ForeignKey(
name: "FK__contrats_prestataires__organisme",
column: x => x.organisme_id,
principalSchema: "st",
principalTable: "organismes",
principalColumn: "id");
table.ForeignKey(
name: "FK__contrats_prestataires__saisie_par",
column: x => x.saisie_par_id,
principalSchema: "core",
principalTable: "utilisateurs",
principalColumn: "id");
});
migrationBuilder.CreateIndex(
name: "IX_ctp_organisme",
schema: "st",
table: "contrats_prestataires",
column: "organisme_id");
migrationBuilder.CreateIndex(
name: "IX_ctp_saisie_par",
schema: "st",
table: "contrats_prestataires",
column: "saisie_par_id");
migrationBuilder.CreateIndex(
name: "UQ_ctp_reference",
schema: "st",
table: "contrats_prestataires",
column: "reference",
unique: true);
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "contrats_prestataires",
schema: "st");
migrationBuilder.DropTable(
name: "organismes",
schema: "st");
}
}
}