using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace FarmatikoData.Migrations { public partial class InitialMigration : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "HealthFacilities", columns: table => new { Id = table.Column(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), CreatedOn = table.Column(nullable: false, defaultValueSql: "now()"), DeletedOn = table.Column(nullable: true), Name = table.Column(nullable: false), Municipality = table.Column(nullable: false), Address = table.Column(nullable: false), Type = table.Column(nullable: false), Email = table.Column(nullable: true), Phone = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_HealthFacilities", x => x.Id); }); migrationBuilder.CreateTable( name: "Pandemics", columns: table => new { Id = table.Column(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), CreatedOn = table.Column(nullable: false, defaultValueSql: "now()"), DeletedOn = table.Column(nullable: true), Name = table.Column(nullable: false), TotalMK = table.Column(nullable: false), ActiveMK = table.Column(nullable: false), DeathsMK = table.Column(nullable: false), NewMK = table.Column(nullable: false), TotalGlobal = table.Column(nullable: false), DeathsGlobal = table.Column(nullable: false), ActiveGlobal = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Pandemics", x => x.Id); }); migrationBuilder.CreateTable( name: "PharmacyHeads", columns: table => new { Id = table.Column(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), CreatedOn = table.Column(nullable: false, defaultValueSql: "now()"), DeletedOn = table.Column(nullable: true), Email = table.Column(nullable: false), Name = table.Column(nullable: false), Password = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_PharmacyHeads", x => x.Id); }); migrationBuilder.CreateTable( name: "Users", columns: table => new { Id = table.Column(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), CreatedOn = table.Column(nullable: false, defaultValueSql: "now()"), DeletedOn = table.Column(nullable: true), Name = table.Column(nullable: false), Email = table.Column(nullable: false), Password = table.Column(nullable: false), UserRole = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); }); migrationBuilder.CreateTable( name: "HealthcareWorkers", columns: table => new { Id = table.Column(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), CreatedOn = table.Column(nullable: false, defaultValueSql: "now()"), DeletedOn = table.Column(nullable: true), Name = table.Column(nullable: false), Branch = table.Column(nullable: false), FacilityId = table.Column(nullable: false), Title = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_HealthcareWorkers", x => x.Id); table.ForeignKey( name: "FK_HealthcareWorkers_HealthFacilities_FacilityId", column: x => x.FacilityId, principalTable: "HealthFacilities", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Medicines", columns: table => new { Id = table.Column(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), CreatedOn = table.Column(nullable: false, defaultValueSql: "now()"), DeletedOn = table.Column(nullable: true), Name = table.Column(nullable: false), Strength = table.Column(nullable: false), Form = table.Column(nullable: true), WayOfIssuing = table.Column(nullable: false), Manufacturer = table.Column(nullable: false), Price = table.Column(nullable: false), Packaging = table.Column(nullable: true), PharmacyHeadId = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Medicines", x => x.Id); table.ForeignKey( name: "FK_Medicines_PharmacyHeads_PharmacyHeadId", column: x => x.PharmacyHeadId, principalTable: "PharmacyHeads", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Pharmacies", columns: table => new { Id = table.Column(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), CreatedOn = table.Column(nullable: false), DeletedOn = table.Column(nullable: true), Name = table.Column(nullable: false), Location = table.Column(nullable: false), Address = table.Column(nullable: false), WorkAllTime = table.Column(nullable: false), PheadId = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Pharmacies", x => x.Id); table.ForeignKey( name: "FK_Pharmacies_PharmacyHeads_PheadId", column: x => x.PheadId, principalTable: "PharmacyHeads", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "PharmacyHeadMedicines", columns: table => new { PheadId = table.Column(nullable: false), MedicineId = table.Column(nullable: false), Id = table.Column(nullable: false), CreatedOn = table.Column(nullable: false, defaultValueSql: "now()"), DeletedOn = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_PharmacyHeadMedicines", x => new { x.PheadId, x.MedicineId }); table.ForeignKey( name: "FK_PharmacyHeadMedicines_Medicines_MedicineId", column: x => x.MedicineId, principalTable: "Medicines", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_PharmacyHeadMedicines_PharmacyHeads_PheadId", column: x => x.PheadId, principalTable: "PharmacyHeads", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "PHRequests", columns: table => new { Id = table.Column(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), CreatedOn = table.Column(nullable: false, defaultValueSql: "now()"), DeletedOn = table.Column(nullable: true), HeadId = table.Column(nullable: false), PharmacyId = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_PHRequests", x => x.Id); table.ForeignKey( name: "FK_PHRequests_PharmacyHeads_HeadId", column: x => x.HeadId, principalTable: "PharmacyHeads", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_PHRequests_Pharmacies_PharmacyId", column: x => x.PharmacyId, principalTable: "Pharmacies", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_HealthcareWorkers_FacilityId", table: "HealthcareWorkers", column: "FacilityId"); migrationBuilder.CreateIndex( name: "IX_Medicines_PharmacyHeadId", table: "Medicines", column: "PharmacyHeadId"); migrationBuilder.CreateIndex( name: "IX_Pharmacies_PheadId", table: "Pharmacies", column: "PheadId"); migrationBuilder.CreateIndex( name: "IX_PharmacyHeadMedicines_MedicineId", table: "PharmacyHeadMedicines", column: "MedicineId"); migrationBuilder.CreateIndex( name: "IX_PHRequests_HeadId", table: "PHRequests", column: "HeadId"); migrationBuilder.CreateIndex( name: "IX_PHRequests_PharmacyId", table: "PHRequests", column: "PharmacyId"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "HealthcareWorkers"); migrationBuilder.DropTable( name: "Pandemics"); migrationBuilder.DropTable( name: "PharmacyHeadMedicines"); migrationBuilder.DropTable( name: "PHRequests"); migrationBuilder.DropTable( name: "Users"); migrationBuilder.DropTable( name: "HealthFacilities"); migrationBuilder.DropTable( name: "Medicines"); migrationBuilder.DropTable( name: "Pharmacies"); migrationBuilder.DropTable( name: "PharmacyHeads"); } } }