Skip to content

Commit 584d9d7

Browse files
committed
feat: Add new columns for note tracking in datamartUsers
- Introduced additional columns: latest_open_note_id, latest_commented_note_id, latest_closed_note_id, and latest_reopened_note_id to the datamartUsers table. - Ensured all basic columns exist before executing COMMENT statements, enhancing the table structure for improved note management.
1 parent e25141d commit 584d9d7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tests/run_mock_etl.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,16 @@ HAS_PK_CONTR_TYPES=$("${psql_cmd[@]}" -tAc "SELECT EXISTS (SELECT 1 FROM informa
235235
if [[ "${HAS_PK_DU}" == "t" || "${HAS_PK_BADGES}" == "t" || "${HAS_PK_BADGE_USERS}" == "t" || "${HAS_PK_CONTR_TYPES}" == "t" ]]; then
236236
# Table exists: add new columns first, then execute script (which will skip CREATE TABLE)
237237
if [[ "${HAS_PK_DU}" == "t" ]]; then
238+
# Ensure all basic columns exist before executing COMMENT statements
238239
"${psql_cmd[@]}" -c "ALTER TABLE dwh.datamartUsers ADD COLUMN IF NOT EXISTS iso_week SMALLINT;" 2> /dev/null || true
239240
"${psql_cmd[@]}" -c "ALTER TABLE dwh.datamartUsers ADD COLUMN IF NOT EXISTS quarter SMALLINT;" 2> /dev/null || true
240241
"${psql_cmd[@]}" -c "ALTER TABLE dwh.datamartUsers ADD COLUMN IF NOT EXISTS month_name VARCHAR(16);" 2> /dev/null || true
241242
"${psql_cmd[@]}" -c "ALTER TABLE dwh.datamartUsers ADD COLUMN IF NOT EXISTS hour_of_week SMALLINT;" 2> /dev/null || true
242243
"${psql_cmd[@]}" -c "ALTER TABLE dwh.datamartUsers ADD COLUMN IF NOT EXISTS period_of_day VARCHAR(16);" 2> /dev/null || true
244+
"${psql_cmd[@]}" -c "ALTER TABLE dwh.datamartUsers ADD COLUMN IF NOT EXISTS latest_open_note_id INTEGER;" 2> /dev/null || true
245+
"${psql_cmd[@]}" -c "ALTER TABLE dwh.datamartUsers ADD COLUMN IF NOT EXISTS latest_commented_note_id INTEGER;" 2> /dev/null || true
246+
"${psql_cmd[@]}" -c "ALTER TABLE dwh.datamartUsers ADD COLUMN IF NOT EXISTS latest_closed_note_id INTEGER;" 2> /dev/null || true
247+
"${psql_cmd[@]}" -c "ALTER TABLE dwh.datamartUsers ADD COLUMN IF NOT EXISTS latest_reopened_note_id INTEGER;" 2> /dev/null || true
243248
fi
244249
TMP_DU12_DDL="$(mktemp)"
245250
awk -v pk_du="${HAS_PK_DU}" -v pk_b="${HAS_PK_BADGES}" -v pk_bu="${HAS_PK_BADGE_USERS}" -v pk_ct="${HAS_PK_CONTR_TYPES}" '

0 commit comments

Comments
 (0)