Skip to content

Commit

Permalink
custom seed job
Browse files Browse the repository at this point in the history
  • Loading branch information
achauve committed Sep 7, 2023
1 parent ab2a546 commit bb3b9e1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
19 changes: 15 additions & 4 deletions .kontinuous/env/dev/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 0 additions & 20 deletions seeds.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit bb3b9e1

Please sign in to comment.