Unrequested primary key being added in migration
David Spitzley
dspitzle at wash.k12.mi.us
Wed Dec 11 15:46:12 UTC 2013
Shoot, just found my own answer: http://stackoverflow.com/questions/17876491/laravel-4-migration-error-creates-two-auto-increment-primary-keys-fields
Sorry for the intrusion.
-----Original Message-----
From: mercurial-bounces at selenic.com [mailto:mercurial-bounces at selenic.com] On Behalf Of David Spitzley
Sent: Wednesday, December 11, 2013 10:29 AM
To: mercurial at selenic.com
Subject: Unrequested primary key being added in migration
I've got a Schema::create in my migration which is resulting in two primary key requests (and a consequent crash of the migration process), and I don't have a clue as to why. In the create request I specifically ask for 'id' to be a primary key, but the --pretend readout shows that the 'zip' field is also generating a primary key request. Any recommendation for killing this bug? Here's the Schema command and the subsequent --pretend output.
Schema::create('family_addresses', function($table) {
$table->integer('id')->unsigned()->unique()->primary()->nullable(false);
$table->integer('primary_id')->unsigned()->index()->nullable();
$table->integer('family_id')->unsigned()->index()->nullable();
$table->foreign('family_id')->references('id')->on('families');
$table->date('occupancy_date')->nullable(false);
$table->integer('living_situation_id')->unsigned()->nullable(false);
$table->foreign('living_situation_id')->references('id')->on('living_situations');
$table->integer('homelessness_reason_id')->unsigned()->nullable(false);
$table->foreign('homelessness_reason_id')->references('id')->on('homelessness_reasons');
$table->text('note')->nullable();
$table->string('address')->nullable();
$table->string('city')->nullable();
$table->string('state',2)->nullable();
$table->integer('zip',5)->index()->nullable();
$table->string('district_id')->index()->nullable();
$table->foreign('district_id')->references('id')->on('districts');
$table->integer('user_id')->unsigned()->nullable(false);
$table->foreign('user_id')->references('id')->on('users');
$table->timestamps();
$table->softDeletes();
});
EphyFamilyTables: create table `family_addresses` (`id` int unsigned not null, `primary_id` int unsigned null, `family_id` int unsigned null, `occupancy_date` date not null, `living_situation_id` int unsigned not null, `homelessness_reason_id` int unsigned not null, `note` text null, `address` varchar(255) null, `city` varchar(255) null, `state` varchar(2) null, `zip` int null auto_increment primary key, `district_id` varchar(255) null, `user_id` int unsigned not null, `created_at` timestamp default 0 not null, `updated_at` timestamp default 0 not null, `deleted_at` timestamp null) default character set utf8 collate utf8_unicode_ci
EphyFamilyTables: alter table `family_addresses` add constraint family_addresses_family_id_foreign foreign key (`family_id`) references `families` (`id`)
EphyFamilyTables: alter table `family_addresses` add constraint family_addresses_living_situation_id_foreign foreign key (`living_situation_id`) references `living_situations` (`id`)
EphyFamilyTables: alter table `family_addresses` add constraint family_addresses_homelessness_reason_id_foreign foreign key (`homelessness_reason_id`) references `homelessness_reasons` (`id`)
EphyFamilyTables: alter table `family_addresses` add constraint family_addresses_district_id_foreign foreign key (`district_id`) references `districts` (`id`)
EphyFamilyTables: alter table `family_addresses` add constraint family_addresses_user_id_foreign foreign key (`user_id`) references `users` (`id`)
EphyFamilyTables: alter table `family_addresses` add primary key family_addresses_id_primary(`id`)
EphyFamilyTables: alter table `family_addresses` add index family_addresses_primary_id_index(`primary_id`)
EphyFamilyTables: alter table `family_addresses` add index family_addresses_family_id_index(`family_id`)
EphyFamilyTables: alter table `family_addresses` add index family_addresses_zip_index(`zip`)
EphyFamilyTables: alter table `family_addresses` add index family_addresses_district_id_index(`district_id`)
_______________________________________________
Mercurial mailing list
Mercurial at selenic.com
http://selenic.com/mailman/listinfo/mercurial
More information about the Mercurial
mailing list