[Rails/Postgres] DB migrate scripts break on references

Joe Tseng <[email protected]>
Newsgroups gmane.comp.lang.ruby.general
Message-ID <CA+t4DcMUTsnq4PVFOoUTRaig59gcVKWJvw3Sxb580FDdBjeB+A@mail.gmail.com>
I've been following online examples of how to create tables the Rails way
and I noticed the migration scripts I created containing references don't
work out of the box. I thought maybe I did something wrong so I tried just
now making a test application/migration against a *SQLite3* datasource. I
ran the following commands:

$ rails g scaffold SchoolClass name
$ rails g scaffold Student name SchoolClass:references

And it made my migration scripts (along with everything else).
[image: Inline image 1]

I ran the migration scripts and it worked fine.
[image: Inline image 3]

When I tried doing the same steps above against a *Postgres* datasource, I
kept on getting the following:

PG::UndefinedTable: ERROR:  relation does not exist

The only way I got past this issue is if I went into the migration script
and updated the t.references line and replaced the class name with the
actual table name. It's a simple enough fix, but I've got a ton of tables
to migrate and each table can have a good number of references. Has anyone
seen this before, and is there some way to keep on using the scaffold
utility to make migrations?

Appreciative of any useful assistance,

 - Joe


-- 

If you type "Google" into Google, you can break the Internet.  -- Jen Barber


Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
Screenshot from 2017-01-17 14-50-17.png (image/png, 15.2 KB) - not displayed
Screenshot from 2017-01-17 14-57-13.png (image/png, 15.7 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.