[SCHEMA] Improve timestamp storage

Avoid the use of deprecated MariaDB "zero dates" globally. If they're present
as attribute defaults somewhere, they will be replaced with NULL implicitly.
The existing "zero dates" in MariaDB storage will be left intact and this
should not present any issues.

The "timestamp" type in table definitions now corresponds to DATETIME in
MariaDB with "DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP", which
should be close enough to the original behaviour for compatibility purposes.
It is now the recommended type for "modified" attributes, because of the
update trigger on MariaDB. But there is no such trigger implemented on
PostgreSQL as of this moment.
This commit is contained in:
Alexei Sorokin
2020-06-29 01:41:46 +03:00
parent b924c180ae
commit 9a515b9234
73 changed files with 1130 additions and 756 deletions

View File

@@ -47,8 +47,8 @@ class Activitypub_profile extends Managed_DataObject
public $homepage; // text()
public $bio; // text() multiple_key
public $location; // text()
public $created; // datetime() not_null default_CURRENT_TIMESTAMP
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
public $created; // datetime()
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
/**
* Return table definition for Schema setup and DB_DataObject usage.
@@ -64,8 +64,8 @@ class Activitypub_profile extends Managed_DataObject
'profile_id' => ['type' => 'int', 'not null' => true],
'inboxuri' => ['type' => 'text', 'not null' => true],
'sharedInboxuri' => ['type' => 'text'],
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
'modified' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
'created' => ['type' => 'datetime', 'description' => 'date this record was created'],
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
],
'primary key' => ['profile_id'],
'foreign keys' => [