spfn 0.2.0-beta.16 → 0.2.0-beta.17
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 +34 -21
- 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.17";
|
|
759
759
|
}
|
|
760
760
|
function getTagFromVersion(version) {
|
|
761
761
|
const match = version.match(/-([a-z]+)\./i);
|
|
@@ -2607,12 +2607,12 @@ async function dbMigrate(options = {}) {
|
|
|
2607
2607
|
console.error(chalk16.red("\u274C DATABASE_URL not found in environment"));
|
|
2608
2608
|
process.exit(1);
|
|
2609
2609
|
}
|
|
2610
|
-
const
|
|
2611
|
-
const
|
|
2612
|
-
|
|
2613
|
-
const
|
|
2614
|
-
const
|
|
2615
|
-
|
|
2610
|
+
const { discoverFunctionMigrations: discoverFunctionMigrations2 } = await Promise.resolve().then(() => (init_function_migrations(), function_migrations_exports));
|
|
2611
|
+
const functions = discoverFunctionMigrations2(process.cwd());
|
|
2612
|
+
if (functions.length > 0) {
|
|
2613
|
+
const fnConn = postgres.default(env4.DATABASE_URL, { max: 1 });
|
|
2614
|
+
const fnDb = drizzle(fnConn);
|
|
2615
|
+
try {
|
|
2616
2616
|
console.log(chalk16.blue("\u{1F4E6} Applying function package migrations:"));
|
|
2617
2617
|
functions.forEach((func) => {
|
|
2618
2618
|
console.log(chalk16.dim(` - ${func.packageName}`));
|
|
@@ -2620,25 +2620,38 @@ async function dbMigrate(options = {}) {
|
|
|
2620
2620
|
for (const func of functions) {
|
|
2621
2621
|
console.log(chalk16.blue(`
|
|
2622
2622
|
\u{1F4E6} Running ${func.packageName} migrations...`));
|
|
2623
|
-
await migrate(
|
|
2623
|
+
await migrate(fnDb, { migrationsFolder: func.migrationsDir });
|
|
2624
2624
|
console.log(chalk16.green(` \u2713 ${func.packageName} migrations applied`));
|
|
2625
2625
|
}
|
|
2626
2626
|
console.log(chalk16.green("\u2705 Function migrations applied\n"));
|
|
2627
|
+
} finally {
|
|
2628
|
+
await fnConn.end();
|
|
2627
2629
|
}
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2630
|
+
}
|
|
2631
|
+
const projectMigrationsDir = join16(process.cwd(), "src/server/drizzle");
|
|
2632
|
+
if (existsSync18(projectMigrationsDir)) {
|
|
2633
|
+
const projConn = postgres.default(env4.DATABASE_URL, { max: 1 });
|
|
2634
|
+
const projDb = drizzle(projConn);
|
|
2635
|
+
try {
|
|
2636
|
+
const beforeCount = await projConn`
|
|
2637
|
+
SELECT count(*)::int as count FROM drizzle.__drizzle_migrations
|
|
2638
|
+
`;
|
|
2639
|
+
console.log(chalk16.blue(`\u{1F4E6} Running project migrations... (${beforeCount[0].count} already recorded)`));
|
|
2640
|
+
await migrate(projDb, { migrationsFolder: projectMigrationsDir });
|
|
2641
|
+
const afterCount = await projConn`
|
|
2642
|
+
SELECT count(*)::int as count FROM drizzle.__drizzle_migrations
|
|
2643
|
+
`;
|
|
2644
|
+
const applied = afterCount[0].count - beforeCount[0].count;
|
|
2645
|
+
if (applied > 0) {
|
|
2646
|
+
console.log(chalk16.green(`\u2705 Project migrations applied successfully (${applied} new)`));
|
|
2647
|
+
} else {
|
|
2648
|
+
console.log(chalk16.yellow(`\u26A0\uFE0F No new project migrations to apply (${afterCount[0].count} already recorded)`));
|
|
2649
|
+
}
|
|
2650
|
+
} finally {
|
|
2651
|
+
await projConn.end();
|
|
2635
2652
|
}
|
|
2636
|
-
}
|
|
2637
|
-
console.
|
|
2638
|
-
console.error(chalk16.red(error instanceof Error ? error.message : "Unknown error"));
|
|
2639
|
-
process.exit(1);
|
|
2640
|
-
} finally {
|
|
2641
|
-
await connection.end();
|
|
2653
|
+
} else {
|
|
2654
|
+
console.log(chalk16.dim("No project migrations found (src/server/drizzle)"));
|
|
2642
2655
|
}
|
|
2643
2656
|
}
|
|
2644
2657
|
|