diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..8740f29 --- /dev/null +++ b/.env.example @@ -0,0 +1,12 @@ +PRODUCTION_HOST=localhost +PRODUCTION_PORT=5432 +PRODUCTION_USERNAME=postgres +PRODUCTION_PASSWORD=postgres + +DEVELOPMENT_HOST=localhost +DEVELOPMENT_PORT=5432 +DEVELOPMENT_USERNAME=postgres +DEVELOPMENT_PASSWORD=postgres + +SYNC_TARGETS=db1,db2 +CONFIG_FILE_PATH=./config.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dee465..5aa8d06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,12 @@ Exceptions are acceptable depending on the circumstances (critical bug fixes tha ### Added - added GitHub pipelines code provided by pipelines project +- added `.env.example` file to guide new users on the required environment variables for setting up their `.env` file + +## Fixed + +- ensured the correct password is set before executing the `pg_restore` command by adding `self.__set_pgpassword()` in the `restore` method +- added `--no-owner` and `--no-acl` options in the `pg_restore` command to avoid restoring ownership and access control lists, resolving errors during database restoration ### Changed diff --git a/database_sync/infrastructure/helpers/psql_connector.py b/database_sync/infrastructure/helpers/psql_connector.py index 4ea3e9f..81ee007 100644 --- a/database_sync/infrastructure/helpers/psql_connector.py +++ b/database_sync/infrastructure/helpers/psql_connector.py @@ -56,6 +56,7 @@ def dump(self, database: str, extend_command: list[str], redirect_to: str) -> bo return success def restore(self, database: str) -> int: + self.__set_pgpassword() command = [ "pg_restore", "-h", @@ -66,6 +67,8 @@ def restore(self, database: str) -> int: self.__settings.user, "-d", database, + "--no-owner", + "--no-acl", f"{database}.dump", ] self.__logger.info(f"executing command: {' '.join(command)}")