I am aware that there's a question similar to this, with postgres, but that uses raw Sql, and I am looking for a laravel migration friendly ORM solution. That's why this question is different. This may in the long run be the right answer but I thought I'd pose it to the community.
Sometimes my data set is a table, sometimes it's view. If we are running the unit test build, this exists as a table, but everywhere else it's a view.
This is what I got. Obviously this is not idea. It's not an accurate conditional. While it may execute when I want it to, It's not a true check if a view exists. I want a way to check the postgres schema to see if a view exists.
if ('dev' === env('APP_ENV') || 'production' === env('APP_ENV')) {
$sql = 'DROP VIEW IF EXISTS backend.friends';
DB::statement($sql);
} else {
Schema::dropIfExists('backend.friends');
}
Mostly I need a conditional. Something like this. Any ideas good stack friends?
if (backed.friends) == view {
$sql = 'DROP VIEW IF EXISTS backend.partners';
} else {
Schema::dropIfExists('backend.friends');
}
Thank you!