Skip to content

Commit f4fa870

Browse files
committed
store/postgres: make store_entity_count migration more robust
In staging, we had an entry in `deployment_schemas` where the underlying Postgres schema did not exist, causing the migration to fail. To make this more robust, we will skip these entries. The issue was most likely caused by manual changes in staging.
1 parent a78d45f commit f4fa870

File tree

1 file changed

+5
-1
lines changed
  • store/postgres/migrations/2019-05-03-164052_store_entity_count

1 file changed

+5
-1
lines changed

store/postgres/migrations/2019-05-03-164052_store_entity_count/up.sql

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ begin
2626

2727
-- Handle split entities tables
2828
for deployment in
29-
select * from deployment_schemas
29+
-- Join with pg_namespace to make sure we do not, under any
30+
-- circumstances, try to access a schema that was dropped for
31+
-- whatever reason
32+
select s.* from deployment_schemas s, pg_namespace n
3033
where subgraph != 'subgraphs'
34+
and s.name = n.nspname
3135
loop
3236
execute format('select count(*) from %I.entities', deployment.name)
3337
into entity_count;

0 commit comments

Comments
 (0)