Remove MySQL from default local development setup

https://3.basecamp.com/2914079/buckets/37331921/chats/9301300227@9334968661
This commit is contained in:
Jorge Manrubia
2025-12-01 12:46:37 +01:00
parent 6fb7de88d7
commit 12de564176
3 changed files with 29 additions and 57 deletions
+5 -4
View File
@@ -35,14 +35,15 @@ The full continuous integration tests can be run with:
### Database configuration
Fizzy supports SQLite (default, recommended for most scenarios) and MySQL. You can switch adapters with the `DATABASE_ADAPTER` environment variable.
Fizzy works on SQLite by default and supports MySQL too. You can switch adapters with the `DATABASE_ADAPTER` environment variable. For example, to develop locally against MySQL:
```sh
DATABASE_ADAPTER=mysql bin/rails
DATABASE_ADAPTER=mysql bin/test
bin/ci # Runs tests against both SQLite and MySQL
DATABASE_ADAPTER=mysql bin/setup --reset
DATABASE_ADAPTER=mysql bin/ci
```
The remote CI pipeline will run tests against both SQLite and MySQL.
### Outbound Emails
You can view email previews at http://fizzy.localhost:3006/rails/mailers.
+22 -47
View File
@@ -59,30 +59,6 @@ needs_seeding() {
}
setup_database() {
local adapter="$1"
local reset="$2"
local label="${adapter:+ ($adapter)}"
local env_cmd="${adapter:+env DATABASE_ADAPTER=$adapter}"
# When setting up sqlite in SAAS mode, we need to disable SAAS so that
# database.yml will use database.sqlite.yml instead of the fizzy-saas config.
# We also unset BUNDLE_GEMFILE so the standard Gemfile is used (without fizzy-saas).
if [ -n "$SAAS" ] && [ "$adapter" = "sqlite" ]; then
env_cmd="env DATABASE_ADAPTER=$adapter SAAS=false BUNDLE_GEMFILE="
fi
if [ "$reset" = "true" ]; then
step "Resetting the database$label" $env_cmd rails db:reset
else
step "Preparing the database$label" $env_cmd rails db:prepare
if needs_seeding; then
step "Seeding the database$label" $env_cmd rails db:seed
fi
fi
}
echo
gum style --foreground 153 " ˚ ∘ ∘ ˚ "
gum style --foreground 111 --bold " ∘˚˳°∘° 𝒻𝒾𝓏𝓏𝓎 °∘°˳˚∘ "
@@ -108,34 +84,33 @@ if [ -n "$SAAS" ]; then
saas_setup=$(bundle show fizzy-saas)/bin/setup
source "$saas_setup"
else
if ! nc -z localhost 3306 2>/dev/null; then
if docker ps -aq -f name=fizzy-mysql | grep -q .; then
step "Starting MySQL" docker start fizzy-mysql
else
step "Setting up MySQL" bash -c '
docker pull mysql:8.4
docker run -d \
--name fizzy-mysql \
-e MYSQL_ALLOW_EMPTY_PASSWORD=yes \
-p 3306:3306 \
mysql:8.4
echo "MySQL is starting… (it may take a few seconds)"
'
if [ "$DATABASE_ADAPTER" = "mysql" ]; then
if ! nc -z localhost 3306 2>/dev/null; then
if docker ps -aq -f name=fizzy-mysql | grep -q .; then
step "Starting MySQL" docker start fizzy-mysql
else
step "Setting up MySQL" bash -c '
docker pull mysql:8.4
docker run -d \
--name fizzy-mysql \
-e MYSQL_ALLOW_EMPTY_PASSWORD=yes \
-p 3306:3306 \
mysql:8.4
echo "MySQL is starting… (it may take a few seconds)"
'
fi
fi
fi
fi
reset_flag=""
[[ $* == *--reset* ]] && reset_flag="true"
if [ -n "$SAAS" ]; then
for adapter in saas sqlite; do
setup_database "$adapter" "$reset_flag"
done
if [[ $* == *--reset* ]]; then
step "Resetting the database" rails db:reset
else
for adapter in sqlite mysql; do
setup_database "$adapter" "$reset_flag"
done
step "Preparing the database" rails db:prepare
if needs_seeding; then
step "Seeding the database" rails db:seed
fi
fi
step "Cleaning up logs and tempfiles" rails log:clear tmp:clear
+2 -6
View File
@@ -19,13 +19,9 @@ CI.run do
if Fizzy.saas?
step "Tests: SaaS", "#{SAAS_ENV} bin/rails test"
step "Tests: SaaS System", "#{SAAS_ENV} #{SYSTEM_TEST_ENV} bin/rails test:system"
step "Tests: SQLite", "#{OSS_ENV} DATABASE_ADAPTER=sqlite bin/rails test"
step "Tests: SQLite System", "#{OSS_ENV} DATABASE_ADAPTER=sqlite #{SYSTEM_TEST_ENV} bin/rails test:system"
else
step "Tests: MySQL", "#{OSS_ENV} DATABASE_ADAPTER=mysql bin/rails test"
step "Tests: MySQL System", "#{OSS_ENV} DATABASE_ADAPTER=mysql #{SYSTEM_TEST_ENV} bin/rails test:system"
step "Tests: SQLite", "#{OSS_ENV} DATABASE_ADAPTER=sqlite bin/rails test"
step "Tests: SQLite System", "#{OSS_ENV} DATABASE_ADAPTER=sqlite #{SYSTEM_TEST_ENV} bin/rails test:system"
step "Tests: SQLite", "#{OSS_ENV} bin/rails test"
step "Tests: SQLite System", "#{OSS_ENV} #{SYSTEM_TEST_ENV} bin/rails test:system"
end
if success?