Skip to content

Commit

Permalink
Merge pull request #49 from kellnerd/importer-dev-setup
Browse files Browse the repository at this point in the history
Update DB setup instructions for importer
  • Loading branch information
MonkeyDo authored Jul 17, 2024
2 parents 636fc40 + d044691 commit 91b625e
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions importer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,29 @@ If you don't want to use your full development database to test the unstable imp
The regular test database, which is used for unit tests, is not sufficient since important supplementary tables (such as `musicbrainz.language`) are empty.
This would lead to foreign key constraint violations, so you have to create a database which contains minimal data.

Assuming that you have appropriate dump files for a minimal database (plus empty import tables), copy them into the container and launch a shell for the container:
Assuming that you have appropriate dump files for a minimal database (plus empty import tables) locally, follow these instructions to use them.

```sh
docker cp local/minimal_test_database.sql postgres:/minimal_test_database.sql
docker cp local/minimal_test_database_import_patch.sql postgres:/minimal_test_database_import_patch.sql
docker exec -it postgres bash
```

Inside the container you can create the database and execute the SQL files to seed it:
Create the database inside your `postgres` container and execute the SQL files to seed it:

```sh
psql -c "CREATE DATABASE bookbrainz_min;" -U bookbrainz
psql -f minimal_test_database.sql -d bookbrainz_min -U bookbrainz
psql -f minimal_test_database_import_patch.sql -d bookbrainz_min -U bookbrainz
docker exec postgres psql -c "CREATE DATABASE bookbrainz_min;" -U bookbrainz
cat local/minimal_test_database.sql | docker exec -i postgres psql -U bookbrainz -d bookbrainz_min

# Add support for series entities if the minimal DB dump does not have them.
cat sql/migrations/series/up.sql | docker exec -i postgres psql -U bookbrainz -d bookbrainz_min
cat sql/migrations/series-identifiers/up.sql | docker exec -i postgres psql -U bookbrainz -d bookbrainz_min
cat sql/migrations/series-achievement/up.sql | docker exec -i postgres psql -U bookbrainz -d bookbrainz_min

cat local/minimal_test_database_import_patch.sql | docker exec -i postgres psql -U bookbrainz -d bookbrainz_min

# Other migrations which might be missing from the minimal DB dump.
# Apply them to avoid unrelated errors while browsing the website.
cat sql/migrations/user-collection/up.sql | docker exec -i postgres psql -U bookbrainz -d bookbrainz_min
cat sql/migrations/2023-05-29-user_privileges/up.sql | docker exec -i postgres psql -U bookbrainz -d bookbrainz_min
cat sql/migrations/2023-05-29-admin_logs/up.sql | docker exec -i postgres psql -U bookbrainz -d bookbrainz_min
cat sql/migrations/relationship-attributes/up.sql | docker exec -i postgres psql -U bookbrainz -d bookbrainz_min
# CritiqueBrainz OAuth
cat sql/migrations/2022-07-19/up.sql | docker exec -i postgres psql -U bookbrainz -d bookbrainz_min
```

Do not forget to change the target database to `bookbrainz_min` in your `config/config.json` file.

0 comments on commit 91b625e

Please sign in to comment.