Support Ecto DSL in `enable_hypertable_compression/2`
Opened this issue ยท 4 comments
davydog187 commented
We have a function enable_hypertable_compression/2
which corresponds to an alter table, see the timescale docs
Currently we're only allowing you to pass the column name, but we should support the order and nulls rules as well. See below ๐๐ผ
ALTER TABLE <table_name> SET (timescaledb.compress, timescaledb.compress_orderby = '<column_name> [ASC | DESC] [ NULLS { FIRST | LAST } ] [, ...]',
timescaledb.compress_segmentby = '<column_name> [, ...]'
);
doomspork commented
I'm trying to better understand how you want the Ecto DSL to play into this. Do you have an idea of what you sort of see the final product looking like?
enable_hypertable_compression(:prices,
segment_by: "currency_id",
order_by: [asc: :inserted_at, desc_nulls_first: :another_id]
)
davydog187 commented
Your example is on the money. On my phone, but I believe there are some alternative ways to do that, we should support them as well
davydog187 commented
From the Ecto.Query.order_by/3 documentation, we should support the following examples:
from(c in City, order_by: c.name, order_by: c.population)
from(c in City, order_by: [c.name, c.population])
from(c in City, order_by: [asc: c.name, desc: c.population])
from(c in City, order_by: [:name, :population])
from(c in City, order_by: [asc: :name, desc_nulls_first: :population])