@powersync/service-module-postgres-storage 0.13.2 → 0.13.3
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/CHANGELOG.md +15 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/migrations/scripts/1684951997326-init.js +24 -100
- package/dist/migrations/scripts/1684951997326-init.js.map +1 -1
- package/dist/migrations/scripts/1749024804042-snapshot-progress.js +12 -88
- package/dist/migrations/scripts/1749024804042-snapshot-progress.js.map +1 -1
- package/dist/migrations/scripts/1756282360128-connection-reporting.js +12 -88
- package/dist/migrations/scripts/1756282360128-connection-reporting.js.map +1 -1
- package/dist/migrations/scripts/1771232439485-storage-version.js +14 -90
- package/dist/migrations/scripts/1771232439485-storage-version.js.map +1 -1
- package/dist/migrations/scripts/1771491856000-sync-plan.js +6 -82
- package/dist/migrations/scripts/1771491856000-sync-plan.js.map +1 -1
- package/dist/storage/PostgresSyncRulesStorage.js +4 -68
- package/dist/storage/PostgresSyncRulesStorage.js.map +1 -1
- package/dist/utils/test-utils.js +33 -109
- package/dist/utils/test-utils.js.map +1 -1
- package/package.json +8 -9
|
@@ -1,78 +1,24 @@
|
|
|
1
|
-
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
-
if (value !== null && value !== void 0) {
|
|
3
|
-
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
-
var dispose, inner;
|
|
5
|
-
if (async) {
|
|
6
|
-
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
-
dispose = value[Symbol.asyncDispose];
|
|
8
|
-
}
|
|
9
|
-
if (dispose === void 0) {
|
|
10
|
-
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
-
dispose = value[Symbol.dispose];
|
|
12
|
-
if (async) inner = dispose;
|
|
13
|
-
}
|
|
14
|
-
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
-
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
-
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
-
}
|
|
18
|
-
else if (async) {
|
|
19
|
-
env.stack.push({ async: true });
|
|
20
|
-
}
|
|
21
|
-
return value;
|
|
22
|
-
};
|
|
23
|
-
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
-
return function (env) {
|
|
25
|
-
function fail(e) {
|
|
26
|
-
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
-
env.hasError = true;
|
|
28
|
-
}
|
|
29
|
-
var r, s = 0;
|
|
30
|
-
function next() {
|
|
31
|
-
while (r = env.stack.pop()) {
|
|
32
|
-
try {
|
|
33
|
-
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
-
if (r.dispose) {
|
|
35
|
-
var result = r.dispose.call(r.value);
|
|
36
|
-
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
-
}
|
|
38
|
-
else s |= 1;
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
fail(e);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
-
if (env.hasError) throw env.error;
|
|
46
|
-
}
|
|
47
|
-
return next();
|
|
48
|
-
};
|
|
49
|
-
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
-
var e = new Error(message);
|
|
51
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
-
});
|
|
53
1
|
import { dropTables } from '../../utils/db.js';
|
|
54
2
|
import { openMigrationDB } from '../migration-utils.js';
|
|
55
3
|
export const up = async (context) => {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
await client.transaction(async (db) => {
|
|
65
|
-
await db.sql `
|
|
4
|
+
const { service_context: { configuration } } = context;
|
|
5
|
+
await using client = openMigrationDB(configuration.storage);
|
|
6
|
+
/**
|
|
7
|
+
* Request an explicit connection which will automatically set the search
|
|
8
|
+
* path to the powersync schema
|
|
9
|
+
*/
|
|
10
|
+
await client.transaction(async (db) => {
|
|
11
|
+
await db.sql `
|
|
66
12
|
CREATE SEQUENCE op_id_sequence AS int8 START
|
|
67
13
|
WITH
|
|
68
14
|
1
|
|
69
15
|
`.execute();
|
|
70
|
-
|
|
16
|
+
await db.sql `
|
|
71
17
|
CREATE SEQUENCE sync_rules_id_sequence AS int START
|
|
72
18
|
WITH
|
|
73
19
|
1
|
|
74
20
|
`.execute();
|
|
75
|
-
|
|
21
|
+
await db.sql `
|
|
76
22
|
CREATE TABLE bucket_data (
|
|
77
23
|
group_id integer NOT NULL,
|
|
78
24
|
bucket_name TEXT NOT NULL,
|
|
@@ -88,8 +34,8 @@ export const up = async (context) => {
|
|
|
88
34
|
target_op bigint
|
|
89
35
|
)
|
|
90
36
|
`.execute();
|
|
91
|
-
|
|
92
|
-
|
|
37
|
+
await db.sql `CREATE TABLE instance (id TEXT PRIMARY KEY) `.execute();
|
|
38
|
+
await db.sql `
|
|
93
39
|
CREATE TABLE sync_rules (
|
|
94
40
|
id INTEGER PRIMARY KEY,
|
|
95
41
|
state TEXT NOT NULL,
|
|
@@ -105,7 +51,7 @@ export const up = async (context) => {
|
|
|
105
51
|
content TEXT NOT NULL
|
|
106
52
|
);
|
|
107
53
|
`.execute();
|
|
108
|
-
|
|
54
|
+
await db.sql `
|
|
109
55
|
CREATE TABLE bucket_parameters (
|
|
110
56
|
id BIGINT DEFAULT nextval('op_id_sequence') PRIMARY KEY,
|
|
111
57
|
group_id integer NOT NULL,
|
|
@@ -117,13 +63,13 @@ export const up = async (context) => {
|
|
|
117
63
|
bucket_parameters text NOT NULL
|
|
118
64
|
);
|
|
119
65
|
`.execute();
|
|
120
|
-
|
|
66
|
+
await db.sql `
|
|
121
67
|
CREATE INDEX bucket_parameters_lookup_index ON bucket_parameters (group_id ASC, lookup ASC, id DESC)
|
|
122
68
|
`.execute();
|
|
123
|
-
|
|
69
|
+
await db.sql `
|
|
124
70
|
CREATE INDEX bucket_parameters_source_index ON bucket_parameters (group_id, source_table, source_key)
|
|
125
71
|
`.execute();
|
|
126
|
-
|
|
72
|
+
await db.sql `
|
|
127
73
|
CREATE TABLE current_data (
|
|
128
74
|
group_id integer NOT NULL,
|
|
129
75
|
source_table TEXT NOT NULL,
|
|
@@ -134,7 +80,7 @@ export const up = async (context) => {
|
|
|
134
80
|
lookups bytea[] NOT NULL
|
|
135
81
|
);
|
|
136
82
|
`.execute();
|
|
137
|
-
|
|
83
|
+
await db.sql `
|
|
138
84
|
CREATE TABLE source_tables (
|
|
139
85
|
--- This is currently a TEXT column to make the (shared) tests easier to integrate
|
|
140
86
|
--- we could improve this if necessary
|
|
@@ -148,15 +94,15 @@ export const up = async (context) => {
|
|
|
148
94
|
snapshot_done BOOLEAN NOT NULL DEFAULT FALSE
|
|
149
95
|
)
|
|
150
96
|
`.execute();
|
|
151
|
-
|
|
152
|
-
|
|
97
|
+
await db.sql `CREATE INDEX source_table_lookup ON source_tables (group_id, table_name)`.execute();
|
|
98
|
+
await db.sql `
|
|
153
99
|
CREATE TABLE write_checkpoints (
|
|
154
100
|
user_id text PRIMARY KEY,
|
|
155
101
|
lsns jsonb NOT NULL,
|
|
156
102
|
write_checkpoint BIGINT NOT NULL
|
|
157
103
|
)
|
|
158
104
|
`.execute();
|
|
159
|
-
|
|
105
|
+
await db.sql `
|
|
160
106
|
CREATE TABLE custom_write_checkpoints (
|
|
161
107
|
user_id text NOT NULL,
|
|
162
108
|
write_checkpoint BIGINT NOT NULL,
|
|
@@ -164,33 +110,11 @@ export const up = async (context) => {
|
|
|
164
110
|
CONSTRAINT unique_user_sync PRIMARY KEY (user_id, sync_rules_id)
|
|
165
111
|
);
|
|
166
112
|
`.execute();
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
catch (e_1) {
|
|
170
|
-
env_1.error = e_1;
|
|
171
|
-
env_1.hasError = true;
|
|
172
|
-
}
|
|
173
|
-
finally {
|
|
174
|
-
const result_1 = __disposeResources(env_1);
|
|
175
|
-
if (result_1)
|
|
176
|
-
await result_1;
|
|
177
|
-
}
|
|
113
|
+
});
|
|
178
114
|
};
|
|
179
115
|
export const down = async (context) => {
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
const client = __addDisposableResource(env_2, openMigrationDB(configuration.storage), true);
|
|
184
|
-
await dropTables(client);
|
|
185
|
-
}
|
|
186
|
-
catch (e_2) {
|
|
187
|
-
env_2.error = e_2;
|
|
188
|
-
env_2.hasError = true;
|
|
189
|
-
}
|
|
190
|
-
finally {
|
|
191
|
-
const result_2 = __disposeResources(env_2);
|
|
192
|
-
if (result_2)
|
|
193
|
-
await result_2;
|
|
194
|
-
}
|
|
116
|
+
const { service_context: { configuration } } = context;
|
|
117
|
+
await using client = openMigrationDB(configuration.storage);
|
|
118
|
+
await dropTables(client);
|
|
195
119
|
};
|
|
196
120
|
//# sourceMappingURL=1684951997326-init.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1684951997326-init.js","sourceRoot":"","sources":["../../../src/migrations/scripts/1684951997326-init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"1684951997326-init.js","sourceRoot":"","sources":["../../../src/migrations/scripts/1684951997326-init.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,CAAC,MAAM,EAAE,GAA0C,KAAK,EAAE,OAAO,EAAE,EAAE;IACzE,MAAM,EACJ,eAAe,EAAE,EAAE,aAAa,EAAE,EACnC,GAAG,OAAO,CAAC;IACZ,YAAY,MAAM,GAAG,eAAe,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAE5D;;;OAGG;IACH,MAAM,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;QACpC,MAAM,EAAE,CAAC,GAAG,CAAA;;;;KAIX,CAAC,OAAO,EAAE,CAAC;QAEZ,MAAM,EAAE,CAAC,GAAG,CAAA;;;;KAIX,CAAC,OAAO,EAAE,CAAC;QAEZ,MAAM,EAAE,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;KAeX,CAAC,OAAO,EAAE,CAAC;QAEZ,MAAM,EAAE,CAAC,GAAG,CAAA,8CAA8C,CAAC,OAAO,EAAE,CAAC;QAErE,MAAM,EAAE,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;KAeX,CAAC,OAAO,EAAE,CAAC;QAEZ,MAAM,EAAE,CAAC,GAAG,CAAA;;;;;;;;;;;KAWX,CAAC,OAAO,EAAE,CAAC;QAEZ,MAAM,EAAE,CAAC,GAAG,CAAA;;KAEX,CAAC,OAAO,EAAE,CAAC;QAEZ,MAAM,EAAE,CAAC,GAAG,CAAA;;KAEX,CAAC,OAAO,EAAE,CAAC;QAEZ,MAAM,EAAE,CAAC,GAAG,CAAA;;;;;;;;;;KAUX,CAAC,OAAO,EAAE,CAAC;QAEZ,MAAM,EAAE,CAAC,GAAG,CAAA;;;;;;;;;;;;;KAaX,CAAC,OAAO,EAAE,CAAC;QAEZ,MAAM,EAAE,CAAC,GAAG,CAAA,0EAA0E,CAAC,OAAO,EAAE,CAAC;QAEjG,MAAM,EAAE,CAAC,GAAG,CAAA;;;;;;KAMX,CAAC,OAAO,EAAE,CAAC;QAEZ,MAAM,EAAE,CAAC,GAAG,CAAA;;;;;;;KAOX,CAAC,OAAO,EAAE,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAA0C,KAAK,EAAE,OAAO,EAAE,EAAE;IAC3E,MAAM,EACJ,eAAe,EAAE,EAAE,aAAa,EAAE,EACnC,GAAG,OAAO,CAAC;IACZ,YAAY,MAAM,GAAG,eAAe,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC5D,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC,CAAC"}
|
|
@@ -1,110 +1,34 @@
|
|
|
1
|
-
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
-
if (value !== null && value !== void 0) {
|
|
3
|
-
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
-
var dispose, inner;
|
|
5
|
-
if (async) {
|
|
6
|
-
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
-
dispose = value[Symbol.asyncDispose];
|
|
8
|
-
}
|
|
9
|
-
if (dispose === void 0) {
|
|
10
|
-
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
-
dispose = value[Symbol.dispose];
|
|
12
|
-
if (async) inner = dispose;
|
|
13
|
-
}
|
|
14
|
-
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
-
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
-
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
-
}
|
|
18
|
-
else if (async) {
|
|
19
|
-
env.stack.push({ async: true });
|
|
20
|
-
}
|
|
21
|
-
return value;
|
|
22
|
-
};
|
|
23
|
-
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
-
return function (env) {
|
|
25
|
-
function fail(e) {
|
|
26
|
-
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
-
env.hasError = true;
|
|
28
|
-
}
|
|
29
|
-
var r, s = 0;
|
|
30
|
-
function next() {
|
|
31
|
-
while (r = env.stack.pop()) {
|
|
32
|
-
try {
|
|
33
|
-
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
-
if (r.dispose) {
|
|
35
|
-
var result = r.dispose.call(r.value);
|
|
36
|
-
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
-
}
|
|
38
|
-
else s |= 1;
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
fail(e);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
-
if (env.hasError) throw env.error;
|
|
46
|
-
}
|
|
47
|
-
return next();
|
|
48
|
-
};
|
|
49
|
-
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
-
var e = new Error(message);
|
|
51
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
-
});
|
|
53
1
|
import { openMigrationDB } from '../migration-utils.js';
|
|
54
2
|
export const up = async (context) => {
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
await client.transaction(async (db) => {
|
|
60
|
-
await db.sql `
|
|
3
|
+
const { service_context: { configuration } } = context;
|
|
4
|
+
await using client = openMigrationDB(configuration.storage);
|
|
5
|
+
await client.transaction(async (db) => {
|
|
6
|
+
await db.sql `
|
|
61
7
|
ALTER TABLE sync_rules
|
|
62
8
|
ADD COLUMN snapshot_lsn TEXT
|
|
63
9
|
`.execute();
|
|
64
|
-
|
|
10
|
+
await db.sql `
|
|
65
11
|
ALTER TABLE source_tables
|
|
66
12
|
ADD COLUMN snapshot_total_estimated_count INTEGER,
|
|
67
13
|
ADD COLUMN snapshot_replicated_count INTEGER,
|
|
68
14
|
ADD COLUMN snapshot_last_key BYTEA
|
|
69
15
|
`.execute();
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
catch (e_1) {
|
|
73
|
-
env_1.error = e_1;
|
|
74
|
-
env_1.hasError = true;
|
|
75
|
-
}
|
|
76
|
-
finally {
|
|
77
|
-
const result_1 = __disposeResources(env_1);
|
|
78
|
-
if (result_1)
|
|
79
|
-
await result_1;
|
|
80
|
-
}
|
|
16
|
+
});
|
|
81
17
|
};
|
|
82
18
|
export const down = async (context) => {
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
await client.transaction(async (db) => {
|
|
88
|
-
await db.sql `
|
|
19
|
+
const { service_context: { configuration } } = context;
|
|
20
|
+
await using client = openMigrationDB(configuration.storage);
|
|
21
|
+
await client.transaction(async (db) => {
|
|
22
|
+
await db.sql `
|
|
89
23
|
ALTER TABLE sync_rules
|
|
90
24
|
DROP COLUMN snapshot_lsn
|
|
91
25
|
`.execute();
|
|
92
|
-
|
|
26
|
+
await db.sql `
|
|
93
27
|
ALTER TABLE source_tables
|
|
94
28
|
DROP COLUMN snapshot_total_estimated_count,
|
|
95
29
|
DROP COLUMN snapshot_replicated_count,
|
|
96
30
|
DROP COLUMN snapshot_last_key
|
|
97
31
|
`.execute();
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
catch (e_2) {
|
|
101
|
-
env_2.error = e_2;
|
|
102
|
-
env_2.hasError = true;
|
|
103
|
-
}
|
|
104
|
-
finally {
|
|
105
|
-
const result_2 = __disposeResources(env_2);
|
|
106
|
-
if (result_2)
|
|
107
|
-
await result_2;
|
|
108
|
-
}
|
|
32
|
+
});
|
|
109
33
|
};
|
|
110
34
|
//# sourceMappingURL=1749024804042-snapshot-progress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1749024804042-snapshot-progress.js","sourceRoot":"","sources":["../../../src/migrations/scripts/1749024804042-snapshot-progress.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"1749024804042-snapshot-progress.js","sourceRoot":"","sources":["../../../src/migrations/scripts/1749024804042-snapshot-progress.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,CAAC,MAAM,EAAE,GAA0C,KAAK,EAAE,OAAO,EAAE,EAAE;IACzE,MAAM,EACJ,eAAe,EAAE,EAAE,aAAa,EAAE,EACnC,GAAG,OAAO,CAAC;IACZ,YAAY,MAAM,GAAG,eAAe,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAE5D,MAAM,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;QACpC,MAAM,EAAE,CAAC,GAAG,CAAA;;;KAGX,CAAC,OAAO,EAAE,CAAC;QACZ,MAAM,EAAE,CAAC,GAAG,CAAA;;;;;KAKX,CAAC,OAAO,EAAE,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAA0C,KAAK,EAAE,OAAO,EAAE,EAAE;IAC3E,MAAM,EACJ,eAAe,EAAE,EAAE,aAAa,EAAE,EACnC,GAAG,OAAO,CAAC;IACZ,YAAY,MAAM,GAAG,eAAe,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAE5D,MAAM,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;QACpC,MAAM,EAAE,CAAC,GAAG,CAAA;;;KAGX,CAAC,OAAO,EAAE,CAAC;QACZ,MAAM,EAAE,CAAC,GAAG,CAAA;;;;;KAKX,CAAC,OAAO,EAAE,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1,63 +1,9 @@
|
|
|
1
|
-
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
-
if (value !== null && value !== void 0) {
|
|
3
|
-
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
-
var dispose, inner;
|
|
5
|
-
if (async) {
|
|
6
|
-
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
-
dispose = value[Symbol.asyncDispose];
|
|
8
|
-
}
|
|
9
|
-
if (dispose === void 0) {
|
|
10
|
-
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
-
dispose = value[Symbol.dispose];
|
|
12
|
-
if (async) inner = dispose;
|
|
13
|
-
}
|
|
14
|
-
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
-
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
-
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
-
}
|
|
18
|
-
else if (async) {
|
|
19
|
-
env.stack.push({ async: true });
|
|
20
|
-
}
|
|
21
|
-
return value;
|
|
22
|
-
};
|
|
23
|
-
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
-
return function (env) {
|
|
25
|
-
function fail(e) {
|
|
26
|
-
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
-
env.hasError = true;
|
|
28
|
-
}
|
|
29
|
-
var r, s = 0;
|
|
30
|
-
function next() {
|
|
31
|
-
while (r = env.stack.pop()) {
|
|
32
|
-
try {
|
|
33
|
-
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
-
if (r.dispose) {
|
|
35
|
-
var result = r.dispose.call(r.value);
|
|
36
|
-
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
-
}
|
|
38
|
-
else s |= 1;
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
fail(e);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
-
if (env.hasError) throw env.error;
|
|
46
|
-
}
|
|
47
|
-
return next();
|
|
48
|
-
};
|
|
49
|
-
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
-
var e = new Error(message);
|
|
51
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
-
});
|
|
53
1
|
import { openMigrationDB } from '../migration-utils.js';
|
|
54
2
|
export const up = async (context) => {
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
await client.transaction(async (db) => {
|
|
60
|
-
await db.sql `
|
|
3
|
+
const { service_context: { configuration } } = context;
|
|
4
|
+
await using client = openMigrationDB(configuration.storage);
|
|
5
|
+
await client.transaction(async (db) => {
|
|
6
|
+
await db.sql `
|
|
61
7
|
CREATE TABLE IF NOT EXISTS connection_report_events (
|
|
62
8
|
id TEXT PRIMARY KEY,
|
|
63
9
|
user_agent TEXT NOT NULL,
|
|
@@ -69,39 +15,17 @@ export const up = async (context) => {
|
|
|
69
15
|
disconnected_at TIMESTAMP WITH TIME ZONE
|
|
70
16
|
)
|
|
71
17
|
`.execute();
|
|
72
|
-
|
|
18
|
+
await db.sql `
|
|
73
19
|
CREATE INDEX IF NOT EXISTS sdk_list_index ON connection_report_events (connected_at, jwt_exp, disconnected_at)
|
|
74
20
|
`.execute();
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
catch (e_1) {
|
|
81
|
-
env_1.error = e_1;
|
|
82
|
-
env_1.hasError = true;
|
|
83
|
-
}
|
|
84
|
-
finally {
|
|
85
|
-
const result_1 = __disposeResources(env_1);
|
|
86
|
-
if (result_1)
|
|
87
|
-
await result_1;
|
|
88
|
-
}
|
|
21
|
+
await db.sql `CREATE INDEX IF NOT EXISTS sdk_user_id_index ON connection_report_events (user_id)`.execute();
|
|
22
|
+
await db.sql `CREATE INDEX IF NOT EXISTS sdk_client_id_index ON connection_report_events (client_id)`.execute();
|
|
23
|
+
await db.sql `CREATE INDEX IF NOT EXISTS sdk_index ON connection_report_events (sdk)`.execute();
|
|
24
|
+
});
|
|
89
25
|
};
|
|
90
26
|
export const down = async (context) => {
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const client = __addDisposableResource(env_2, openMigrationDB(configuration.storage), true);
|
|
95
|
-
await client.sql `DROP TABLE IF EXISTS connection_report_events`.execute();
|
|
96
|
-
}
|
|
97
|
-
catch (e_2) {
|
|
98
|
-
env_2.error = e_2;
|
|
99
|
-
env_2.hasError = true;
|
|
100
|
-
}
|
|
101
|
-
finally {
|
|
102
|
-
const result_2 = __disposeResources(env_2);
|
|
103
|
-
if (result_2)
|
|
104
|
-
await result_2;
|
|
105
|
-
}
|
|
27
|
+
const { service_context: { configuration } } = context;
|
|
28
|
+
await using client = openMigrationDB(configuration.storage);
|
|
29
|
+
await client.sql `DROP TABLE IF EXISTS connection_report_events`.execute();
|
|
106
30
|
};
|
|
107
31
|
//# sourceMappingURL=1756282360128-connection-reporting.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1756282360128-connection-reporting.js","sourceRoot":"","sources":["../../../src/migrations/scripts/1756282360128-connection-reporting.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"1756282360128-connection-reporting.js","sourceRoot":"","sources":["../../../src/migrations/scripts/1756282360128-connection-reporting.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,CAAC,MAAM,EAAE,GAA0C,KAAK,EAAE,OAAO,EAAE,EAAE;IACzE,MAAM,EACJ,eAAe,EAAE,EAAE,aAAa,EAAE,EACnC,GAAG,OAAO,CAAC;IACZ,YAAY,MAAM,GAAG,eAAe,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC5D,MAAM,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;QACpC,MAAM,EAAE,CAAC,GAAG,CAAA;;;;;;;;;;;KAWX,CAAC,OAAO,EAAE,CAAC;QAEZ,MAAM,EAAE,CAAC,GAAG,CAAA;;KAEX,CAAC,OAAO,EAAE,CAAC;QAEZ,MAAM,EAAE,CAAC,GAAG,CAAA,oFAAoF,CAAC,OAAO,EAAE,CAAC;QAE3G,MAAM,EAAE,CAAC,GAAG,CAAA,wFAAwF,CAAC,OAAO,EAAE,CAAC;QAE/G,MAAM,EAAE,CAAC,GAAG,CAAA,wEAAwE,CAAC,OAAO,EAAE,CAAC;IACjG,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAA0C,KAAK,EAAE,OAAO,EAAE,EAAE;IAC3E,MAAM,EACJ,eAAe,EAAE,EAAE,aAAa,EAAE,EACnC,GAAG,OAAO,CAAC;IACZ,YAAY,MAAM,GAAG,eAAe,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC5D,MAAM,MAAM,CAAC,GAAG,CAAA,+CAA+C,CAAC,OAAO,EAAE,CAAC;AAC5E,CAAC,CAAC"}
|
|
@@ -1,86 +1,20 @@
|
|
|
1
|
-
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
-
if (value !== null && value !== void 0) {
|
|
3
|
-
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
-
var dispose, inner;
|
|
5
|
-
if (async) {
|
|
6
|
-
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
-
dispose = value[Symbol.asyncDispose];
|
|
8
|
-
}
|
|
9
|
-
if (dispose === void 0) {
|
|
10
|
-
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
-
dispose = value[Symbol.dispose];
|
|
12
|
-
if (async) inner = dispose;
|
|
13
|
-
}
|
|
14
|
-
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
-
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
-
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
-
}
|
|
18
|
-
else if (async) {
|
|
19
|
-
env.stack.push({ async: true });
|
|
20
|
-
}
|
|
21
|
-
return value;
|
|
22
|
-
};
|
|
23
|
-
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
-
return function (env) {
|
|
25
|
-
function fail(e) {
|
|
26
|
-
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
-
env.hasError = true;
|
|
28
|
-
}
|
|
29
|
-
var r, s = 0;
|
|
30
|
-
function next() {
|
|
31
|
-
while (r = env.stack.pop()) {
|
|
32
|
-
try {
|
|
33
|
-
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
-
if (r.dispose) {
|
|
35
|
-
var result = r.dispose.call(r.value);
|
|
36
|
-
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
-
}
|
|
38
|
-
else s |= 1;
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
fail(e);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
-
if (env.hasError) throw env.error;
|
|
46
|
-
}
|
|
47
|
-
return next();
|
|
48
|
-
};
|
|
49
|
-
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
-
var e = new Error(message);
|
|
51
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
-
});
|
|
53
1
|
import { storage } from '@powersync/service-core';
|
|
54
2
|
import { openMigrationDB } from '../migration-utils.js';
|
|
55
3
|
export const up = async (context) => {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
await client.transaction(async (db) => {
|
|
61
|
-
await db.sql `
|
|
4
|
+
const { service_context: { configuration } } = context;
|
|
5
|
+
await using client = openMigrationDB(configuration.storage);
|
|
6
|
+
await client.transaction(async (db) => {
|
|
7
|
+
await db.sql `
|
|
62
8
|
ALTER TABLE sync_rules
|
|
63
9
|
ADD COLUMN storage_version integer NOT NULL DEFAULT 1
|
|
64
10
|
`.execute();
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
catch (e_1) {
|
|
68
|
-
env_1.error = e_1;
|
|
69
|
-
env_1.hasError = true;
|
|
70
|
-
}
|
|
71
|
-
finally {
|
|
72
|
-
const result_1 = __disposeResources(env_1);
|
|
73
|
-
if (result_1)
|
|
74
|
-
await result_1;
|
|
75
|
-
}
|
|
11
|
+
});
|
|
76
12
|
};
|
|
77
13
|
export const down = async (context) => {
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
await client.transaction(async (db) => {
|
|
83
|
-
const newRules = await db.sql `
|
|
14
|
+
const { service_context: { configuration } } = context;
|
|
15
|
+
await using client = openMigrationDB(configuration.storage);
|
|
16
|
+
await client.transaction(async (db) => {
|
|
17
|
+
const newRules = await db.sql `
|
|
84
18
|
SELECT
|
|
85
19
|
id,
|
|
86
20
|
storage_version
|
|
@@ -89,23 +23,13 @@ export const down = async (context) => {
|
|
|
89
23
|
WHERE
|
|
90
24
|
storage_version > ${{ type: 'int4', value: storage.LEGACY_STORAGE_VERSION }}
|
|
91
25
|
`.rows();
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
26
|
+
if (newRules.length > 0) {
|
|
27
|
+
throw new Error(`Cannot revert migration due to newer storage versions in use: ${newRules.map((r) => `${r.id}: v${r.storage_version}`).join(', ')}`);
|
|
28
|
+
}
|
|
29
|
+
await db.sql `
|
|
96
30
|
ALTER TABLE sync_rules
|
|
97
31
|
DROP COLUMN storage_version
|
|
98
32
|
`.execute();
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
catch (e_2) {
|
|
102
|
-
env_2.error = e_2;
|
|
103
|
-
env_2.hasError = true;
|
|
104
|
-
}
|
|
105
|
-
finally {
|
|
106
|
-
const result_2 = __disposeResources(env_2);
|
|
107
|
-
if (result_2)
|
|
108
|
-
await result_2;
|
|
109
|
-
}
|
|
33
|
+
});
|
|
110
34
|
};
|
|
111
35
|
//# sourceMappingURL=1771232439485-storage-version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1771232439485-storage-version.js","sourceRoot":"","sources":["../../../src/migrations/scripts/1771232439485-storage-version.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"1771232439485-storage-version.js","sourceRoot":"","sources":["../../../src/migrations/scripts/1771232439485-storage-version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,CAAC,MAAM,EAAE,GAA0C,KAAK,EAAE,OAAO,EAAE,EAAE;IACzE,MAAM,EACJ,eAAe,EAAE,EAAE,aAAa,EAAE,EACnC,GAAG,OAAO,CAAC;IACZ,YAAY,MAAM,GAAG,eAAe,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC5D,MAAM,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;QACpC,MAAM,EAAE,CAAC,GAAG,CAAA;;;KAGX,CAAC,OAAO,EAAE,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAA0C,KAAK,EAAE,OAAO,EAAE,EAAE;IAC3E,MAAM,EACJ,eAAe,EAAE,EAAE,aAAa,EAAE,EACnC,GAAG,OAAO,CAAC;IACZ,YAAY,MAAM,GAAG,eAAe,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC5D,MAAM,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;QACpC,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,GAAG,CAAA;;;;;;;4BAOL,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,sBAAsB,EAAE;KAC9E,CAAC,IAAI,EAA6D,CAAC;QAEpE,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CACb,iEAAiE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACpI,CAAC;QACJ,CAAC;QAED,MAAM,EAAE,CAAC,GAAG,CAAA;;;KAGX,CAAC,OAAO,EAAE,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|