clickhouse
clickhouse copied to clipboard
Default value for columns
Does this gem support defining default value as what is descried in clickhouse documentation metioned bellow?
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] [db.]name [ON CLUSTER cluster]
(
name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1],
name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2],
...
) ENGINE = engine
I saw Clickhouse::Connection::Query::Table#to_sql and think it is not supported.
I've just made an alternative, very similar to this one:
ClickHouse.connection.create_table('visits', engine: 'MergeTree(date, (year, date), 8192)') do |t|
t.UInt16 :year
t.Date :date
t.UInt16 :id, 16, default: 0, ttl: 'date + INTERVAL 1 DAY'
end