Merge pull request #1764 from basecamp/oss-sqlite

Remove MySQL from default local development setup
This commit is contained in:
Jorge Manrubia
2025-12-01 13:16:06 +01:00
committed by GitHub
3 changed files with 30 additions and 55 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 with 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.
+23 -45
View File
@@ -58,27 +58,20 @@ needs_seeding() {
fi
}
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
oss_mysql_setup() {
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
}
@@ -108,34 +101,19 @@ 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)"
'
fi
if [ "$DATABASE_ADAPTER" = "mysql" ]; then
oss_mysql_setup
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?