Skip to content

Commit

Permalink
Add timestamps to new table migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyWay committed Mar 3, 2014
1 parent 77c8d95 commit 31310f7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Way/Generators/Syntax/CreateTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public function create($migrationData, $fields)
$primaryKey['id'] = ['type' => 'increments'];
$fields = $primaryKey + $fields;

// We'll also add timestamps to new tables for convenience
$fields[''] = ['type' => 'timestamps'];

return (new AddToTable($this->file, $this->compiler))->add($migrationData, $fields);
}

Expand Down
1 change: 1 addition & 0 deletions tests/stubs/CreateComplexOrdersTable.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class CreateOrdersTable extends Migration {
$table->increments('id');
$table->string('title', 50)->unique();
$table->text('body')->unique()->nullable();
$table->timestamps('');
});
}

Expand Down
1 change: 1 addition & 0 deletions tests/stubs/CreateOrdersTable.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class CreateOrdersTable extends Migration {
Schema::create('orders', function(Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->timestamps('');
});
}

Expand Down
1 change: 1 addition & 0 deletions tests/stubs/DropOrdersTable.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class DropOrdersTable extends Migration {
Schema::create('orders', function(Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->timestamps('');
});
}

Expand Down

0 comments on commit 31310f7

Please sign in to comment.