Skip to content

Commit

Permalink
fix v2 setup with postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcEgliP committed Jul 10, 2024
1 parent 3f647d2 commit df92e70
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions bin/hit/db/console
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
#!/usr/bin/bash

docker compose exec postgres bash -c '
psql -U root -d hitobito_development
psql -U hitobito -d hitobito_development
'
17 changes: 15 additions & 2 deletions bin/hit/test/env
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,35 @@ TEST_DB_NAME="hitobito_test_$HIT_TEST_ENV"

echo "Starting test env for: $HIT_TEST_ENV"

apply_core_db_migrations() {
docker compose run --rm \
--workdir=/usr/src/app/hitobito \
-e RAILS_ENV=test \
-e RAILS_TEST_DB_NAME=$TEST_DB_NAME \
-e RAILS_DB_NAME=$TEST_DB_NAME \
-e SKIP_INIT=1 \
rails_test \
bundle exec "rake db:migrate"
}

# reset/create mysql db
setup_test_db $TEST_DB_NAME

if [[ "$HIT_TEST_ENV" == "core" ]]; then
PREPARE_RAILS_SPEC_CMD="rails db:migrate"
PREPARE_RAILS_SPEC_CMD="rake db:migrate"
WORKDIR=/usr/src/app/hitobito
else
PREPARE_RAILS_SPEC_CMD="cp ../hitobito/Gemfile.lock . && rake app:db:migrate app:wagon:migrate"
PREPARE_RAILS_SPEC_CMD="cp ../hitobito/Gemfile.lock . && rake app:wagon:migrate"
WORKDIR="/usr/src/app/hitobito_$HIT_TEST_ENV"
apply_core_db_migrations
fi

# run test env
docker compose run --rm \
--workdir=$WORKDIR \
-e RAILS_ENV=test \
-e RAILS_TEST_DB_NAME=$TEST_DB_NAME \
-e RAILS_DB_NAME=$TEST_DB_NAME \
-e SKIP_INIT=1 \
rails_test \
bundle exec "$PREPARE_RAILS_SPEC_CMD && bash"
2 changes: 1 addition & 1 deletion bin/hit/test/test_db_setup
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ psql_sql_cmd() {
}

setup_test_db() {
psql_sql_cmd "DROP DATABASE IF EXISTS $1;"
psql_sql_cmd "DROP DATABASE IF EXISTS $1 WITH (FORCE);"
psql_sql_cmd "CREATE DATABASE $1;"
}
11 changes: 0 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,6 @@ services:
- sphinx_indexes:/opt/sphinx/indexes
profiles: [sphinx]

# db:
# image: mysql:5.7
# command:
# - --sort_buffer_size=2M
# - --character-set-server=utf8mb4
# - --collation-server=utf8mb4_general_ci
# - --innodb-lock-wait-timeout=2
# - --max_allowed_packet=3250585600
# env_file: ./docker/mysql.env

postgres:
image: postgres:16
env_file: ./docker/postgres.env
Expand Down Expand Up @@ -121,7 +111,6 @@ services:

volumes:
postgres:
# db:
seed:
hitobito_bundle:
external: true
Expand Down

0 comments on commit df92e70

Please sign in to comment.