-
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
31 changed files
with
658 additions
and
296 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,16 @@ | ||
CREATE TABLE IF NOT EXISTS gs_ch.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); |
6 changes: 6 additions & 0 deletions
6
clickhouse/migrations/20240815105700CreateEventPropsTable.sql
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 gs_ch.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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
MIGRATIONS_DIR="/migrations" | ||
|
||
echo "Starting migrations..." | ||
|
||
for migration in $(ls ${MIGRATIONS_DIR}/*.sql | sort); do | ||
echo "Applying migration: $migration..." | ||
|
||
if [ -z "$CLICKHOUSE_USER" ] && [ -z "$CLICKHOUSE_PASS" ]; then | ||
clickhouse-client --query="$(cat $migration)" | ||
else | ||
clickhouse-client --user="${CLICKHOUSE_USER}" --password="${CLICKHOUSE_PASS}" --query="$(cat $migration)" | ||
fi | ||
done | ||
|
||
echo "Migrations complete!" |
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
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.