Implement API security baseline (sys_user, JWT, audit fields, transactions, unique constraints) and Web real login with 401 handling. Document setup and development workflows in root, WmsLite.Api, and WmsLite.Web README files. Co-authored-by: Cursor <cursoragent@cursor.com>
70 lines
1.7 KiB
C#
70 lines
1.7 KiB
C#
using FluentMigrator;
|
|
|
|
namespace WmsLite.Api.Database.Migrations;
|
|
|
|
[Migration(3, "Make audit columns nullable for legacy DBs")]
|
|
public class MakeAuditColumnsNullable0003 : Migration
|
|
{
|
|
private static readonly string[] BaseEntityTables =
|
|
{
|
|
"warehouse",
|
|
"zone",
|
|
"location",
|
|
"material",
|
|
"container",
|
|
"inventory",
|
|
"inventory_transaction",
|
|
"sys_template",
|
|
"inbound_order",
|
|
"inbound_order_line",
|
|
"outbound_order",
|
|
"outbound_order_line",
|
|
"transfer_order",
|
|
"transfer_order_line",
|
|
"stocktake_order",
|
|
"stocktake_order_line"
|
|
};
|
|
|
|
private static readonly string[] AuditColumns =
|
|
{
|
|
"create_time",
|
|
"create_by",
|
|
"update_by",
|
|
"update_time",
|
|
"delete_time",
|
|
"delete_by"
|
|
};
|
|
|
|
public override void Up()
|
|
{
|
|
foreach (var table in BaseEntityTables)
|
|
{
|
|
if (!Schema.Table(table).Exists())
|
|
{
|
|
continue;
|
|
}
|
|
|
|
foreach (var column in AuditColumns)
|
|
{
|
|
if (!Schema.Table(table).Column(column).Exists())
|
|
{
|
|
continue;
|
|
}
|
|
|
|
Execute.Sql($"ALTER TABLE {table} ALTER COLUMN {column} DROP NOT NULL;");
|
|
}
|
|
}
|
|
|
|
if (Schema.Table("http_access_log").Exists()
|
|
&& Schema.Table("http_access_log").Column("create_time").Exists())
|
|
{
|
|
Execute.Sql("ALTER TABLE http_access_log ALTER COLUMN create_time DROP NOT NULL;");
|
|
}
|
|
}
|
|
|
|
public override void Down()
|
|
{
|
|
// Irreversible: rows may already have NULL audit values after Up().
|
|
}
|
|
}
|