I don’t know why a new table was created with
Not sure what’s happening here, any ideas?
Is there a chance you could create a GitHub repo with a sample application with steps on how to reproduce this bug?
If that’s not possible, could you describe how you created the migrations or what command(s) you ran? Is this error reproducible? As in, if you reset (roll back db for example) your changes, can this same error be reproduced or is it a one off?
I dug in a little deeper, and I think Rails is doing some database inspection.
I think it’s creating this inv_products_XYZ table because I’m actually loading data into this database from a prior pg_dump.
After I run a
rake db:migrate it seems to create that table. Nowhere in my code is there a migration which is creating this table, it just somehow gets into my
schema.rb file. I think via inspection/introspection or whatever. Rails must see the table exists already, and adds the corresponding Ruby code in
schema.rb to create that table.
I can’t provide code in this case, since it’s a proprietary codebase.
That is correct.
schema.rb has nothing to do with migrations (despite the superficial connections).
It is always a record of the schema of the database. If you use tools other than migrations (e.g. the
pg* command line tools) to make changes to the database schema they will always be reflected in
schema.rb after you run migrations. This isn’t becuase of the migrations, but because there is a task triggered after the migrations task runs which translates the complete DB schema into