Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default value for columns #25

Open
volfgox opened this issue Sep 17, 2018 · 1 comment
Open

Default value for columns #25

volfgox opened this issue Sep 17, 2018 · 1 comment

Comments

@volfgox
Copy link

volfgox commented Sep 17, 2018

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.

@shlima
Copy link

shlima commented Nov 9, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants