@getstrata/core 2.2.17 → 2.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# @getstrata/core changelog
|
|
2
2
|
|
|
3
|
+
## 2.2.18
|
|
4
|
+
|
|
5
|
+
Add optional typed guardMigrationRollback for application-owned rollback history predicates; skip history reads only during explicit development fresh resets, propagate predicate failures, and reuse the contract for encryption-checkpoint archival protection. Document guard placement and unchanged reset/rollback safety; cover type, runner and real SQLite history regressions.
|
|
6
|
+
|
|
3
7
|
## 2.2.17
|
|
4
8
|
|
|
5
9
|
Add explicit development-only migration reset context while preserving guarded rollback and encryption archival; align generated fresh entries and reject production/staging or unsupported reset arguments before provisioning. Replace CSP-blocked error-page JavaScript navigation with safe same-origin links, and correct ambiguous Postgres/SQLite foreign-key messages without changing their HTTP status.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MigrationDownContext } from "./types.ts";
|
|
2
|
+
interface MigrationRollbackGuard {
|
|
3
|
+
/** Application-owned history check. It is not evaluated during an explicit fresh reset. */
|
|
4
|
+
hasHistory(): boolean | Promise<boolean>;
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
/** Await before destructive DDL. Predicate failures propagate; ordinary rollback remains guarded. */
|
|
8
|
+
declare function guardMigrationRollback(context: MigrationDownContext | undefined, guard: MigrationRollbackGuard): Promise<void>;
|
|
9
|
+
export type { MigrationRollbackGuard };
|
|
10
|
+
export { guardMigrationRollback };
|
|
@@ -23,4 +23,5 @@ declare function freshDatabase(db: MigrationDatabase, migrations: Migration[], o
|
|
|
23
23
|
destructive?: boolean;
|
|
24
24
|
}): Promise<void>;
|
|
25
25
|
export { withMigrationLock } from "./advisoryLock.ts";
|
|
26
|
+
export { guardMigrationRollback, type MigrationRollbackGuard } from "./rollbackGuard.ts";
|
|
26
27
|
export { ensureMigrationsTable, freshDatabase, getAppliedMigrations, getMigrationStatus, loadMigrationsFromDirectory, migrateDatabase, rollbackDatabase, runPendingMigrations, };
|
|
@@ -265,6 +265,13 @@ async function withMigrationLock(db, callback, lockKey = MIGRATION_LOCK_KEY) {
|
|
|
265
265
|
await db.unsafe("SELECT pg_advisory_unlock($1)", [lockKey]);
|
|
266
266
|
}
|
|
267
267
|
}
|
|
268
|
+
// ../../src/core/database/migrations/rollbackGuard.ts
|
|
269
|
+
async function guardMigrationRollback(context, guard) {
|
|
270
|
+
if (context?.operation === "fresh")
|
|
271
|
+
return;
|
|
272
|
+
if (await guard.hasHistory())
|
|
273
|
+
throw new Error(guard.message);
|
|
274
|
+
}
|
|
268
275
|
|
|
269
276
|
// ../../src/core/database/migrations/runner.ts
|
|
270
277
|
var MIGRATIONS_TABLE = "framework_migrations";
|
|
@@ -398,6 +405,7 @@ export {
|
|
|
398
405
|
freshDatabase,
|
|
399
406
|
getAppliedMigrations,
|
|
400
407
|
getMigrationStatus,
|
|
408
|
+
guardMigrationRollback,
|
|
401
409
|
loadMigrationsFromDirectory,
|
|
402
410
|
migrateDatabase,
|
|
403
411
|
rollbackDatabase,
|
package/dist/index.js
CHANGED
|
@@ -6369,6 +6369,16 @@ var baseRepository_default = BaseRepository;
|
|
|
6369
6369
|
|
|
6370
6370
|
// ../../src/core/crypto/fieldEncryptionRotation.ts
|
|
6371
6371
|
init_boundConnection();
|
|
6372
|
+
|
|
6373
|
+
// ../../src/core/database/migrations/rollbackGuard.ts
|
|
6374
|
+
async function guardMigrationRollback(context, guard) {
|
|
6375
|
+
if (context?.operation === "fresh")
|
|
6376
|
+
return;
|
|
6377
|
+
if (await guard.hasHistory())
|
|
6378
|
+
throw new Error(guard.message);
|
|
6379
|
+
}
|
|
6380
|
+
|
|
6381
|
+
// ../../src/core/crypto/fieldEncryptionRotation.ts
|
|
6372
6382
|
init_repositoryConnection();
|
|
6373
6383
|
|
|
6374
6384
|
// ../../src/core/database/schema/columnDefinition.ts
|
|
@@ -7165,13 +7175,13 @@ function createFieldEncryptionRotationMigration(name, driver, options = {}) {
|
|
|
7165
7175
|
await db.unsafe(enableTenantRlsSql(checkpointTable.name));
|
|
7166
7176
|
},
|
|
7167
7177
|
async down(db, context) {
|
|
7168
|
-
|
|
7169
|
-
|
|
7170
|
-
|
|
7171
|
-
|
|
7172
|
-
|
|
7173
|
-
|
|
7174
|
-
|
|
7178
|
+
await guardMigrationRollback(context, {
|
|
7179
|
+
hasHistory: () => true,
|
|
7180
|
+
message: "Encryption rotation checkpoints require explicit administrative archival."
|
|
7181
|
+
});
|
|
7182
|
+
await Schema.run(db, driver, (schema) => {
|
|
7183
|
+
schema.drop(checkpointTable.name);
|
|
7184
|
+
});
|
|
7175
7185
|
}
|
|
7176
7186
|
};
|
|
7177
7187
|
}
|