How to use php artisan migrate command of Laravel4

2019-04-05 08:42发布

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

5条回答
在下西门庆
2楼-- · 2019-04-05 09:03

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

查看更多
Explosion°爆炸
3楼-- · 2019-04-05 09:06

This line will give you access to all laravel artisan commands:

heroku run php artisan
查看更多
Juvenile、少年°
4楼-- · 2019-04-05 09:08

with the new official php build pack 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".

查看更多
我欲成王,谁敢阻挡
5楼-- · 2019-04-05 09:14

Here is a complete example, and will solve "nothing to migrate issue" that comes in for Heroku,

heroku run php artisan migrate --path=database/migrations --app application-name

application-name is your Heroku APP name

查看更多
对你真心纯属浪费
6楼-- · 2019-04-05 09:22

I would recommend to run migration as a part of build process. As it should be. Take a look at https://github.com/lifekent/heroku-buildpack-laravel. Official build pack with easy yo use support for running artisan commands

查看更多
登录 后发表回答