diff --git a/.github/workflows/build-docker-images.yml b/.github/workflows/build-docker-images.yml index 4da34f1a2..647e2c502 100644 --- a/.github/workflows/build-docker-images.yml +++ b/.github/workflows/build-docker-images.yml @@ -1,4 +1,4 @@ -name: Run tests +name: Build Docker Images on: push: branches: diff --git a/.github/workflows/lint-migrations.yml b/.github/workflows/lint-migrations.yml new file mode 100644 index 000000000..c1587f696 --- /dev/null +++ b/.github/workflows/lint-migrations.yml @@ -0,0 +1,21 @@ +name: Lint Migrations + +on: + pull_request: + paths: + - 'packages/db/migrations/**' + +jobs: + lint_migrations: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Find modified migrations + run: | + modified_migrations=$(git diff --diff-filter=d --name-only origin/$GITHUB_BASE_REF...origin/$GITHUB_HEAD_REF 'packages/db/migrations/*.do.*.sql') + echo "$modified_migrations" + echo "::set-output name=file_names::$modified_migrations" + id: modified-migrations + - uses: sbdchd/squawk-action@v1 + with: + pattern: ${{ steps.modified-migrations.outputs.file_names }} diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index 88ea58232..572408202 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -77,6 +77,7 @@ jobs: PG_PASSWORD: postgres PG_DB: omnivore_test PGPASSWORD: postgres # This is required for the psql command to work without a password prompt + PG_EXTRA_OPTIONS: '-c lock_timeout=2000' - name: TypeScript Build and Lint run: | source ~/.nvm/nvm.sh diff --git a/packages/db/migrate.ts b/packages/db/migrate.ts index 97d723acd..f4867b3fa 100755 --- a/packages/db/migrate.ts +++ b/packages/db/migrate.ts @@ -39,6 +39,7 @@ const getEnv = (): DBEnv => { database: database || 'omnivore', username, password, + options: process.env.PG_EXTRA_OPTIONS, } return config diff --git a/packages/db/migrations/0177.do.public_item.sql b/packages/db/migrations/0177.do.public_item.sql index 6a8e27f27..a2e2d8f48 100755 --- a/packages/db/migrations/0177.do.public_item.sql +++ b/packages/db/migrations/0177.do.public_item.sql @@ -87,6 +87,4 @@ ALTER TABLE omnivore.library_item ADD COLUMN topic LTREE, ADD COLUMN score FLOAT; -CREATE INDEX library_item_topic_idx ON omnivore.library_item USING GIST (topic); - COMMIT; diff --git a/packages/db/migrations/0177.undo.public_item.sql b/packages/db/migrations/0177.undo.public_item.sql index cb068a36c..966be690a 100755 --- a/packages/db/migrations/0177.undo.public_item.sql +++ b/packages/db/migrations/0177.undo.public_item.sql @@ -9,8 +9,6 @@ DROP TABLE omnivore.public_item_stats; DROP TABLE omnivore.public_item; DROP TABLE omnivore.public_item_source; -DROP INDEX omnivore.library_item_topic_idx; - ALTER TABLE omnivore.library_item DROP COLUMN seen_at, DROP COLUMN digested_at, diff --git a/packages/db/migrations/0183.do.library_item_topic_idx.sql b/packages/db/migrations/0183.do.library_item_topic_idx.sql new file mode 100755 index 000000000..6660ad596 --- /dev/null +++ b/packages/db/migrations/0183.do.library_item_topic_idx.sql @@ -0,0 +1,5 @@ +-- Type: DO +-- Name: library_item_topic_idx +-- Description: Create index on topic column in library_item table + +CREATE INDEX CONCURRENTLY IF NOT EXISTS library_item_topic_idx ON omnivore.library_item USING GIST (topic); diff --git a/packages/db/migrations/0183.undo.library_item_topic_idx.sql b/packages/db/migrations/0183.undo.library_item_topic_idx.sql new file mode 100755 index 000000000..c5a065551 --- /dev/null +++ b/packages/db/migrations/0183.undo.library_item_topic_idx.sql @@ -0,0 +1,9 @@ +-- Type: UNDO +-- Name: library_item_topic_idx +-- Description: Create index on topic column in library_item table + +BEGIN; + +DROP INDEX IF EXISTS omnivore.library_item_topic_idx; + +COMMIT;