feat: manage owner usage history records

This commit is contained in:
Wyndham ARR
2026-08-03 16:43:27 +08:00
parent 393b841023
commit 84443d5dba
17 changed files with 798 additions and 102 deletions

View File

@@ -17,6 +17,9 @@ const MIGRATION_CHECKSUM =
const MIGRATION_V2 = "002_legacy_import_and_bookings";
const MIGRATION_V2_CHECKSUM =
"cfc38024984c883490cb46ab8ab1fca2e72c67f10dc3a43c179b12a8e6f2405b";
const MIGRATION_V3 = "003_delete_usage_record";
const MIGRATION_V3_CHECKSUM =
"9110464c03ed18385fbc2da1d4369715fcbf83148d7a0f2550c25710a5f54148";
const expectedColumns = {
bookings: [
@@ -334,11 +337,12 @@ try {
calculate_multiplier: { volatility: "s" },
create_usage_record: { volatility: "v" },
create_usage_record_v2: { volatility: "v" },
delete_usage_record: { volatility: "v" },
ensure_booking_for_usage: { volatility: "v" },
open_entitlement_period: { volatility: "v" }
};
const functionsValid =
functionResult.rowCount === 5
functionResult.rowCount === 6
&& functionResult.rows.every(row =>
expectedFunctions[row.function_name]?.volatility === row.volatility
&& row.security_definer === false
@@ -371,13 +375,16 @@ try {
&& businessCounts.usage_record_count === 157
&& businessCounts.ledger_count === 547,
migrationVerified:
migrationResult.rowCount === 2
migrationResult.rowCount === 3
&& migrationResult.rows.some(row =>
row.version === MIGRATION_VERSION && row.checksum === MIGRATION_CHECKSUM
)
&& migrationResult.rows.some(row =>
row.version === MIGRATION_V2 && row.checksum === MIGRATION_V2_CHECKSUM
)
&& migrationResult.rows.some(row =>
row.version === MIGRATION_V3 && row.checksum === MIGRATION_V3_CHECKSUM
)
};
process.stdout.write(`${JSON.stringify({