Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/Sushi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
Loading