Skip to content

Commit

Permalink
[5.5] Change datetime to datetime2 (#18962)
Browse files Browse the repository at this point in the history
* Change datetime to datetime2

* Fix databaseschema test

* Fix databaseschema sqlserver test
  • Loading branch information
fernandobandeira authored and taylorotwell committed Apr 27, 2017
1 parent d037ed8 commit a9cb9ef
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php
Expand Up @@ -468,7 +468,7 @@ protected function typeDate(Fluent $column)
*/
protected function typeDateTime(Fluent $column)
{
return "datetime($column->precision)";
return "datetime2($column->precision)";
}

/**
Expand Down Expand Up @@ -513,10 +513,10 @@ protected function typeTimeTz(Fluent $column)
protected function typeTimestamp(Fluent $column)
{
if ($column->useCurrent) {
return "datetime($column->precision) default CURRENT_TIMESTAMP";
return "datetime2($column->precision) default CURRENT_TIMESTAMP";
}

return "datetime($column->precision)";
return "datetime2($column->precision)";
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/DatabaseSchemaBlueprintTest.php
Expand Up @@ -73,6 +73,6 @@ public function testDefaultCurrentTimestamp()
$this->assertEquals(['alter table "users" add column "created" datetime default CURRENT_TIMESTAMP not null'], $blueprint->toSql($connection, new SQLiteGrammar));

$blueprint = clone $base;
$this->assertEquals(['alter table "users" add "created" datetime(0) default CURRENT_TIMESTAMP not null'], $blueprint->toSql($connection, new SqlServerGrammar));
$this->assertEquals(['alter table "users" add "created" datetime2(0) default CURRENT_TIMESTAMP not null'], $blueprint->toSql($connection, new SqlServerGrammar));
}
}
6 changes: 3 additions & 3 deletions tests/Database/DatabaseSqlServerSchemaGrammarTest.php
Expand Up @@ -446,7 +446,7 @@ public function testAddingDateTime()
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertEquals(1, count($statements));
$this->assertEquals('alter table "users" add "foo" datetime(0) not null', $statements[0]);
$this->assertEquals('alter table "users" add "foo" datetime2(0) not null', $statements[0]);
}

public function testAddingDateTimeTz()
Expand Down Expand Up @@ -486,7 +486,7 @@ public function testAddingTimeStamp()
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertEquals(1, count($statements));
$this->assertEquals('alter table "users" add "foo" datetime(0) not null', $statements[0]);
$this->assertEquals('alter table "users" add "foo" datetime2(0) not null', $statements[0]);
}

public function testAddingTimeStampTz()
Expand All @@ -506,7 +506,7 @@ public function testAddingTimeStamps()
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertEquals(1, count($statements));
$this->assertEquals('alter table "users" add "created_at" datetime(0) null, "updated_at" datetime(0) null', $statements[0]);
$this->assertEquals('alter table "users" add "created_at" datetime2(0) null, "updated_at" datetime2(0) null', $statements[0]);
}

public function testAddingTimeStampsTz()
Expand Down

0 comments on commit a9cb9ef

Please sign in to comment.