Files
vigilcare-clinical/VigilCareClinicalAPI/Migrations/20260622143154_WidenPhiEncryptedColumns.cs
T

111 lines
3.7 KiB
C#

using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace VigilCareClinicalAPI.Migrations
{
/// <inheritdoc />
public partial class WidenPhiEncryptedColumns : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "last_name",
table: "patients",
type: "text",
maxLength: 100,
nullable: false,
oldClrType: typeof(string),
oldType: "character varying(100)",
oldMaxLength: 100);
migrationBuilder.AlterColumn<string>(
name: "first_name",
table: "patients",
type: "text",
maxLength: 100,
nullable: false,
oldClrType: typeof(string),
oldType: "character varying(100)",
oldMaxLength: 100);
migrationBuilder.AlterColumn<string>(
name: "emergency_contact_phone",
table: "patients",
type: "text",
maxLength: 20,
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(20)",
oldMaxLength: 20,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "emergency_contact_name",
table: "patients",
type: "text",
maxLength: 200,
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(200)",
oldMaxLength: 200,
oldNullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(
"""
UPDATE patients SET last_name = LEFT(last_name, 100);
UPDATE patients SET first_name = LEFT(first_name, 100);
UPDATE patients SET emergency_contact_phone = LEFT(emergency_contact_phone, 20);
UPDATE patients SET emergency_contact_name = LEFT(emergency_contact_name, 200);
""");
migrationBuilder.AlterColumn<string>(
name: "last_name",
table: "patients",
type: "character varying(100)",
maxLength: 100,
nullable: false,
oldClrType: typeof(string),
oldType: "text",
oldMaxLength: 100);
migrationBuilder.AlterColumn<string>(
name: "first_name",
table: "patients",
type: "character varying(100)",
maxLength: 100,
nullable: false,
oldClrType: typeof(string),
oldType: "text",
oldMaxLength: 100);
migrationBuilder.AlterColumn<string>(
name: "emergency_contact_phone",
table: "patients",
type: "character varying(20)",
maxLength: 20,
nullable: true,
oldClrType: typeof(string),
oldType: "text",
oldMaxLength: 20,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "emergency_contact_name",
table: "patients",
type: "character varying(200)",
maxLength: 200,
nullable: true,
oldClrType: typeof(string),
oldType: "text",
oldMaxLength: 200,
oldNullable: true);
}
}
}