Clickhouse rails
Install
Add to Gemfile
gem 'clickhouse-rails'Run bundle
$ bundle installInit config files and folders
$ rails g clickhouse:installChange clickhouse.yml at
config/clickhouse.ymlpath
Usage
Create migrations
$ rails g clickhouse:migration add_tmp_table create db/clickhouse/migrate/002_add_tmp_table.rbEdit file like this:
# db/clickhouse/migrate/002_add_tmp_table.rb class AddTmpTable < Clickhouse::Rails::Migrations::Base def self.up create_table :tmp do |t| t.date :date t.uint16 :id t.engine "MergeTree(date, (date), 8192)" end end endRun migrations
$ rake clickhouse:db:migrate
You can create class of clickhouse table:
# app/models/custom_table.rb
class CustomTable
include Clickhouse::Table
end
TODO:
- Rollback migrations
- Alter table