feat: manage owner usage history records
This commit is contained in:
@@ -26,12 +26,24 @@ const legacyDownPath = path.join(
|
||||
"migrations",
|
||||
"002_legacy_import_and_bookings.down.sql"
|
||||
);
|
||||
const deleteUpPath = path.join(
|
||||
backendDirectory,
|
||||
"migrations",
|
||||
"003_delete_usage_record.up.sql"
|
||||
);
|
||||
const deleteDownPath = path.join(
|
||||
backendDirectory,
|
||||
"migrations",
|
||||
"003_delete_usage_record.down.sql"
|
||||
);
|
||||
|
||||
const [upSql, downSql, legacyUpSql, legacyDownSql] = await Promise.all([
|
||||
const [upSql, downSql, legacyUpSql, legacyDownSql, deleteUpSql, deleteDownSql] = await Promise.all([
|
||||
readFile(upPath, "utf8"),
|
||||
readFile(downPath, "utf8"),
|
||||
readFile(legacyUpPath, "utf8"),
|
||||
readFile(legacyDownPath, "utf8")
|
||||
readFile(legacyDownPath, "utf8"),
|
||||
readFile(deleteUpPath, "utf8"),
|
||||
readFile(deleteDownPath, "utf8")
|
||||
]);
|
||||
|
||||
const checks = [];
|
||||
@@ -166,6 +178,21 @@ record(
|
||||
&& /^DROP FUNCTION condon\.create_usage_record_v2/gm.test(legacyDownSql)
|
||||
&& /^DROP INDEX condon\.usage_records_source_location_key;$/gm.test(legacyDownSql)
|
||||
);
|
||||
record(
|
||||
"delete migration is an internal transactional function",
|
||||
/^CREATE FUNCTION condon\.delete_usage_record\(\s*p_usage_record_id uuid\s*\)/m.test(deleteUpSql)
|
||||
&& /^RETURNS void$/m.test(deleteUpSql)
|
||||
&& /^SECURITY INVOKER$/m.test(deleteUpSql)
|
||||
&& deleteUpSql.includes("FOR UPDATE")
|
||||
&& deleteUpSql.includes("DELETE FROM condon.entitlement_ledger")
|
||||
&& deleteUpSql.includes("UPDATE condon.entitlement_periods")
|
||||
&& /^REVOKE ALL ON FUNCTION condon\.delete_usage_record\(uuid\) FROM PUBLIC;$/m.test(deleteUpSql)
|
||||
);
|
||||
record(
|
||||
"delete migration down reverses its function",
|
||||
/^DROP FUNCTION condon\.delete_usage_record\(uuid\);$/m.test(deleteDownSql)
|
||||
&& !/\bCASCADE\b/i.test(deleteDownSql)
|
||||
);
|
||||
|
||||
for (const check of checks) {
|
||||
process.stdout.write(
|
||||
|
||||
Reference in New Issue
Block a user