Last active
November 9, 2019 21:14
-
-
Save ffmit/f45c9ddbfa44c290afe0203010db72ee to your computer and use it in GitHub Desktop.
Laravel - Add view with migration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function up() | |
{ | |
// Delete the view in case of "php artisan:fresh", to workaround bug | |
DB::statement('DROP VIEW IF EXISTS userItemlistsView'); | |
// Create views | |
DB::statement("CREATE VIEW userItemlistsView AS | |
SELECT | |
U.NAME AS USER_NAME, | |
I.NAME AS LIST_NAME | |
FROM | |
USERS U, | |
ITEMLISTS I | |
WHERE | |
1 = 1 | |
AND U.ID = I.USER_ID"); | |
} | |
public function down() | |
{ | |
// Nothing needed here, see workaround above | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment