Skip to content

Commit

Permalink
Merge pull request #2 from luizjhonata/fix/pg_retore-password
Browse files Browse the repository at this point in the history
fix(pg_restore-password): ensure correct password setting and options in pg_restore command
  • Loading branch information
rios0rios0 authored Sep 23, 2024
2 parents 8913570 + 1d55809 commit ec6cb7e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions database_sync/infrastructure/helpers/psql_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)}")
Expand Down

0 comments on commit ec6cb7e

Please sign in to comment.