Laravel部署失败,因为迁移

时间:2018-04-05 10:37:47

标签: php laravel bitbucket bitbucket-pipelines

这是我的部署脚本的一部分,但遗憾的是失败了:

image: php:7-fpm

pipelines:
  branches:  # Pipelines that run automatically on a commit to a branch
    staging:
      - step:
          script:
            - apt-get update && apt-get install -y unzip python-dev git
            - apt-get install -qy git curl libmcrypt-dev mysql-client
            - docker-php-ext-install mcrypt && docker-php-ext-install pdo_mysql
            - ./install-composer.sh
            - composer install
            - export APP_ENV=QA
            - export S3_ACCESS_KEY_ID=AAAAA
            - export S3_BUCKET_ASSETS=AAAAA
            - export S3_DEFAULT_CDN_BASE=AAAAA
            - export S3_REGION=eu-west-1
            - export S3_SECRET_ACCESS_KEY=AAAAA
            - curl -O https://bootstrap.pypa.io/get-pip.py
            - python get-pip.py
            - pip install awsebcli --upgrade
            - eb init this-data -r eu-central-1 -p PHP
            - eb setenv APP_ENV=QA JS_PATH=AAAA IMAGES_PATH=AAAAA FONTS_PATH=AAAA                - eb setenv SES_KEY=AAAAA
            - eb printenv
            - export CACHE_DRIVER=redis
            - export SESSION_DRIVER=redis
            - export DB_CONNECTION=mysql
            - php artisan migrate
            - php artisan serve
            - eb deploy this-staging-env
          services:
            - mysql

definitions:
      services:
              mysql:
                image: mysql
                environment:
                  MYSQL_DATABASE: 'thisdb'
                  MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
                  MYSQL_USER: 'thisuser'
                  MYSQL_PASSWORD: 'thispass'
                  MYSQL_HOST: 'rdsInstance'

出现的信息是:

php artisan migrate
  

Illuminate \ Database \ QueryException:找不到驱动程序(SQL:select * from information_schema.tables where table_schema = forge和table_name = migrations)     在/ opt / atlassian / pipelines / agent / build / vendor / laravel / framework / src / Illuminate /

1 个答案:

答案 0 :(得分:0)

我的解决方案是在.ebextensions / init.config中添加它:

container_commands:
    01initdb:
        command: "php artisan migrate"

这意味着migrate命令在部署后运行。