laravel-postgresql-enhanced: timescaledb hypertable causes migrate:fresh error

Hey Tobias,

I’m just now playing around with the timescaledb support and noticed that I can’t seem to use the migrate:fresh command when there is a hypertable. This is the error I get:

ERROR:  cannot drop a hypertable along with other objects

In this particular project I already have a custom composer reset script, so just added a DROP TABLE command in there before calling migrate:fresh, which works fine.

Anyways, great work!

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (15 by maintainers)

Commits related to this issue

Most upvoted comments

Those PostGIS views should probably be on a whiteliste within Laravel - are there many? Maybe I can work on a fix within Laravel. And yeah, that views are not ignored is an oversight by Laravel. I’ll add that to my package and will PR a change to Laravel.

It’s these here (the raster ones are actually from pgrouting):

raster_columns
geometry_columns
geography_columns
raster_overviews

I guess that pg_stat_statements and pg_stat_statements_info would also need to be in that whitelist.

Its now working as expected with release 2.3.1. But you have to use migrate:fresh --drop-views if you use continuous aggregates - somehow the cagg is not always deleted when deleting a hypertable with cascade.

I’ve been using it in my workaround and it works like a charm 😉

Nice idea. Haven’t tested whether it works on continous aggregates or hypertables.

Its possible to fix this. The db:wipe command executes dropAllTables() on the SchemaBuilder. And that logic can be overwritten in this PG driver. So normal tables and hypertables would be dropped in different commands.

But its more complicated than this:

  • Are foreign keys with hypertables supported? Don’t really know. Never tried it.
  • Continous aggregates would be dropped with dropAllViews() is that one working or does it also need special behaviour?
  • Do we have to implement logic to calculate a dropping order? Argh. Topological sorting is great for that but a lot of code is needed to determine which things needs to be dropped before other things.