From cb5e0d358dcdc524c98a65e19b401689b229618f Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Thu, 24 Oct 2024 21:19:42 +1100 Subject: [PATCH] DEV: Run db:create in Docker dev container (#29295) When attempting to [set up the Docker development environment](https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009), I was seeing the following error when running `d/boot_dev --init`: ``` ActiveRecord::NoDatabaseError: We could not find your database: discourse_development. Available database configurations can be found in config/database.yml. (ActiveRecord::NoDatabaseError) ``` Running `db:create` before the `db:migrate` fixed this issue for me. It appears to be safe to run `db:create` even if the database already exists, running `d/rake db:create` locally shows an info message at the database already exists, but doesn't exit with an error. --- bin/docker/boot_dev | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/docker/boot_dev b/bin/docker/boot_dev index 89fdcf6f653..0e9c5ce7d5d 100755 --- a/bin/docker/boot_dev +++ b/bin/docker/boot_dev @@ -122,6 +122,7 @@ echo "pnpm install..." if [ "${initialize}" = "initialize" ]; then echo "Migrating database..." + "${SCRIPTPATH}/rake" db:create "${SCRIPTPATH}/rake" db:migrate RAILS_ENV=test "${SCRIPTPATH}/rake" db:migrate