Skip to content

Commit b92eec8

Browse files
author
Cristhian Garcia
authored
Merge pull request #927 from openedx/cag/tags
feat: add tag related tables
2 parents 0537e1e + 90679f1 commit b92eec8

File tree

6 files changed

+94
-5
lines changed

6 files changed

+94
-5
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared \
2-
pip install "platform-plugin-aspects==v0.10.0"
2+
pip install "platform-plugin-aspects==v0.11.0"
33

44
RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared \
55
pip install "edx-event-routing-backends>=9.3.0,<9.4"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared \
2-
pip install "platform-plugin-aspects==v0.10.0"
2+
pip install "platform-plugin-aspects==v0.11.0"
33

44
RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared \
55
pip install "edx-event-routing-backends>=9.3.0,<9.4"

tutoraspects/plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
("DOCKER_IMAGE_VECTOR", "timberio/vector:0.30.0-alpine"),
4141
(
4242
"EVENT_SINK_MODELS_ENABLED",
43-
["course_overviews"],
43+
["course_overviews", "tag", "taxonomy", "object_tag"],
4444
),
4545
(
4646
"EVENT_SINK_PII_MODELS",
@@ -376,7 +376,7 @@
376376
# For now we are pulling this from github, which should allow maximum
377377
# flexibility for forking, running branches, specific versions, etc.
378378
("DBT_REPOSITORY", "https://github.com/openedx/aspects-dbt"),
379-
("DBT_BRANCH", "v3.30.0"),
379+
("DBT_BRANCH", "v3.31.0"),
380380
("DBT_SSH_KEY", ""),
381381
("DBT_STATE_DIR", "/app/aspects-dbt/state"),
382382
("DBT_PROFILES_DIR", "/app/aspects/dbt/"),

tutoraspects/templates/aspects/apps/aspects/dbt/profiles.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ aspects: # this needs to match the profile in your dbt_project.yml file
3131
database_atomic_delay_before_drop_table_sec: 0
3232
# Make sure all drops and detaches complete before continuing
3333
database_atomic_wait_for_drop_and_detach_synchronously: 1
34+
# Allow to drop/rename tables that have dependants. dbt-clickhouse use it for view backups
35+
check_table_dependencies: 0
3436

3537

3638
{{ patch("dbt-profiles") | indent(6)}}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
from alembic import op
2+
import sqlalchemy as sa
3+
4+
revision = "0039"
5+
down_revision = "0038"
6+
branch_labels = None
7+
depends_on = None
8+
on_cluster = " ON CLUSTER '{{CLICKHOUSE_CLUSTER_NAME}}' " if "{{CLICKHOUSE_CLUSTER_NAME}}" else ""
9+
engine = (
10+
"ReplicatedReplacingMergeTree"
11+
if "{{CLICKHOUSE_CLUSTER_NAME}}"
12+
else "ReplacingMergeTree"
13+
)
14+
15+
16+
def upgrade():
17+
op.execute(
18+
f"""
19+
CREATE TABLE IF NOT EXISTS {{ ASPECTS_EVENT_SINK_DATABASE }}.tag
20+
{on_cluster}
21+
(
22+
id Int32,
23+
taxonomy Int32,
24+
parent Int32,
25+
value String,
26+
external_id String,
27+
lineage String,
28+
dump_id UUID NOT NULL,
29+
time_last_dumped String NOT NULL
30+
) ENGINE {engine}
31+
ORDER BY (id, time_last_dumped)
32+
PRIMARY KEY (id, time_last_dumped);
33+
"""
34+
)
35+
36+
op.execute(
37+
f"""
38+
CREATE TABLE IF NOT EXISTS {{ ASPECTS_EVENT_SINK_DATABASE }}.taxonomy
39+
{on_cluster}
40+
(
41+
id Int32,
42+
name String,
43+
dump_id UUID NOT NULL,
44+
time_last_dumped String NOT NULL
45+
) ENGINE {engine}
46+
ORDER BY (id, time_last_dumped)
47+
PRIMARY KEY (id, time_last_dumped);
48+
"""
49+
)
50+
51+
52+
op.execute(
53+
f"""
54+
CREATE TABLE IF NOT EXISTS {{ ASPECTS_EVENT_SINK_DATABASE }}.object_tag
55+
{on_cluster}
56+
(
57+
id Int32,
58+
object_id String,
59+
taxonomy Int32,
60+
tag Int32,
61+
_value String,
62+
_export_id String,
63+
lineage String,
64+
dump_id UUID NOT NULL,
65+
time_last_dumped String NOT NULL
66+
) ENGINE {engine}
67+
ORDER BY (id, time_last_dumped)
68+
PRIMARY KEY (id, time_last_dumped);
69+
"""
70+
)
71+
72+
73+
def downgrade():
74+
op.execute(
75+
"DROP TABLE IF EXISTS {{ ASPECTS_EVENT_SINK_DATABASE }}.tag"
76+
f"{on_cluster};"
77+
)
78+
79+
op.execute(
80+
"DROP TABLE IF EXISTS {{ ASPECTS_EVENT_SINK_DATABASE }}.taxonomy"
81+
f"{on_cluster};"
82+
)
83+
84+
op.execute(
85+
"DROP TABLE IF EXISTS {{ ASPECTS_EVENT_SINK_DATABASE }}.object_tag"
86+
f"{on_cluster};"
87+
)

tutoraspects/templates/aspects/apps/aspects/scripts/bootstrap.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fi
1616

1717
export branch=$(git -C aspects-dbt/ branch --show-current)
1818
export repo=$(git -C aspects-dbt/ config --get remote.origin.url)
19-
if [ "$DBT_BRANCH" != "$branch" ] && [ "$DBT_REPOSITORY" != "$repo" ];
19+
if [ "$DBT_BRANCH" != "$branch" ] || [ "$DBT_REPOSITORY" != "$repo" ];
2020
then
2121
rm -rf aspects-dbt
2222

0 commit comments

Comments
 (0)