diff --git a/importer/README.md b/importer/README.md index f069596..2fdf228 100644 --- a/importer/README.md +++ b/importer/README.md @@ -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.