Skip to content

Commit

Permalink
fix(sync): id sequence (#1250)
Browse files Browse the repository at this point in the history
  • Loading branch information
gunar authored Nov 4, 2022
1 parent 3a2b262 commit 2e61ccc
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/sync-staging-db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ jobs:
working-directory: infrastructure/application
env:
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
- run: |
echo "PG_URL=$(pulumi stack output --stack staging --show-secrets dbRootUrl)" >> $GITHUB_ENV
working-directory: infrastructure/data
env:
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
- uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
Expand Down
2 changes: 1 addition & 1 deletion api.planx.uk/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const getMostRecentPublishedFlow = async (id: string) => {
`
query GetMostRecentPublishedFlow($id: uuid!) {
flows_by_pk(id: $id) {
published_flows(limit: 1, order_by: { created_at: desc }) {
published_flows(limit: 1, order_by: { id: desc }) {
data
}
}
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ services:
HASURA_GRAPHQL_URL: http://hasura-proxy:7000/v1/graphql
HASURA_GRAPHQL_ENDPOINT: http://hasura-proxy:7000/
PRODUCTION_GRAPHQL_URL: 'https://hasura.editor.planx.uk/v1/graphql'
PG_URL: postgres://${PG_USERNAME}:${PG_PASSWORD}@postgres/${PG_DATABASE}
api:
restart: unless-stopped
build:
Expand Down
1 change: 1 addition & 0 deletions scripts/seed-database/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ RUN npm install -g hasura-cli
WORKDIR /scripts/
RUN npm install -g [email protected]
COPY pnpm-lock.yaml .
RUN apk add postgresql-client

RUN pnpm fetch --prod
ADD . .
Expand Down
1 change: 1 addition & 0 deletions scripts/seed-database/fix_id_sequence.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT setval('published_flows_id_seq', max(id)) FROM published_flows;
5 changes: 4 additions & 1 deletion scripts/seed-database/seed-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ hasura seeds apply

cd /scripts/

pnpm upsert-flows
pnpm upsert-flows

echo "Fixing published_flows id sequence"
psql "${PG_URL}" < "./fix_id_sequence.sql"

0 comments on commit 2e61ccc

Please sign in to comment.