Skip to content

Detect incorrect sequence owners

What does this MR do and why?

This commit builds upon !196044 (merged) and makes it possible to identify wrong owners for sequences.

Relates to #396878

References

Screenshots or screen recordings

Before After

How to set up and validate locally

I used my test database to avoid mucking with the real database:

  1. gdk psql -d gitlabhq_test -c "ALTER SEQUENCE zoekt_enabled_namespaces_id_seq OWNED BY web_hook_logs_daily.id"
  2. Run RAILS_ENV=test bin/rake gitlab:db:schema_checker:run. You should see this in the output:
------------------------------------------------------
The sequence public.zoekt_enabled_namespaces_id_seq has a different owner between structure.sql and database
Diff:
 CREATE SEQUENCE public.zoekt_enabled_namespaces_id_seq;
-ALTER SEQUENCE public.zoekt_enabled_namespaces_id_seq OWNED BY public.zoekt_enabled_namespaces.id
+ALTER SEQUENCE public.zoekt_enabled_namespaces_id_seq OWNED BY public.web_hook_logs_daily.id
  1. To restore the permissions, run: gdk psql -d gitlabhq_test -c "ALTER SEQUENCE public.zoekt_enabled_namespaces_id_seq OWNED BY public.zoekt_enabled_namespaces.id".
  2. RAILS_ENV=test bin/rake gitlab:db:schema_checker:run should no longer report this difference.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Stan Hu

Merge request reports

Loading