spfn 0.2.0-beta.40 → 0.2.0-beta.42
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/dist/index.js +13 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -755,7 +755,7 @@ var init_deployment_config = __esm({
|
|
|
755
755
|
|
|
756
756
|
// src/utils/version.ts
|
|
757
757
|
function getCliVersion() {
|
|
758
|
-
return "0.2.0-beta.
|
|
758
|
+
return "0.2.0-beta.42";
|
|
759
759
|
}
|
|
760
760
|
function getTagFromVersion(version) {
|
|
761
761
|
const match = version.match(/-([a-z]+)\./i);
|
|
@@ -2451,7 +2451,7 @@ async function dbPush(options = {}) {
|
|
|
2451
2451
|
schemaFilter
|
|
2452
2452
|
);
|
|
2453
2453
|
const managedSchemaSet = new Set(schemaFilter);
|
|
2454
|
-
const
|
|
2454
|
+
const patched = statementsToExecute.filter((s) => {
|
|
2455
2455
|
const dropMatch = s.match(/^\s*DROP\s+SCHEMA\s+"?([^"\s;]+)"?/i);
|
|
2456
2456
|
if (dropMatch && managedSchemaSet.has(dropMatch[1])) {
|
|
2457
2457
|
console.log(chalk13.dim(` [skip] DROP SCHEMA "${dropMatch[1]}" \u2014 managed schema, ignoring`));
|
|
@@ -2461,7 +2461,10 @@ async function dbPush(options = {}) {
|
|
|
2461
2461
|
}).map(
|
|
2462
2462
|
(s) => s.replace(/^CREATE SCHEMA(?!\s+IF\s+NOT\s+EXISTS)/i, "CREATE SCHEMA IF NOT EXISTS")
|
|
2463
2463
|
);
|
|
2464
|
-
|
|
2464
|
+
const ensureSchemas = schemaFilter.filter((s) => s !== "public").map((s) => `CREATE SCHEMA IF NOT EXISTS "${s}";
|
|
2465
|
+
`);
|
|
2466
|
+
const statements = [...ensureSchemas, ...patched];
|
|
2467
|
+
if (patched.length === 0) {
|
|
2465
2468
|
console.log(chalk13.green("\u2705 No changes detected \u2014 database is up to date\n"));
|
|
2466
2469
|
await applyFunctionMigrations();
|
|
2467
2470
|
return;
|
|
@@ -2484,13 +2487,14 @@ async function dbPush(options = {}) {
|
|
|
2484
2487
|
}
|
|
2485
2488
|
displayApplySummary(statements.length, 0);
|
|
2486
2489
|
} else {
|
|
2487
|
-
const
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2490
|
+
const destructiveSet = new Set(result.destructive.map((s) => s.sql));
|
|
2491
|
+
const nonDestructive = statements.filter((s) => !destructiveSet.has(s));
|
|
2492
|
+
if (nonDestructive.length > 0) {
|
|
2493
|
+
for (const stmt of nonDestructive) {
|
|
2494
|
+
await db.execute(sql.raw(stmt));
|
|
2491
2495
|
}
|
|
2492
2496
|
console.log(chalk13.green(`
|
|
2493
|
-
\u2705 Applied ${
|
|
2497
|
+
\u2705 Applied ${nonDestructive.length} safe statement(s)`));
|
|
2494
2498
|
}
|
|
2495
2499
|
console.log(chalk13.red(`
|
|
2496
2500
|
\u274C ${result.destructive.length} destructive change(s) require confirmation:`));
|
|
@@ -2510,7 +2514,7 @@ async function dbPush(options = {}) {
|
|
|
2510
2514
|
}
|
|
2511
2515
|
displayApplySummary(statements.length, 0);
|
|
2512
2516
|
} else {
|
|
2513
|
-
displayApplySummary(
|
|
2517
|
+
displayApplySummary(nonDestructive.length, result.destructive.length);
|
|
2514
2518
|
console.log(chalk13.dim("Tip: Use --force to apply all changes without prompting.\n"));
|
|
2515
2519
|
}
|
|
2516
2520
|
}
|