Migrate DB
Firestore/Realtime DB migration scripts.
Auth
Download a service account JSON key for the project you want to interact with, and put it in ./keys/<project-id>.json
(like keys/illust-marketplace-staging.json
).
Run
To run a script, use run.sh
to set the correct service account and projectId. Example to run a backup of the whole database:
Backups
It's smart to run a backup of the database before making a major change. You can run ./run.sh illust backup-database
to download a full backup of the prod database to src/data/backup.json
. Then you may want to copy that file to src/data/backup-YYYY-MM-DD.json
, so you keep a copy, and perhaps upload it to Google Drive. All files in src/data
are gitignored, so this won't be committed.
Also note that if you add a new database table, you should add the table to the backup-database.ts
script, so it will get downloaded in the next backup.
Finally, note that many of the migration scripts rely on first backing up the database, and then looping through the local copy of the data to make changes. This pattern makes it easier to develop a script without fetching data many times.
Last updated