65 lines
2.8 KiB
C#
65 lines
2.8 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace VigilCareClinicalAPI.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddClinicalAuditLogs : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "clinical_audit_logs",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<Guid>(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
|
|
action = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
|
entity_type = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
entity_id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
user_id = table.Column<Guid>(type: "uuid", nullable: true),
|
|
user_display_name = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: true),
|
|
previous_value_json = table.Column<string>(type: "jsonb", nullable: true),
|
|
new_value_json = table.Column<string>(type: "jsonb", nullable: true),
|
|
reason = table.Column<string>(type: "text", nullable: true),
|
|
ip_address = table.Column<string>(type: "character varying(45)", maxLength: 45, nullable: true),
|
|
correlation_id = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
|
|
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "NOW()")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_clinical_audit_logs", x => x.id);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_clinical_audit_logs_created_at",
|
|
table: "clinical_audit_logs",
|
|
column: "created_at");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_clinical_audit_logs_entity_id",
|
|
table: "clinical_audit_logs",
|
|
column: "entity_id");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_clinical_audit_logs_entity_type",
|
|
table: "clinical_audit_logs",
|
|
column: "entity_type");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_clinical_audit_logs_user_id",
|
|
table: "clinical_audit_logs",
|
|
column: "user_id");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "clinical_audit_logs");
|
|
}
|
|
}
|
|
}
|