@crvouga/mockingbird-service-fcm 1.3.0 → 2.0.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/dist/admin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  fcmCredential
3
- } from "./chunk-QMKS4S45.js";
3
+ } from "./chunk-JBKKCBA7.js";
4
4
 
5
5
  // src/admin.ts
6
6
  import { Agent, createServer } from "node:https";
@@ -53,8 +53,38 @@ var CORE_MIGRATIONS = [
53
53
  `
54
54
  }
55
55
  ];
56
+ var LEGACY_TABLES = [
57
+ ["emulates_records", "mockingbird_records"],
58
+ ["emulators_records", "mockingbird_records"],
59
+ ["emulates_sequences", "mockingbird_sequences"],
60
+ ["emulators_sequences", "mockingbird_sequences"]
61
+ ];
62
+ var LEGACY_INDEXES = [
63
+ ["emulates_records_seq", "mockingbird_records_seq"],
64
+ ["emulators_records_seq", "mockingbird_records_seq"]
65
+ ];
66
+ var namesOf = (sqlite, type) => new Set(sqlite.prepare("SELECT name FROM sqlite_master WHERE type = ?").all(type).map((row) => row.name));
56
67
  var migrateCore = (sqlite) => {
57
68
  migrate(sqlite, CORE_MIGRATIONS);
69
+ const tables = namesOf(sqlite, "table");
70
+ const indexes = namesOf(sqlite, "index");
71
+ sqlite.transaction(() => {
72
+ for (const [from, to] of LEGACY_TABLES) {
73
+ if (!tables.has(from) || tables.has(to))
74
+ continue;
75
+ sqlite.exec(`ALTER TABLE ${from} RENAME TO ${to}`);
76
+ tables.delete(from);
77
+ tables.add(to);
78
+ }
79
+ for (const [from, to] of LEGACY_INDEXES) {
80
+ if (!indexes.has(from) || indexes.has(to))
81
+ continue;
82
+ sqlite.exec(`DROP INDEX ${from}`);
83
+ sqlite.exec(`CREATE INDEX ${to} ON mockingbird_records (namespace, collection, seq)`);
84
+ indexes.delete(from);
85
+ indexes.add(to);
86
+ }
87
+ });
58
88
  };
59
89
  var clearNamespace = (sqlite, namespace) => {
60
90
  sqlite.transaction(() => {
@@ -2354,7 +2384,7 @@ var stateAdminRoutes = (routes) => {
2354
2384
  };
2355
2385
 
2356
2386
  // ../core/dist/version.js
2357
- var PACKAGE_VERSION = true ? "1.3.0" : UNRELEASED_VERSION;
2387
+ var PACKAGE_VERSION = true ? "2.0.0" : UNRELEASED_VERSION;
2358
2388
 
2359
2389
  // ../core/dist/webhooks.js
2360
2390
  var json4 = (status, body) => new Response(JSON.stringify(body), {
@@ -4039,4 +4069,4 @@ export {
4039
4069
  fcmCredential,
4040
4070
  FcmAPI
4041
4071
  };
4042
- //# sourceMappingURL=chunk-QMKS4S45.js.map
4072
+ //# sourceMappingURL=chunk-JBKKCBA7.js.map