arkormx 1.3.3 → 2.0.0-next.0

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/README.md CHANGED
@@ -23,11 +23,20 @@ Arkormˣ is a framework-agnostic ORM designed to run anywhere Node.js runs. It b
23
23
 
24
24
  ### Installation
25
25
 
26
+ Stable release:
27
+
26
28
  ```sh
27
29
  pnpm add arkormx @prisma/client
28
30
  pnpm add -D prisma
29
31
  ```
30
32
 
33
+ Preview release (`next`):
34
+
35
+ ```sh
36
+ pnpm add arkormx@next @prisma/client
37
+ pnpm add -D prisma
38
+ ```
39
+
31
40
  ### Configuration
32
41
 
33
42
  Create `arkormx.config.js` in your project root:
package/dist/cli.mjs CHANGED
@@ -2520,10 +2520,24 @@ const markMigrationRun = (state, run) => {
2520
2520
  const getLastMigrationRun = (state) => {
2521
2521
  const runs = state.runs ?? [];
2522
2522
  if (runs.length === 0) return void 0;
2523
- return [...runs].sort((left, right) => right.appliedAt.localeCompare(left.appliedAt))[0];
2523
+ return runs.map((run, index) => ({
2524
+ run,
2525
+ index
2526
+ })).sort((left, right) => {
2527
+ const appliedAtOrder = right.run.appliedAt.localeCompare(left.run.appliedAt);
2528
+ if (appliedAtOrder !== 0) return appliedAtOrder;
2529
+ return right.index - left.index;
2530
+ })[0]?.run;
2524
2531
  };
2525
2532
  const getLatestAppliedMigrations = (state, steps) => {
2526
- return [...state.migrations].sort((left, right) => right.appliedAt.localeCompare(left.appliedAt)).slice(0, Math.max(0, steps));
2533
+ return state.migrations.map((migration, index) => ({
2534
+ migration,
2535
+ index
2536
+ })).sort((left, right) => {
2537
+ const appliedAtOrder = right.migration.appliedAt.localeCompare(left.migration.appliedAt);
2538
+ if (appliedAtOrder !== 0) return appliedAtOrder;
2539
+ return right.index - left.index;
2540
+ }).slice(0, Math.max(0, steps)).map((entry) => entry.migration);
2527
2541
  };
2528
2542
 
2529
2543
  //#endregion