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

前端 未结 6 1568
渐次进展
渐次进展 2021-02-19 05:22

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

$ heroku          


        
相关标签:
6条回答
  • 2021-02-19 05:29

    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

    0 讨论(0)
  • 2021-02-19 05:32

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

    heroku run php artisan
    
    0 讨论(0)
  • 2021-02-19 05:37

    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".

    0 讨论(0)
  • 2021-02-19 05:47

    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

    0 讨论(0)
  • 2021-02-19 05:47

    If you have multiple applications on a heroku server, you can do:

    heroku run bash -a application-name
    

    this will open a bash container for that specific application, and you can run any command inside this container. i.e

    php artisan migrate:refresh --seed
    

    Obviously you'll first need to make sure that you are already logged in to the heroku cli.

    0 讨论(0)
  • 2021-02-19 05:50

    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

    0 讨论(0)
提交回复
热议问题