Replicache licensing client and server
Replicache license server and client
- brew install node (or brew equivalent)
- brew install heroku/brew/heroku
- heroku login
- optional but helpful: heroku autocomplete (and follow instructions)
- setup staging and production remote, run these commands in this order
1. heroku git:remote -a replicache-license-staging
2. git remote rename heroku staging
3. heroku git:remote -a replicache-license
- verify your remotes are correct
git remote -v
output should look like this:
```
heroku https://git.heroku.com/replicache-license.git (fetch)
heroku https://git.heroku.com/replicache-license.git (push)
origin git@github.com:rocicorp/licensing.git (fetch)
origin git@github.com:rocicorp/licensing.git (push)
staging https://git.heroku.com/replicache-license-staging.git (fetch)
staging https://git.heroku.com/replicache-license-staging.git (push)
- install Docker, run it, and configure
Settings to start when you log in (if you'd like)
- install postgres (for the psql cli, we use docker to actuallybrew install postgresql
run postgres) eg .env
- create a file in the root directory of the project with contents:`
`
DATABASE_URL="postgresql://testuser:testpw@localhost:5433/test"
Note: currently the same db is used by tests and when you run the server
locally. It's wiped each start/test but still, that's lame. See note in
docker-compose.yml and feel free to fix this.
- IMPORTANT: npm run start is for production. The prod db is persistentlynpm run start_local
running so doesn't need to be started. When running locally we need to start a local,
dockerized db; use to start up locally.
- connect to local db:
- npm run start_test_dbnpx prisma migrate dev
- source ./.env && psql $DATABASE_URL
- npx prisma migrate dev --name foo
- generate a migration:
- generates the new migrationnpx prisma generate
- generates the new clientnpm run start_test_db && npm run migrate_test_db
- dev migration compaction: to compact several new, locally applied migrations (do not do this in production, or if they have been applied in prod, unless you are resetting the prod db, which you probably should not be)
1. bring up the local db eg _prisma_migrations
2. remove the migration rows in the db from the tableprimsa/migrations
3. remove the migration dirs from npx prisma migrate dev
4. run which will generate a new migration AND RESET THE LOCAL DBheroku pg:backups:schedule --at '02:00 America/Los_Angeles' --app replicache-license
- BACKUPS
- automatic physical backups happen continuously and are saved for a week and can be restored using rollbacks
- logical backups happen every 24h at 2am pacific time and are kept for ~30 days ()heroku pg:backups:capture --app replicache-license
- capture a manual logical backup:
- heroku pg:backups --app replicache-license
- list logical backups:
- heroku pg:backups:restore
- restore from a logical backup:
-
We have two environments:
1. staging: app replicache-license-staging remote name 'staging'
2. production: app replicache-license remote name 'heroku'
Env vars, resources, etc. are NOT automatically reflected from prod to staging, you need to remember to add them both places eg:
``
heroku config:set --a replicache-license-staging FOO=bar
heroku config:set --a replicache-license FOO=bar
- to push from main: git push heroku main or git push staging maingit push
- to push from someother branch:
To deploy to staging:
`Copy prod db to the staging db:
heroku pg:copy replicache-license::DATABASE_URL DATABASE_URL -a replicache-license-staging --verbose
To deploy to production:
`
heroku maintenance:on -a replicache-license
git push heroku main
heroku maintenance:off -a replicache-license
`$3
It's often more convenient to just roll forward, but here are the useful commands:
`
heroku releases -a
heroku releases:info vXX -a
heroku rollback vXX -a
`$3
- to tail logs:
heroku logs --tail -a