public function testAddingForeignKey() { $blueprint = new Blueprint('users'); $blueprint->foreign('foo_id')->references('id')->on('orders'); $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); $this->assertEquals(1, count($statements)); $this->assertEquals('alter table `users` add constraint users_foo_id_foreign foreign key (`foo_id`) references `orders` (`id`)', $statements[0]); }
public function testAddingForeignKey() { $blueprint = new Blueprint('users'); $blueprint->create(); $blueprint->string('foo')->primary(); $blueprint->string('order_id'); $blueprint->foreign('order_id')->references('id')->on('orders'); $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); $this->assertEquals(1, count($statements)); $this->assertEquals('create table "users" ("foo" varchar null, "order_id" varchar null, foreign key("order_id") references "orders"("id"), primary key ("foo"))', $statements[0]); }