Skip to content

Commit fe450e1

Browse files
committed
More fixes after testing
1 parent 827c2ed commit fe450e1

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

src/Schema/Columns/Contracts/Column.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,6 @@ public function get_definition(): array {
270270
$sql .= ' UNSIGNED';
271271
}
272272

273-
if ( $this instanceof Precisionable ) {
274-
$sql .= "({$this->get_precision()})";
275-
}
276-
277273
$sql .= $this->get_nullable() ? ' NULL' : ' NOT NULL';
278274

279275
if ( $this instanceof Auto_Incrementable && $this->get_auto_increment() ) {

src/Schema/Columns/Datetime_Column.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace StellarWP\Schema\Columns;
1313

1414
use StellarWP\Schema\Columns\Contracts\Column;
15+
use InvalidArgumentException;
1516

1617
/**
1718
* Class Datetime_Column
@@ -35,6 +36,21 @@ class Datetime_Column extends Column {
3536
*/
3637
protected string $php_type = self::PHP_TYPE_DATETIME;
3738

39+
/**
40+
* Get the default value of the column.
41+
*
42+
* @return mixed The default value of the column.
43+
*
44+
* @throws InvalidArgumentException If the default value is not valid.
45+
*/
46+
public function get_default() {
47+
if ( 'CURRENT_TIMESTAMP' === $this->default && $this->get_type() !== self::COLUMN_TYPE_TIMESTAMP ) {
48+
throw new InvalidArgumentException( 'CURRENT_TIMESTAMP is not a valid default for a non timestamp column until MySQL 5.6.5. Please use a timestamp column instead.' );
49+
}
50+
51+
return $this->default;
52+
}
53+
3854
/**
3955
* Get the supported column types.
4056
*

0 commit comments

Comments
 (0)