Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permissions table not found during testing #888

Open
mkanoor opened this issue Jan 30, 2021 · 1 comment
Open

Permissions table not found during testing #888

mkanoor opened this issue Jan 30, 2021 · 1 comment

Comments

@mkanoor
Copy link
Contributor

mkanoor commented Jan 30, 2021

Intermittently during running specs the Permissions table goes missing. The Permissions table is implemented in this migration as sql enum

This table is not exported in the db/schema.rb and during tests when the db is cleared its possible that this table would be missing.

Failure/Error: access_control_permissions { [create(:access_control_permission, :has_read_permission)] }
      
      ActiveRecord::StatementInvalid:
        PG::UndefinedTable: ERROR:  relation "permissions" does not exist
        LINE 8:                WHERE a.attrelid = '"permissions"'::regclass
                                                  ^
        :               SELECT a.attname, format_type(a.atttypid, a.atttypmod),
                             pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
                             c.collname, col_description(a.attrelid, a.attnum) AS comment
                        FROM pg_attribute a
                        LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
                        LEFT JOIN pg_type t ON a.atttypid = t.oid
                        LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
                       WHERE a.attrelid = '"permissions"'::regclass
                         AND a.attnum > 0 AND NOT a.attisdropped
                       ORDER BY a.attnum
      # ./spec/factories/access_control_entry.rb:16:in `block (4 levels) in <top (required)>'
      # ./spec/models/access_control_entry_spec.rb:8:in `block (3 levels) in <top (required)>'
      # ./spec/models/access_control_entry_spec.rb:12:in `block (4 levels) in <top (required)>'
      # ------------------
      # --- Caused by: ---
      # PG::UndefinedTable:
      #   ERROR:  relation "permissions" does not exist
      #   LINE 8:                WHERE a.attrelid = '"permissions"'::regclass
      #                                             ^
      #   ./spec/factories/access_control_entry.rb:16:in `block (4 levels) in <top (required)>'
@hsong-rh
Copy link
Contributor

hsong-rh commented Feb 2, 2021

bin/rails db:drop db:create db:migrate RAILS_ENV=test should resolve this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants