@firebaseextensions/firestore-bigquery-change-tracker 1.1.17 → 1.1.18
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.
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.viewRequiresUpdate = exports.tableRequiresUpdate = void 0;
|
|
4
4
|
const partitioning_1 = require("./partitioning");
|
|
5
|
-
async function tableRequiresUpdate({ table, config, documentIdColExists, pathParamsColExists, }) {
|
|
5
|
+
async function tableRequiresUpdate({ table, config, documentIdColExists, pathParamsColExists, oldDataColExists, }) {
|
|
6
6
|
/* Setup checks */
|
|
7
7
|
const { metadata } = table;
|
|
8
8
|
/** Check clustering */
|
|
@@ -16,6 +16,9 @@ async function tableRequiresUpdate({ table, config, documentIdColExists, pathPar
|
|
|
16
16
|
/** Check document id column */
|
|
17
17
|
if (!documentIdColExists)
|
|
18
18
|
return true;
|
|
19
|
+
/** Check old_data column exists */
|
|
20
|
+
if (!oldDataColExists)
|
|
21
|
+
return true;
|
|
19
22
|
/** Check partitioning */
|
|
20
23
|
const partitioning = new partitioning_1.Partitioning(config, table);
|
|
21
24
|
const isValidPartition = await partitioning.isValidPartitionForExistingTable();
|
|
@@ -25,16 +28,16 @@ async function tableRequiresUpdate({ table, config, documentIdColExists, pathPar
|
|
|
25
28
|
return false;
|
|
26
29
|
}
|
|
27
30
|
exports.tableRequiresUpdate = tableRequiresUpdate;
|
|
28
|
-
function viewRequiresUpdate({ metadata, config, documentIdColExists, pathParamsColExists, }) {
|
|
29
|
-
/** Check if documentId column exists */
|
|
30
|
-
if (!documentIdColExists)
|
|
31
|
-
return true;
|
|
31
|
+
function viewRequiresUpdate({ metadata, config, documentIdColExists, pathParamsColExists, oldDataColExists, }) {
|
|
32
32
|
/** Check wildcards */
|
|
33
33
|
if (!!config.wildcardIds !== pathParamsColExists)
|
|
34
34
|
return true;
|
|
35
35
|
/** Check document id column */
|
|
36
36
|
if (!documentIdColExists)
|
|
37
37
|
return true;
|
|
38
|
+
/** Check old_data column exists */
|
|
39
|
+
if (!oldDataColExists)
|
|
40
|
+
return true;
|
|
38
41
|
/* Using the new query syntax for snapshots */
|
|
39
42
|
if (metadata) {
|
|
40
43
|
const query = metadata.view?.query || "";
|
package/lib/bigquery/index.js
CHANGED
|
@@ -253,6 +253,7 @@ class FirestoreBigQueryEventHistoryTracker {
|
|
|
253
253
|
await clustering.updateClustering(metadata);
|
|
254
254
|
const documentIdColExists = fields.find((column) => column.name === "document_id");
|
|
255
255
|
const pathParamsColExists = fields.find((column) => column.name === "path_params");
|
|
256
|
+
const oldDataColExists = fields.find((column) => column.name === "old_data");
|
|
256
257
|
if (!documentIdColExists) {
|
|
257
258
|
fields.push(schema_1.documentIdField);
|
|
258
259
|
logs.addNewColumn(this.rawChangeLogTableName(), schema_1.documentIdField.name);
|
|
@@ -268,6 +269,7 @@ class FirestoreBigQueryEventHistoryTracker {
|
|
|
268
269
|
config: this.config,
|
|
269
270
|
documentIdColExists,
|
|
270
271
|
pathParamsColExists,
|
|
272
|
+
oldDataColExists,
|
|
271
273
|
});
|
|
272
274
|
if (shouldUpdate) {
|
|
273
275
|
await table.setMetadata(metadata);
|
|
@@ -307,18 +309,22 @@ class FirestoreBigQueryEventHistoryTracker {
|
|
|
307
309
|
if (viewExists) {
|
|
308
310
|
logs.bigQueryViewAlreadyExists(view.id, dataset.id);
|
|
309
311
|
const [metadata] = await view.getMetadata();
|
|
310
|
-
|
|
312
|
+
// TODO: just casting this for now, needs properly fixing
|
|
313
|
+
const fields = (metadata.schema ? metadata.schema.fields : []);
|
|
311
314
|
if (this.config.wildcardIds) {
|
|
312
315
|
schema.fields.push(schema_1.documentPathParams);
|
|
313
316
|
}
|
|
314
|
-
const
|
|
315
|
-
const
|
|
317
|
+
const columnNames = fields.map((field) => field.name);
|
|
318
|
+
const documentIdColExists = columnNames.includes("document_id");
|
|
319
|
+
const pathParamsColExists = columnNames.includes("path_params");
|
|
320
|
+
const oldDataColExists = columnNames.includes("old_data");
|
|
316
321
|
/** If new view or opt-in to new query syntax **/
|
|
317
322
|
const updateView = checkUpdates_1.viewRequiresUpdate({
|
|
318
323
|
metadata,
|
|
319
324
|
config: this.config,
|
|
320
325
|
documentIdColExists,
|
|
321
326
|
pathParamsColExists,
|
|
327
|
+
oldDataColExists,
|
|
322
328
|
});
|
|
323
329
|
if (updateView) {
|
|
324
330
|
metadata.view = snapshot_1.latestConsistentSnapshotView({
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"url": "github.com/firebase/extensions.git",
|
|
6
6
|
"directory": "firestore-bigquery-export/firestore-bigquery-change-tracker"
|
|
7
7
|
},
|
|
8
|
-
"version": "1.1.
|
|
8
|
+
"version": "1.1.18",
|
|
9
9
|
"description": "Core change-tracker library for Cloud Firestore Collection BigQuery Exports",
|
|
10
10
|
"main": "./lib/index.js",
|
|
11
11
|
"scripts": {
|