public function testDropForeign()
 {
     $blueprint = new Blueprint('users');
     $blueprint->dropForeign('foo');
     $statements = $blueprint->toSql($this->getGrammar());
     $this->assertEquals(1, count($statements));
     $this->assertEquals('alter table "users" drop constraint foo', $statements[0]);
 }
Пример #2
0
 /**
  * Excluir campo.
  *
  * @param  string|array $columns
  *
  * @return \Illuminate\Support\Fluent
  */
 public function dropColumn($columns)
 {
     $columns = is_array($columns) ? $columns : (array) func_get_args();
     // Verificar se deve excluir constrain dos campos lookups antes
     foreach ($columns as $column) {
         if (ForeignKey::isAssociation($column)) {
             parent::dropForeign(ForeignKey::makeName($this->table, $column));
         }
     }
     return parent::dropColumn($columns);
 }
Пример #3
0
 /**
  * Drop a foreign key in the given table.
  *
  * @param  \Illuminate\Database\Schema\Blueprint   $table
  * @param  \Stidges\LaravelFkMigration\ForeignKey  $key
  * @return void
  */
 protected function dropKey($table, ForeignKey $key)
 {
     $column = is_array($key->column) ? $key->column : [$key->column];
     $table->dropForeign($column);
 }