- Docker (tested on v27.2.0)
- Go (tested on go1.22.2 linux/amd64)
docker run -d -p 9000:9000 -p 8123:8123 --name venatus-clickhouse-server --ulimit nofile=262144:262144 clickhouse/clickhouse-server
- Design a command line tool, that will apply pending schema migrations and store the schema state on the database server.
- On first launch, the program should create a table in clickhouse that stores the migration state.
- Traverse the migrations directory, check SQL files that have not been applied already in alphanumeric order and apply each sequentially.
- The program should not rely on filename alone and should check if the files contents have changed since last applied.
- The tool should support reversion of schema with a command line parameter such as
-rollback 002_alter_column.sql
(see contents of migrations/002_alter_column.sql for rollback). On revert, we should read the code inside comment and ignore the uncommented. - Unit tests designed to verify clickhouse state:
- Migration applied
- No operation needed
- Successfully rolled back
Dbeaver is a useful UI to connect to clickhouse. In Go it is preferred to use a native connection (port 9000), but dbeaver will need to use http (port 8123)