tpetry / laravel-postgresql-enhanced

Support for many missing PostgreSQL specific features
MIT License
773 stars 31 forks source link

Allow defining columns of the view #66

Closed bastien-phi closed 1 year ago

bastien-phi commented 1 year ago

When creating a view, it could be useful to define the columns before the query.

create or replace view "test_623632" ("column_449989") as select random()

Real-life use case of this : I want a view to be created as a union query of different tables. Some columns have to be renamed, other defined with static values, ... It would be possible to do it without defining the columns before the query but the syntax of the query would become very heavy.

This syntax is borrowed from staudenmeir/laravel-migration-views (https://github.com/staudenmeir/laravel-migration-views) but the two packages are not compatible.

tpetry commented 1 year ago

The materialized view would need the columns param too to be consistent with the other ones.

bastien-phi commented 1 year ago

Here it is !

tpetry commented 1 year ago

Thanks for your work Bastien, again. Its released as 0.32.0

bastien-phi commented 1 year ago

Always fun to contribute ! Actually, I needed this for my current project :sweat_smile: