-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrate events from mysql to clickhouse
- Loading branch information
Showing
40 changed files
with
750 additions
and
341 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM clickhouse/clickhouse-server:24.6-alpine | ||
|
||
RUN apk add --no-cache gettext | ||
|
||
COPY /clickhouse/migrations /docker-entrypoint-initdb.d/ | ||
COPY /clickhouse/entrypoint.sh /usr/local/bin/entrypoint.sh | ||
|
||
RUN chmod +x /usr/local/bin/entrypoint.sh | ||
|
||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
INIT_DIR="/docker-entrypoint-initdb.d" | ||
FLAG_FILE="$INIT_DIR/.migrated" | ||
|
||
if [ ! -f "$FLAG_FILE" ]; then | ||
for file in ${INIT_DIR}/*.sql; do | ||
if [ -f "$file" ]; then | ||
envsubst < "$file" > "$file.processed" && mv "$file.processed" "$file" | ||
echo "Processed migration $file" | ||
fi | ||
done | ||
|
||
echo "Creating migrations lock" | ||
touch "$FLAG_FILE" | ||
else | ||
echo "Migrations lock set; Skipping envsubst processing" | ||
fi | ||
|
||
exec /entrypoint.sh "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
CREATE TABLE IF NOT EXISTS ${CLICKHOUSE_DB}.events | ||
( | ||
id String, | ||
name String, | ||
game_id UInt32, | ||
player_alias_id UInt32, | ||
dev_build Boolean, | ||
created_at DateTime, | ||
updated_at DateTime, | ||
PRIMARY KEY (id), | ||
INDEX name_idx (name) TYPE bloom_filter(0.01) GRANULARITY 64, | ||
INDEX game_id_idx (game_id) TYPE minmax GRANULARITY 64, | ||
INDEX player_alias_id_idx (player_alias_id) TYPE minmax GRANULARITY 64 | ||
) | ||
ENGINE = MergeTree() | ||
ORDER BY (id, created_at, game_id, player_alias_id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CREATE TABLE IF NOT EXISTS ${CLICKHOUSE_DB}.event_props ( | ||
event_id String, | ||
prop_key String, | ||
prop_value String | ||
) ENGINE = MergeTree() | ||
ORDER BY (event_id, prop_key); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,9 @@ | ||
services: | ||
test-db: | ||
image: mysql:8.4 | ||
command: --mysql-native-password=ON | ||
environment: | ||
- MYSQL_DATABASE=${DB_NAME} | ||
- MYSQL_ROOT_PASSWORD=${DB_PASS} | ||
restart: always | ||
healthcheck: | ||
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1"] | ||
interval: 2s | ||
timeout: 2s | ||
retries: 10 | ||
ports: | ||
- ${DB_PORT}:3306 | ||
volumes: | ||
- test-data:/var/lib/mysql | ||
networks: | ||
- test-network | ||
|
||
test-redis: | ||
image: bitnami/redis:7.2 | ||
command: | ||
environment: | ||
- REDIS_PASSWORD=${REDIS_PASSWORD} | ||
ports: | ||
- ${REDIS_PORT}:6379 | ||
depends_on: | ||
test-db: | ||
condition: service_healthy | ||
networks: | ||
- test-network | ||
|
||
stripe-api: | ||
image: stripe/stripe-mock:latest | ||
ports: | ||
- 12111:12111 | ||
- 12112:12112 | ||
networks: | ||
- test-network | ||
|
||
volumes: | ||
test-data: | ||
|
||
networks: | ||
test-network: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.