Skip to content

Commit

Permalink
Merge pull request #75 from ucan-lab/fix/soft-deletes
Browse files Browse the repository at this point in the history
fix softDeletes
  • Loading branch information
ucan-lab authored Oct 8, 2019
2 parents c912f33 + d7fcb40 commit 239a85c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
15 changes: 15 additions & 0 deletions src/Migrations/Schema/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,18 @@ public function __construct(string $name, $attributes)
if ($name === 'rememberToken') {
$this->name = null;
$this->type = 'rememberToken';
} elseif ($name === 'softDeletes') {
$this->name = null;
$this->type = 'softDeletes';
} elseif ($name === 'softDeletesTz') {
$this->name = null;
$this->type = 'softDeletesTz';
} elseif ($name === 'timestamps') {
$this->name = is_int($attributes) ? $attributes : null;
$this->type = 'timestamps';
} elseif ($name === 'timestampsTz') {
$this->name = is_int($attributes) ? $attributes : null;
$this->type = 'timestampsTz';
} elseif (is_string($attributes)) {
$this->type = $attributes;
} elseif (is_array($attributes)) {
Expand Down Expand Up @@ -85,8 +94,14 @@ protected function getColumnType(): string
{
if ($this->type === 'rememberToken') {
return '->rememberToken()';
} elseif ($this->type === 'softDeletes') {
return '->softDeletes()';
} elseif ($this->type === 'softDeletesTz') {
return '->softDeletesTz()';
} elseif ($this->type === 'timestamps') {
return '->timestamps(' . ($this->name ?: '') . ')';
} elseif ($this->type === 'timestampsTz') {
return '->timestampsTz(' . ($this->name ?: '') . ')';
}

preg_match('/\((.*)\)/', $this->type, $match);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public function up()
$table->point('position_point');
$table->polygon('positions_polygon');
$table->set('flavors', ['strawberry', 'vanilla']);
$table->rememberToken();
$table->softDeletes();
$table->timestamps();
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public function up()
$table->timeTz('sunrise_tz');
$table->timestamp('added_on');
$table->timestampTz('added_on_tz');
$table->softDeletesTz();
$table->timestampsTz();
});
}

Expand Down
10 changes: 5 additions & 5 deletions tests/Storage/column_type/schemas/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ column_type3:
type: polygon
flavors:
type: set(['strawberry', 'vanilla'])
rememberToken: true
softDeletes: true
timestamps: true
rememberToken: true
softDeletes: true
timestamps: true

column_type4:
columns:
Expand All @@ -98,8 +98,8 @@ column_type4:
type: timestamp
added_on_tz:
type: timestampTz
softDeletesTz: true
timestampsTz: true
softDeletesTz: true
timestampsTz: true

column_type5:
columns:
Expand Down

0 comments on commit 239a85c

Please sign in to comment.