[Rails] foreign keys on migration

Craig White
2006-03-25T17:40:56Z

On Sat, 2006-03-25 at 09:37 -0700, Craig White wrote:
> I have reached a development plateau and now want to integrate some of
> the rails niceties that I passed over to get the system online.
>
----
whoa - this is strange...I dropped the tables and started over, and
completely removed my sql stuff in the migration script...

$ rake environment RAILS_ENV=test migrate
(in /home/craig/svn/th-db/trunk)
NOTICE:  CREATE TABLE will create implicit sequence "users_id_seq" for
"serial" column "users.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"users_pkey" for table "users"
NOTICE:  CREATE TABLE will create implicit sequence "clients_id_seq"
for
"serial" column "clients.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"clients_pkey" for table "clients"
NOTICE:  CREATE TABLE will create implicit sequence
"facilities_id_seq"
for "serial" column "facilities.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"facilities_pkey" for table "facilities"
NOTICE:  CREATE TABLE will create implicit sequence
"case_managers_id_seq" for "serial" column
"case_managers.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"case_managers_pkey" for table "case_managers"
NOTICE:  CREATE TABLE will create implicit sequence "clients_id_seq"
for
"serial" column "clients.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"clients_pkey" for table "clients"
NOTICE:  CREATE TABLE will create implicit sequence
"facilities_id_seq"
for "serial" column "facilities.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"facilities_pkey" for table "facilities"
NOTICE:  CREATE TABLE will create implicit sequence
"placements_id_seq"
for "serial" column "placements.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"placements_pkey" for table "placements"
NOTICE:  CREATE TABLE will create implicit sequence
"referral_notes_id_seq" for "serial" column
"referral_notes.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"referral_notes_pkey" for table "referral_notes"
NOTICE:  CREATE TABLE will create implicit sequence "users_id_seq" for
"serial" column "users.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"users_pkey" for table "users"
NOTICE:  CREATE TABLE will create implicit sequence
"case_managers_id_seq" for "serial" column
"case_managers.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"case_managers_pkey" for table "case_managers"
NOTICE:  CREATE TABLE will create implicit sequence "clients_id_seq"
for
"serial" column "clients.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"clients_pkey" for table "clients"
NOTICE:  CREATE TABLE will create implicit sequence
"facilities_id_seq"
for "serial" column "facilities.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"facilities_pkey" for table "facilities"
NOTICE:  CREATE TABLE will create implicit sequence
"placements_id_seq"
for "serial" column "placements.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"placements_pkey" for table "placements"
NOTICE:  CREATE TABLE will create implicit sequence
"referral_notes_id_seq" for "serial" column
"referral_notes.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"referral_notes_pkey" for table "referral_notes"
NOTICE:  CREATE TABLE will create implicit sequence "users_id_seq" for
"serial" column "users.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"users_pkey" for table "users"

OK - so it creates the PRIMARY KEY constraints automatically for
me...I''m cool with that.

and just to make sure...changing nothing, I run it again...

[craig@lin-workstation trunk]$ rake environment RAILS_ENV=test migrate
(in /home/craig/svn/th-db/trunk)
NOTICE:  CREATE TABLE will create implicit sequence "users_id_seq" for
"serial" column "users.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"users_pkey" for table "users"
NOTICE:  CREATE TABLE will create implicit sequence "clients_id_seq"
for
"serial" column "clients.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"clients_pkey" for table "clients"
NOTICE:  CREATE TABLE will create implicit sequence
"facilities_id_seq"
for "serial" column "facilities.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"facilities_pkey" for table "facilities"

and it wants to create the same PRIMARY KEY constraints that already
exist.

and if I run the command again, it does the same thing again...

I am confused.

Craig