Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use php artisan migrate command of Laravel4 in Heroku?

I am suing Heroku dev plan for creating database using PostgreSQL. Database is created in Heroku. After running heroku pg:info command

$ heroku pg:info
=== HEROKU_POSTGRESQL_XXX_URL
Plan:        Hobby-dev
Status:      available
Connections: 1
PG Version:  9.3.1
Created:     2013-11-27 04:00 UTC
Data Size:   6.4 MB
Tables:      0
Rows:        0/10000 (In compliance)
Fork/Follow: Unsupported
Rollback:    Unsupported

Result shows zero tables, which is correct.

In my local machine tables are created by using following command which are supported in Laravel4 framework.

php artisan migrate

php artisan db:seed

But it seems like I cannot run this command in heroku to create table and dump data. Please tel me how can I create a copy of my local database in Heroku.

Thanks all

like image 455
niran Avatar asked Nov 27 '13 13:11

niran


People also ask

How does php artisan migrate work?

php artisan migrate:reset reverses all migration, unlike :rollback . php artisan migrate:fresh is used when we want a fresh or new installation of our database. It deletes all the existing tables of the database and runs the migrate command.

Which Artisan command is used to migrate a database?

To create a new migration, you can run the make:migration Artisan command and that will bootstrap a new class on your Laravel application, in the database/migrations folder.


2 Answers

It took a little digging, but I was able to use it by running this command:

heroku run /app/php/bin/php /app/www/artisan migrate

So the lesson I learned was this: prefix all remote artisan commands with heroku run /app/php/bin/php /app/www/artisan

like image 38
Aaron Gustafson Avatar answered Dec 22 '22 02:12

Aaron Gustafson


with the new official php buildpack you just run

$ heroku run bash
$ php artisan migrate

or just

$ heroku run php artisan migrate

And if you want the migration to happen every time you deploy via git then add "php artisan migrate" to to composer.json in the "post-update-cmd" section of "scripts".

like image 53
dwenaus Avatar answered Dec 22 '22 01:12

dwenaus