diff --git a/src/Sushi.php b/src/Sushi.php index c84ad50..74f0de5 100644 --- a/src/Sushi.php +++ b/src/Sushi.php @@ -149,8 +149,8 @@ public function createTable(string $tableName, $firstRow) { $this->createTableSafely($tableName, function ($table) use ($firstRow) { // Add the "id" column if it doesn't already exist in the rows. - if ($this->incrementing && ! array_key_exists($this->primaryKey, $firstRow)) { - $table->increments($this->primaryKey); + if ($this->getIncrementing() && ! array_key_exists($this->getKeyName(), $firstRow)) { + $table->increments($this->getKeyName()); } foreach ($firstRow as $column => $value) { @@ -171,8 +171,8 @@ public function createTable(string $tableName, $firstRow) $type = 'string'; } - if ($column === $this->primaryKey && $type == 'integer') { - $table->increments($this->primaryKey); + if ($column === $this->getKeyName() && $type == 'integer') { + $table->increments($this->getKeyName()); continue; } @@ -201,13 +201,13 @@ public function createTableWithNoData(string $tableName) $this->createTableSafely($tableName, function ($table) { $schema = $this->getSchema(); - if ($this->incrementing && ! in_array($this->primaryKey, array_keys($schema))) { - $table->increments($this->primaryKey); + if ($this->getIncrementing() && ! in_array($this->getKeyName(), array_keys($schema))) { + $table->increments($this->getKeyName()); } foreach ($schema as $name => $type) { - if ($name === $this->primaryKey && $type == 'integer') { - $table->increments($this->primaryKey); + if ($name === $this->getKeyName() && $type == 'integer') { + $table->increments($this->getKeyName()); continue; }