From bb3b9e18a208f85c2d2d50f1a24db7edaa1b2ff8 Mon Sep 17 00:00:00 2001 From: Adrien Chauve Date: Thu, 7 Sep 2023 14:54:37 +0200 Subject: [PATCH] custom seed job --- .kontinuous/env/dev/values.yaml | 19 +++++++++++++++---- seeds.sql | 20 -------------------- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/.kontinuous/env/dev/values.yaml b/.kontinuous/env/dev/values.yaml index 8959e2774..b6f576757 100644 --- a/.kontinuous/env/dev/values.yaml +++ b/.kontinuous/env/dev/values.yaml @@ -20,9 +20,20 @@ indice: jobs: runs: seed-db: - use: seed-db ~needs: [pg] - with: - seedPath: ./seeds.sql - #pgSecretName: pg-superuser + retry: 3 + checkout: true + image: ghcr.io/socialgouv/docker/psql:7.0.0 + envFrom: + - secretRef: + name: "{{ $.Values.global.pgSecretName }}" + run: | + if [[ psql -c "\dt public.alembic_version" ]] + then + echo "Data already loaded" + else + echo "Init database" + psql -b /workspace/seeds.sql + fi + diff --git a/seeds.sql b/seeds.sql index 8e9712a33..9dbf6957a 100755 --- a/seeds.sql +++ b/seeds.sql @@ -8,26 +8,6 @@ -- Started on 2023-08-25 19:11:49 --- abort script if data already loaded -do -$$ -declare - l_count integer; -begin - - select count(*) - into l_count - from information_schema.tables - where table_name = 'newsletter' - and table_schema = 'public'; - - if (l_count > 0) then - raise exception 'Data already loaded!'; - end if; -end; -$$ - - SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0;