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
- fix: db wipe support for materialized views and timescale (resolves #104) — committed to KornaLaravel/laravel-postgresql-enhanced by tpetry 2 years ago
- fix: improved handling of hypertables/views not to drop (resolves #104) — committed to KornaLaravel/laravel-postgresql-enhanced by tpetry 2 years ago
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):
I guess that
pg_stat_statementsandpg_stat_statements_infowould 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-viewsif 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:wipecommand executesdropAllTables()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:
dropAllViews()is that one working or does it also need special behaviour?