cynx-lib 1.3.116 → 1.3.117

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cynx-lib",
3
- "version": "1.3.116",
3
+ "version": "1.3.117",
4
4
  "type": "module",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",
@@ -338,12 +338,6 @@ async function sync_db(options = {}) {
338
338
  let executedDoBlocks = 0;
339
339
  const parsed = parseSchema(schemaSql);
340
340
  const safeDdlOpts = { maxRetries, retryDelayMs, logger };
341
- for (const doSql of parsed.doBlocks) {
342
- if (!dryRun) {
343
- await runSafeDdl(queryFn, doSql, "schema do-block", safeDdlOpts);
344
- }
345
- executedDoBlocks++;
346
- }
347
341
  for (const table of parsed.tables) {
348
342
  if (!existingTables.has(table.name)) {
349
343
  if (!dryRun) {
@@ -477,6 +471,12 @@ async function sync_db(options = {}) {
477
471
  }
478
472
  }
479
473
  }
474
+ for (const doSql of parsed.doBlocks) {
475
+ if (!dryRun) {
476
+ await runSafeDdl(queryFn, doSql, "schema do-block", safeDdlOpts);
477
+ }
478
+ executedDoBlocks++;
479
+ }
480
480
  const durationMs = Date.now() - startTime;
481
481
  const summaryParts = [];
482
482
  if (createdTables.length > 0) summaryParts.push(`${createdTables.length} tables created`);
package/utils/utils/db.js CHANGED
@@ -436,14 +436,6 @@ export async function sync_db(options = {}) {
436
436
  const parsed = parseSchema(schemaSql);
437
437
  const safeDdlOpts = { maxRetries, retryDelayMs, logger };
438
438
 
439
- // ── Step 0: Execute Custom DO Blocks (Data migrations / fixes / seed updates)
440
- for (const doSql of parsed.doBlocks) {
441
- if (!dryRun) {
442
- await runSafeDdl(queryFn, doSql, 'schema do-block', safeDdlOpts);
443
- }
444
- executedDoBlocks++;
445
- }
446
-
447
439
  // ── Step A: Ensure Tables ─────────────────────────────────────────────────
448
440
  for (const table of parsed.tables) {
449
441
  if (!existingTables.has(table.name)) {
@@ -591,6 +583,14 @@ export async function sync_db(options = {}) {
591
583
  }
592
584
  }
593
585
 
586
+ // ── Step F: Execute Custom DO Blocks (Data migrations / fixes / seed updates)
587
+ for (const doSql of parsed.doBlocks) {
588
+ if (!dryRun) {
589
+ await runSafeDdl(queryFn, doSql, 'schema do-block', safeDdlOpts);
590
+ }
591
+ executedDoBlocks++;
592
+ }
593
+
594
594
  const durationMs = Date.now() - startTime;
595
595
  const summaryParts = [];
596
596
  if (createdTables.length > 0) summaryParts.push(`${createdTables.length} tables created`);