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

Fix running migrations on empty database #27

Merged
merged 1 commit into from Jul 22, 2016
Merged

Fix running migrations on empty database #27

merged 1 commit into from Jul 22, 2016

Conversation

philtr
Copy link
Contributor

@philtr philtr commented Jul 21, 2016

Good afternoon @jdtornow!

I couldn't run migrations on an empty database in Rails 5.

Running rails db:migrate gave me this error:

ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "admin_users" does not exist
LINE 8:                WHERE a.attrelid = '"admin_users"'::regclass
                                          ^
:               SELECT a.attname, format_type(a.atttypid, a.atttypmod),
                     pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
             (SELECT c.collname FROM pg_collation c, pg_type t
               WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation),
                     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
               WHERE a.attrelid = '"admin_users"'::regclass
                 AND a.attnum > 0 AND NOT a.attisdropped
               ORDER BY a.attnum

Commenting out include Challah::Userable fixed the issue, as well as the code attached to this pull request (does not exist is for postgres, could not find table is for sqlite).

I'm not married to this approach, but this was the offending code. If you have a better idea, I'd be happy to implement it.

Cheers!

@jdtornow
Copy link
Owner

Great find. Thanks a ton @philtr!

@jdtornow jdtornow merged commit 687f31c into jdtornow:master Jul 22, 2016
@philtr philtr deleted the custom-table-error branch July 27, 2016 16:04
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

Successfully merging this pull request may close these issues.

None yet

2 participants