gpt4 book ai didi

github-actions - Github Actions Rails Postgres 数据库 "test"不存在

转载 作者:行者123 更新时间:2023-12-05 02:03:48 27 4
gpt4 key购买 nike

此 Github 操作在“Db create Migrate”步骤失败。

ActiveRecord::NoDatabaseError: FATAL: 数据库“test”不存在

我知道我可能不存在。我的目的是创造它。为什么没有创建?

name: Ruby
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
services:
db:
image: postgres:11@sha256:85d79cba2d4942dad7c99f84ec389a5b9cc84fb07a3dcd3aff0fb06948cdc03b
ports: ['5432:5432']
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis
ports: ['6379:6379']
options: --entrypoint redis-server

steps:
- uses: actions/checkout@v2
- name: Setup Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: 2.7
- name: Build and test with Rake
env:
RAILS_ENV: test
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
run: |
sudo apt-get -yqq install libpq-dev
gem install bundler
bundle install --jobs 4 --retry 3
- name: Db create Migrate
env:
DATABASE_URL: postgres://postgres:@localhost:5432/test
REDIS_URL: redis://localhost:6379/0
RAILS_ENV: test
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
run: |
bundle exec rails db:create
bundle exec rails db:migrate
bundle exec rails db:test:prepare
bundle exec rails test


最佳答案

尝试添加一个 POSTGRES_DB 环境变量:

services:
db:
image: postgres:11@sha256:85d79cba2d4942dad7c99f84ec389a5b9cc84fb07a3dcd3aff0fb06948cdc03b
ports: ['5432:5432']
env:
POSTGRES_DB: test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

关于github-actions - Github Actions Rails Postgres 数据库 "test"不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64897338/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com