using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace VigilCareClinicalAPI.Migrations { /// public partial class AddSofaScores : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "sofa_scores", columns: table => new { id = table.Column(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"), encounter_id = table.Column(type: "uuid", nullable: false), patient_id = table.Column(type: "uuid", nullable: false), total_score = table.Column(type: "integer", nullable: false), respiratory_score = table.Column(type: "integer", nullable: false), coagulation_score = table.Column(type: "integer", nullable: false), liver_score = table.Column(type: "integer", nullable: false), cardiovascular_score = table.Column(type: "integer", nullable: false), cns_score = table.Column(type: "integer", nullable: false), renal_score = table.Column(type: "integer", nullable: false), is_baseline = table.Column(type: "boolean", nullable: false), delta_from_baseline = table.Column(type: "integer", nullable: true), staleness_flags = table.Column(type: "jsonb", nullable: true), calculated_at = table.Column(type: "timestamp with time zone", nullable: false), created_at = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_sofa_scores", x => x.id); table.ForeignKey( name: "FK_sofa_scores_encounters_encounter_id", column: x => x.encounter_id, principalTable: "encounters", principalColumn: "id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "idx_sofa_scores_baseline", table: "sofa_scores", column: "encounter_id", filter: "is_baseline = true"); migrationBuilder.CreateIndex( name: "IX_sofa_scores_encounter_id_calculated_at", table: "sofa_scores", columns: new[] { "encounter_id", "calculated_at" }); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "sofa_scores"); } } }