jonatas / timescaledb

The timescaledb gem. Pack of helpers to work with TimescaleDB extension in Ruby.
https://jonatas.github.io/timescaledb/
MIT License
61 stars 18 forks source link

Schema with create_continuous_aggregate before create_hypertable #43

Closed knoxjeffrey closed 1 year ago

knoxjeffrey commented 1 year ago

I think this may have come from the most recent update to dump hypertables and retention policies last, for compatibility with foreign keys.

The call to views(stream) unless defined?(Scenic) in turn calls timescale_continuous_aggregates(stream) and this all happens before timescale_hypertables(stream). This results in the schema.rb being out of order with continuous aggregates trying to be created before the hypertables.

knoxjeffrey commented 1 year ago

Is this just a case of moving views(stream) unless defined?(Scenic) to the end of the tables method in Timescaledb::SchemaDumper?

jonatas commented 1 year ago

Hi @knoxjeffrey! Good catch! I didn't check the order. Probably that is the case! I'll try to provide the update soon.

jonatas commented 1 year ago

Hi @knoxjeffrey ! please, review #44 if you have some time. I'd love to have an extra eye here as I did a little refactoring in the scenic part. Not sure if you use the lib or not.

knoxjeffrey commented 1 year ago

Hi @knoxjeffrey ! please, review #44 if you have some time. I'd love to have an extra eye here as I did a little refactoring in the scenic part. Not sure if you use the lib or not.

Hi @jonatas, that looks great, cheers for sorting that with the PR. Sadly I'm not using the Scenic gem yet though to give that part a quick test on my own codebase.