chore: set up DB import/export scripts #50
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This sets up import and export scripts for syncing DBs across environments. Some key benefits of this approach:
Closes #32
Validation DB
You can use this DB export to verify the import functionality.
db-export-2023-09-22T17-48-43_UTC.sql.gz
To Validate
SITE_URL=https:\\/\\/example.com
to your.env
file (this is used to replace absolute URLs based on environment)npm start
npm run backup-db
to save your current DB (confirm that a file is added tosql/backups
)npm run backup-db named-backup
to confirm that this uses the name you give it instead ofdb-backup-*
sql
foldernpm run import-db
, confirming that another backup is created before the import happens, and that the imported file is moved tosql/previous-imports
when the script is finished runningnpm run export-db
, confirming that a gzipped sql file is added tosql/exports
npm run export-db named-export
, confirming that the new export file uses the name you gave it instead ofdb-export-*
sql
folder and runnpm run import-db
to get your original DB back