4

How do i check, when php artisan migrate is working, has database view?

Something like this,

if(Schema::hasView('search_content')) {
    return;
}
2
  • Try checking with hasTable only. Commented Sep 16, 2019 at 14:55
  • 1
    By using DB::statement("SHOW FULL TABLES IN database_name WHERE TABLE_TYPE LIKE 'VIEW';"); something like this. Commented Sep 16, 2019 at 14:58

2 Answers 2

4

Try this,

\DB::select("SELECT * FROM information_schema.VIEWS WHERE TABLE_NAME='table_name'")

Sign up to request clarification or add additional context in comments.

Comments

0

It may not apply to everyone's needs buy I found myself into a similar problem after upgrading from Laravel 5.6 to 6.

I had a Mysql VIEW migration that needed to updated.

I'd also rather have a hasView() but instead of using hasTable() I am updating the full Mysql View statement using MySql CREATE OR REPLACE VIEW so that the view get overriden anyway.

CREATE or REPLACE VIEW full statement...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.