CREATE TABLE IF NOT EXISTS qrust.assets (
    symbol String,
    class Enum('us_equity' = 1, 'crypto' = 2),
    exchange Enum(
        'AMEX' = 1,
        'ARCA' = 2,
        'BATS' = 3,
        'NASDAQ' = 4,
        'NYSE' = 5,
        'NYSEARCA' = 6,
        'OTC' = 7,
        'CRYPTO' = 8
    ),
    time_added DateTime DEFAULT now()
)
ENGINE = ReplacingMergeTree()
PRIMARY KEY symbol;

CREATE TABLE IF NOT EXISTS qrust.bars (
    symbol String,
    time DateTime,
    open Float64,
    high Float64,
    low Float64,
    close Float64,
    volume Float64,
    trades Int64,
    vwap Float64
)
ENGINE = ReplacingMergeTree()
PRIMARY KEY (symbol, time)
PARTITION BY toYYYYMM(time);

CREATE TABLE IF NOT EXISTS qrust.backfills (
    symbol String,
    time DateTime
)
ENGINE = ReplacingMergeTree()
PRIMARY KEY symbol;
