#947 frontend: create row in private tables when not yet added.
Closed 4 years ago by dturecek. Opened 4 years ago by dturecek.
copr/ dturecek/copr database-dumps  into  master

@@ -9,7 +9,15 @@ 

  

  dump_dir=$1

  

- runuser -c 'pg_dump --exclude-table-data "*_private" coprdb' - postgres \

-     | runuser -c "gzip > $dump_dir/copr_db-$(date '+%Y-%m-%d_%H-%M').gz" - copr-fe \

+ (

+     runuser -c 'pg_dump --exclude-table-data "*_private" coprdb' - postgres

+     cat <<'EOF'

+ INSERT INTO public.user_private (mail, api_login, api_token, api_token_expiration, user_id)

+ SELECT '', '', '', '2000-01-01', id FROM public."user";

+ 

+ INSERT INTO public.copr_private (copr_id)

+ SELECT id FROM public.copr;

+ EOF

+ ) | runuser -c "gzip > $dump_dir/copr_db-$(date '+%Y-%m-%d_%H-%M').gz" - copr-fe

  

  find "$dump_dir" -name 'copr_db-*.gz' -mtime +1 -delete

When the private counterpart to user or copr table doesn't exist
yet (e.g. after importing public db dump), create the rows when
logging in or accessing settings/integrations.

Fixes: #912

Even though this solution works, I don't like it very much, so I'd like to find a better one.

Metadata Update from @dturecek:
- Pull-request tagged with: wip

4 years ago

rebased onto 85ca4ade72b86fbb0dcba5a00b414c3fb97d1cff

4 years ago

As per discussion with @praiskup I modified the script to put two queries at the end of the dump that will fill the private tables with needed data (ids of users/coprs in the public tables).

Metadata Update from @dturecek:
- Pull-request untagged with: wip

4 years ago

rebased onto e5c77c1

4 years ago

Pull-Request has been closed by dturecek

4 years ago