Skip to content

Commit

Permalink
Ozone: add option to run migrations from service entrypoint (bluesky-…
Browse files Browse the repository at this point in the history
…social#2789)

ozone: add option to run migrations from service entrypoint
  • Loading branch information
devinivy authored Sep 5, 2024
1 parent c46dc91 commit f7cbfa4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions services/ozone/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const {
envToSecrets,
readEnv,
httpLogger,
Database,
} = require('@atproto/ozone')

const main = async () => {
Expand Down Expand Up @@ -62,6 +63,16 @@ const main = async () => {
? new MultiImageInvalidator(imgInvalidators)
: imgInvalidators[0]

const migrate = process.env.OZONE_DB_MIGRATE === '1'
if (migrate) {
const db = new Database({
url: cfg.db.postgresUrl,
schema: cfg.db.postgresSchema,
})
await db.migrateToLatestOrThrow()
await db.close()
}

const ozone = await OzoneService.create(cfg, secrets, { imgInvalidator })

await ozone.start()
Expand Down

0 comments on commit f7cbfa4

Please sign in to comment.