diff --git a/.github/workflows/build-and-push-bsky-aws.yaml b/.github/workflows/build-and-push-bsky-aws.yaml index 36b1aa23cb3..65c27574f38 100644 --- a/.github/workflows/build-and-push-bsky-aws.yaml +++ b/.github/workflows/build-and-push-bsky-aws.yaml @@ -3,6 +3,7 @@ on: push: branches: - main + - enable-migrations env: REGISTRY: ${{ secrets.AWS_ECR_REGISTRY_USEAST2_PACKAGES_REGISTRY }} USERNAME: ${{ secrets.AWS_ECR_REGISTRY_USEAST2_PACKAGES_USERNAME }} diff --git a/services/bsky/api.js b/services/bsky/api.js index ec38c55ae55..3868b060061 100644 --- a/services/bsky/api.js +++ b/services/bsky/api.js @@ -27,6 +27,15 @@ const { const main = async () => { const env = getEnv() assert(env.dbPrimaryPostgresUrl, 'missing configuration for db') + // separate db needed for more permissions + const migrateDb = new PrimaryDatabase({ + url: env.dbMigratePostgresUrl, + schema: env.dbPostgresSchema, + poolSize: 2, + }) + await migrateDb.migrateToLatestOrThrow() + await migrateDb.close() + const db = new DatabaseCoordinator({ schema: env.dbPostgresSchema, primary: { @@ -73,12 +82,12 @@ const main = async () => { algos, }) // separate db needed for more permissions - const migrateDb = new PrimaryDatabase({ + const viewMaintainerDb = new PrimaryDatabase({ url: env.dbMigratePostgresUrl, schema: env.dbPostgresSchema, poolSize: 2, }) - const viewMaintainer = new ViewMaintainer(migrateDb) + const viewMaintainer = new ViewMaintainer(viewMaintainerDb) const viewMaintainerRunning = viewMaintainer.run() const periodicModerationActionReversal = new PeriodicModerationActionReversal( @@ -96,7 +105,7 @@ const main = async () => { await bsky.destroy() viewMaintainer.destroy() await viewMaintainerRunning - await migrateDb.close() + await viewMaintainerDb.close() }) }