Skip to content

Commit fc7e6f8

Browse files
committed
add schema version
1 parent 4f88d93 commit fc7e6f8

File tree

4 files changed

+214
-219
lines changed

4 files changed

+214
-219
lines changed

broker/cloud_functions/lvk/store_BigQuery/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
PROJECT_ID = os.getenv("GCP_PROJECT")
1212
SURVEY = os.getenv("SURVEY")
1313
TESTID = os.getenv("TESTID")
14+
VERSIONTAG = os.getenv("VERSIONTAG")
1415

1516
# connect to the cloud logger
1617
log_name = "store-bigquery-cloudfnc" # same log for all broker instances
1718
logging_client = logging.Client()
1819
logger = logging_client.logger(log_name)
1920

2021
# GCP resources used in this module
21-
TABLE = pittgoogle.Table.from_cloud("alerts", survey=SURVEY, testid=TESTID)
22+
TABLE = pittgoogle.Table.from_cloud(f"alerts_{VERSIONTAG}", survey=SURVEY, testid=TESTID)
2223
TOPIC = pittgoogle.Topic.from_cloud("bigquery", survey=SURVEY, testid=TESTID, projectid=PROJECT_ID)
2324

2425

broker/setup_broker/lvk/setup_broker.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ testid="${1:-test}"
88
teardown="${2:-False}"
99
# name of the survey this broker instance will ingest
1010
survey="${3:-lvk}"
11-
region="${4:-us-central1}"
11+
schema_version="${4:-1.0}"
12+
versiontag=v$(echo "${schema_version}" | tr . _) # 1.0 -> v1_0
13+
region="${5:-us-central1}"
1214
zone="${region}-a" # just use zone "a" instead of adding another script arg
1315

1416
PROJECT_ID=$GOOGLE_CLOUD_PROJECT # get the environment variable
@@ -46,7 +48,7 @@ if [ "$testid" != "False" ]; then
4648
topic_storebigquery="${topic_storebigquery}-${testid}"
4749
fi
4850

49-
alerts_table="alerts"
51+
alerts_table="alerts_${versiontag}"
5052

5153
#--- Create (or delete) BigQuery, GCS, Pub/Sub resources
5254
echo

broker/setup_broker/lvk/templates/bq_lvk_alerts_schema.json

Lines changed: 0 additions & 216 deletions
This file was deleted.

0 commit comments

Comments
 (0)