using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace SchotzIadKmTracker.Api.Data.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "AdresseCache", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Adresse = table.Column(type: "TEXT", maxLength: 255, nullable: false), Latitude = table.Column(type: "REAL", nullable: false), Longitude = table.Column(type: "REAL", nullable: false), GeometrieJson = table.Column(type: "TEXT", nullable: true), DerniereUtilisation = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AdresseCache", x => x.Id); }); migrationBuilder.CreateTable( name: "AdressesNommees", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Denomination = table.Column(type: "TEXT", maxLength: 100, nullable: false), DenominationNormalisee = table.Column(type: "TEXT", maxLength: 100, nullable: false), Adresse = table.Column(type: "TEXT", maxLength: 255, nullable: false), Latitude = table.Column(type: "REAL", nullable: true), Longitude = table.Column(type: "REAL", nullable: true), GeocodageReussi = table.Column(type: "INTEGER", nullable: false), CreatedAt = table.Column(type: "TEXT", nullable: false), UpdatedAt = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AdressesNommees", x => x.Id); }); migrationBuilder.CreateTable( name: "Profil", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false), Nom = table.Column(type: "TEXT", maxLength: 100, nullable: true), Prenom = table.Column(type: "TEXT", maxLength: 100, nullable: true), Matricule = table.Column(type: "TEXT", maxLength: 8, nullable: true), AdresseDomicile = table.Column(type: "TEXT", maxLength: 255, nullable: true), DomicileLatitude = table.Column(type: "REAL", nullable: true), DomicileLongitude = table.Column(type: "REAL", nullable: true), DomicileGeocode = table.Column(type: "INTEGER", nullable: false), UpdatedAt = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Profil", x => x.Id); }); migrationBuilder.CreateTable( name: "TranchesBareme", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Annee = table.Column(type: "INTEGER", nullable: false), PuissanceFiscale = table.Column(type: "INTEGER", nullable: false), KmMin = table.Column(type: "TEXT", nullable: false), KmMax = table.Column(type: "TEXT", nullable: false), Coefficient = table.Column(type: "TEXT", nullable: false), Base = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_TranchesBareme", x => x.Id); table.CheckConstraint("CK_TranchesBareme_Km", "\"KmMin\" <= \"KmMax\""); }); migrationBuilder.CreateTable( name: "Vehicules", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Plaque = table.Column(type: "TEXT", maxLength: 15, nullable: false), PuissanceFiscale = table.Column(type: "INTEGER", nullable: false), DateEffet = table.Column(type: "TEXT", nullable: false), CreatedAt = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Vehicules", x => x.Id); table.CheckConstraint("CK_Vehicules_PuissanceFiscale", "\"PuissanceFiscale\" > 0"); }); migrationBuilder.CreateTable( name: "MontantsRegles", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Annee = table.Column(type: "INTEGER", nullable: false), Mois = table.Column(type: "INTEGER", nullable: false), VehiculeId = table.Column(type: "INTEGER", nullable: false), Montant = table.Column(type: "TEXT", nullable: false), UpdatedAt = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_MontantsRegles", x => x.Id); table.CheckConstraint("CK_MontantsRegles_Mois", "\"Mois\" BETWEEN 1 AND 12"); table.CheckConstraint("CK_MontantsRegles_Montant", "\"Montant\" >= 0"); table.ForeignKey( name: "FK_MontantsRegles_Vehicules_VehiculeId", column: x => x.VehiculeId, principalTable: "Vehicules", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Trajets", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Date = table.Column(type: "TEXT", nullable: false), AdresseDepart = table.Column(type: "TEXT", maxLength: 255, nullable: false), AdresseArrivee = table.Column(type: "TEXT", maxLength: 255, nullable: false), Distance = table.Column(type: "TEXT", nullable: false), Commentaire = table.Column(type: "TEXT", maxLength: 500, nullable: true), Position = table.Column(type: "TEXT", nullable: false), VehiculeId = table.Column(type: "INTEGER", nullable: false), PuissanceFiscale = table.Column(type: "INTEGER", nullable: false), CreatedAt = table.Column(type: "TEXT", nullable: false), UpdatedAt = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Trajets", x => x.Id); table.CheckConstraint("CK_Trajets_Distance", "\"Distance\" > 0"); table.CheckConstraint("CK_Trajets_PuissanceFiscale", "\"PuissanceFiscale\" > 0"); table.ForeignKey( name: "FK_Trajets_Vehicules_VehiculeId", column: x => x.VehiculeId, principalTable: "Vehicules", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_AdresseCache_Adresse", table: "AdresseCache", column: "Adresse", unique: true); migrationBuilder.CreateIndex( name: "UX_AdresseNommee_Denomination", table: "AdressesNommees", column: "DenominationNormalisee", unique: true); migrationBuilder.CreateIndex( name: "IX_MontantsRegles_VehiculeId", table: "MontantsRegles", column: "VehiculeId"); migrationBuilder.CreateIndex( name: "UX_MontantsRegles_Periode_Vehicule", table: "MontantsRegles", columns: new[] { "Annee", "Mois", "VehiculeId" }, unique: true); migrationBuilder.CreateIndex( name: "UX_Profil_Singleton", table: "Profil", column: "Id", unique: true); migrationBuilder.CreateIndex( name: "IX_Trajets_Date", table: "Trajets", column: "Date"); migrationBuilder.CreateIndex( name: "IX_Trajets_Date_Position", table: "Trajets", columns: new[] { "Date", "Position" }); migrationBuilder.CreateIndex( name: "IX_Trajets_Vehicule", table: "Trajets", column: "VehiculeId"); migrationBuilder.CreateIndex( name: "IX_TranchesBareme_Annee_PF", table: "TranchesBareme", columns: new[] { "Annee", "PuissanceFiscale" }); migrationBuilder.CreateIndex( name: "IX_Vehicules_DateEffet", table: "Vehicules", column: "DateEffet"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "AdresseCache"); migrationBuilder.DropTable( name: "AdressesNommees"); migrationBuilder.DropTable( name: "MontantsRegles"); migrationBuilder.DropTable( name: "Profil"); migrationBuilder.DropTable( name: "Trajets"); migrationBuilder.DropTable( name: "TranchesBareme"); migrationBuilder.DropTable( name: "Vehicules"); } } }