From 5eae3dc3515ce4da9b8a4bcf79672ec1d7bea409 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Sun, 5 Jul 2020 13:12:35 +0000 Subject: [PATCH] [CORE][DATABASE] Replace zero dates with CURRENT_TIMESTAMP and add defaults to all 'created' or 'modified' This commit is a port from v2's 9a515b9234 ([SCHEMA] Improve timestamp storage) to v3. As explained by Alexei Sorokin: Avoid the use of deprecated MariaDATABASE "zero dates" globally. If they're present as attribute defaults somewhere, they will be replaced with NULL implicitly. The existing "zero dates" in MariaDATABASE storage will be left intact and this should not present any issues. The "timestamp" type in table definitions now corresponds to DATETIME in MariaDATABASE 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 MariaDATABASE. But there is no such trigger implemented on PostgreSQL as of this moment. --- src/Core/DB/SchemaDefDriver.php | 26 +++++++++++++------------- src/Entity/ActivityLocation.php | 2 +- src/Entity/ActivitySource.php | 4 ++-- src/Entity/ActivityTag.php | 2 +- src/Entity/Avatar.php | 4 ++-- src/Entity/ConfirmAddress.php | 4 ++-- src/Entity/Conversation.php | 4 ++-- src/Entity/File.php | 2 +- src/Entity/FileThumbnail.php | 2 +- src/Entity/FileToActivity.php | 2 +- src/Entity/FollowQueue.php | 2 +- src/Entity/Group.php | 4 ++-- src/Entity/GroupAlias.php | 2 +- src/Entity/GroupBlock.php | 2 +- src/Entity/GroupInbox.php | 2 +- src/Entity/GroupJoinQueue.php | 2 +- src/Entity/GroupMember.php | 4 ++-- src/Entity/Invitation.php | 2 +- src/Entity/LocationService.php | 4 ++-- src/Entity/Notification.php | 4 ++-- src/Entity/Profile.php | 4 ++-- src/Entity/ProfileBlock.php | 2 +- src/Entity/ProfileList.php | 4 ++-- src/Entity/ProfilePrefs.php | 4 ++-- src/Entity/ProfileTag.php | 2 +- src/Entity/ProfileTagFollow.php | 4 ++-- src/Entity/RelatedGroup.php | 2 +- src/Entity/ReservedNickname.php | 2 +- src/Entity/SmsCarrier.php | 4 ++-- src/Entity/UserLocationPrefs.php | 4 ++-- src/Entity/UserNotificationPrefs.php | 4 ++-- src/Entity/UserUrlShortenerPrefs.php | 4 ++-- 32 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/Core/DB/SchemaDefDriver.php b/src/Core/DB/SchemaDefDriver.php index b4575efe16..b26ba1d188 100644 --- a/src/Core/DB/SchemaDefDriver.php +++ b/src/Core/DB/SchemaDefDriver.php @@ -37,19 +37,20 @@ use Functional as F; class SchemaDefDriver extends StaticPHPDriver { /** - * PEAR DB type => Doctrine type + * V2 DB type => Doctrine type */ private const types = [ - 'varchar' => 'string', - 'char' => 'string', // char is a fixed witdh varchar - 'int' => 'integer', - 'serial' => 'integer', - 'tinyint' => 'smallint', // no portable tinyint - 'bigint' => 'bigint', - 'bool' => 'boolean', - 'numeric' => 'decimal', - 'text' => 'text', - 'datetime' => 'datetime', + 'varchar' => 'string', + 'char' => 'string', // char is a fixed witdh varchar + 'int' => 'integer', + 'serial' => 'integer', + 'tinyint' => 'smallint', // no portable tinyint + 'bigint' => 'bigint', + 'bool' => 'boolean', + 'numeric' => 'decimal', + 'text' => 'text', + 'datetime' => 'datetime', + 'timestamp' => 'datetime', // Unused in V2, but might start being used 'date' => 'date', 'time' => 'time', @@ -98,8 +99,7 @@ class SchemaDefDriver extends StaticPHPDriver } } - $default = (($opts['default'] ?? null) === '0000-00-00 00:00:00' && $_ENV['DBMS'] === 'postgres') - ? '-infinity' : $opts['default'] ?? null; + $default = $opts['default'] ?? null; $field = [ // boolean, optional diff --git a/src/Entity/ActivityLocation.php b/src/Entity/ActivityLocation.php index 01c2ee4655..ef71454e8d 100644 --- a/src/Entity/ActivityLocation.php +++ b/src/Entity/ActivityLocation.php @@ -124,7 +124,7 @@ class ActivityLocation 'lon' => ['type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'longitude'], 'location_id' => ['type' => 'int', 'description' => 'location id if possible'], 'location_service' => ['type' => 'int', 'size' => 'tiny', 'description' => 'service used to retrieve location information'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['activity_id'], 'foreign keys' => [ diff --git a/src/Entity/ActivitySource.php b/src/Entity/ActivitySource.php index 965c33ef22..a47122e3e3 100644 --- a/src/Entity/ActivitySource.php +++ b/src/Entity/ActivitySource.php @@ -122,8 +122,8 @@ class ActivitySource 'code' => ['type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'code identifier'], 'name' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'name of the source'], 'url' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'url to link to'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['code'], ]; diff --git a/src/Entity/ActivityTag.php b/src/Entity/ActivityTag.php index 44bd6c0397..75312421a1 100644 --- a/src/Entity/ActivityTag.php +++ b/src/Entity/ActivityTag.php @@ -86,7 +86,7 @@ class ActivityTag 'fields' => [ 'tag' => ['type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'hash tag associated with this activity'], 'activity_id' => ['type' => 'int', 'not null' => true, 'description' => 'activity tagged'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], ], 'primary key' => ['tag', 'activity_id'], 'foreign keys' => [ diff --git a/src/Entity/Avatar.php b/src/Entity/Avatar.php index 3467b1ee8f..c26db67d1d 100644 --- a/src/Entity/Avatar.php +++ b/src/Entity/Avatar.php @@ -148,8 +148,8 @@ class Avatar 'width' => ['type' => 'int', 'not null' => true, 'description' => 'image width'], 'height' => ['type' => 'int', 'not null' => true, 'description' => 'image height'], 'mediatype' => ['type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'file type'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['profile_id', 'width', 'height'], 'foreign keys' => [ diff --git a/src/Entity/ConfirmAddress.php b/src/Entity/ConfirmAddress.php index e956efdf2d..7aa42b3c5a 100644 --- a/src/Entity/ConfirmAddress.php +++ b/src/Entity/ConfirmAddress.php @@ -149,8 +149,8 @@ class ConfirmAddress 'address_extra' => ['type' => 'varchar', 'length' => 191, 'description' => 'carrier ID, for SMS'], 'address_type' => ['type' => 'varchar', 'length' => 8, 'not null' => true, 'description' => 'address type ("email", "xmpp", "sms")'], 'claimed' => ['type' => 'datetime', 'description' => 'date this was claimed for queueing'], - 'sent' => ['type' => 'datetime', 'description' => 'date this was sent for queueing'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'], + 'sent' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this was sent for queueing'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['code'], 'foreign keys' => [ diff --git a/src/Entity/Conversation.php b/src/Entity/Conversation.php index f5586a47b9..2bc2c5d781 100644 --- a/src/Entity/Conversation.php +++ b/src/Entity/Conversation.php @@ -108,8 +108,8 @@ class Conversation 'id' => ['type' => 'serial', 'not null' => true, 'description' => 'Unique identifier, (again) unrelated to notice id since 2016-01-06'], 'uri' => ['type' => 'varchar', 'not null' => true, 'length' => 191, 'description' => 'URI of the conversation'], 'url' => ['type' => 'varchar', 'length' => 191, 'description' => 'Resolvable URL, preferably remote (local can be generated on the fly)'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['id'], 'unique keys' => [ diff --git a/src/Entity/File.php b/src/Entity/File.php index 10067cad89..32a86a7344 100644 --- a/src/Entity/File.php +++ b/src/Entity/File.php @@ -215,7 +215,7 @@ class File 'is_local' => ['type' => 'bool', 'description' => 'whether the file is stored locally'], 'width' => ['type' => 'int', 'description' => 'width in pixels, if it can be described as such and data is available'], 'height' => ['type' => 'int', 'description' => 'height in pixels, if it can be described as such and data is available'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['id'], 'unique keys' => [ diff --git a/src/Entity/FileThumbnail.php b/src/Entity/FileThumbnail.php index 2f84723541..3dec606c2a 100644 --- a/src/Entity/FileThumbnail.php +++ b/src/Entity/FileThumbnail.php @@ -134,7 +134,7 @@ class FileThumbnail 'file_id' => ['type' => 'int', 'not null' => true, 'description' => 'thumbnail for what file'], 'width' => ['type' => 'int', 'not null' => true, 'description' => 'width of thumbnail'], 'height' => ['type' => 'int', 'not null' => true, 'description' => 'height of thumbnail'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['file_id', 'width', 'height'], 'foreign keys' => [ diff --git a/src/Entity/FileToActivity.php b/src/Entity/FileToActivity.php index 187f1ec6d8..cf1ec5166c 100644 --- a/src/Entity/FileToActivity.php +++ b/src/Entity/FileToActivity.php @@ -85,7 +85,7 @@ class FileToActivity 'fields' => [ 'file_id' => ['type' => 'int', 'not null' => true, 'description' => 'id of file'], 'activity_id' => ['type' => 'int', 'not null' => true, 'description' => 'id of the activity it belongs to'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['file_id', 'activity_id'], 'foreign keys' => [ diff --git a/src/Entity/FollowQueue.php b/src/Entity/FollowQueue.php index 1106b69520..647f63d24d 100644 --- a/src/Entity/FollowQueue.php +++ b/src/Entity/FollowQueue.php @@ -86,7 +86,7 @@ class FollowQueue 'fields' => [ 'follower' => ['type' => 'int', 'not null' => true, 'description' => 'remote or local profile making the request'], 'followed' => ['type' => 'int', 'not null' => true, 'description' => 'remote or local profile being followed to'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], ], 'primary key' => ['follower', 'followed'], 'indexes' => [ diff --git a/src/Entity/Group.php b/src/Entity/Group.php index dc46fc69d6..a7edb48f70 100644 --- a/src/Entity/Group.php +++ b/src/Entity/Group.php @@ -263,12 +263,12 @@ class Group 'homepage_logo' => ['type' => 'varchar', 'length' => 191, 'description' => 'homepage (profile) size logo'], 'stream_logo' => ['type' => 'varchar', 'length' => 191, 'description' => 'stream-sized logo'], 'mini_logo' => ['type' => 'varchar', 'length' => 191, 'description' => 'mini logo'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'], 'uri' => ['type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'], 'mainpage' => ['type' => 'varchar', 'length' => 191, 'description' => 'page for group info to link to'], 'join_policy' => ['type' => 'int', 'size' => 'tiny', 'description' => '0=open; 1=requires admin approval'], 'force_scope' => ['type' => 'int', 'size' => 'tiny', 'description' => '0=never,1=sometimes,-1=always'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['id'], 'unique keys' => [ diff --git a/src/Entity/GroupAlias.php b/src/Entity/GroupAlias.php index 03ff1209da..7569982ab6 100644 --- a/src/Entity/GroupAlias.php +++ b/src/Entity/GroupAlias.php @@ -85,7 +85,7 @@ class GroupAlias 'fields' => [ 'alias' => ['type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'additional nickname for the group'], 'group_id' => ['type' => 'int', 'not null' => true, 'description' => 'group id which this is an alias of'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date alias was created'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['alias'], 'foreign keys' => [ diff --git a/src/Entity/GroupBlock.php b/src/Entity/GroupBlock.php index a6f302090d..cdc2eb4d1c 100644 --- a/src/Entity/GroupBlock.php +++ b/src/Entity/GroupBlock.php @@ -98,7 +98,7 @@ class GroupBlock 'group_id' => ['type' => 'int', 'not null' => true, 'description' => 'group profile is blocked from'], 'blocked_profile' => ['type' => 'int', 'not null' => true, 'description' => 'profile that is blocked'], 'blocker_user' => ['type' => 'int', 'not null' => true, 'description' => 'user making the block'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date of blocking'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['group_id', 'blocked_profile'], 'foreign keys' => [ diff --git a/src/Entity/GroupInbox.php b/src/Entity/GroupInbox.php index 537106919c..39f00f0e7b 100644 --- a/src/Entity/GroupInbox.php +++ b/src/Entity/GroupInbox.php @@ -86,7 +86,7 @@ class GroupInbox 'fields' => [ 'group_id' => ['type' => 'int', 'not null' => true, 'description' => 'group receiving the message'], 'activity_id' => ['type' => 'int', 'not null' => true, 'description' => 'activity received'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date the activity was created'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], ], 'primary key' => ['group_id', 'activity_id'], 'foreign keys' => [ diff --git a/src/Entity/GroupJoinQueue.php b/src/Entity/GroupJoinQueue.php index c2882a8743..0dcec8a5a2 100644 --- a/src/Entity/GroupJoinQueue.php +++ b/src/Entity/GroupJoinQueue.php @@ -86,7 +86,7 @@ class GroupJoinQueue 'fields' => [ 'profile_id' => ['type' => 'int', 'not null' => true, 'description' => 'remote or local profile making the request'], 'group_id' => ['type' => 'int', 'not null' => true, 'description' => 'remote or local group to join, if any'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], ], 'primary key' => ['profile_id', 'group_id'], 'indexes' => [ diff --git a/src/Entity/GroupMember.php b/src/Entity/GroupMember.php index 5297f04185..acdf63271f 100644 --- a/src/Entity/GroupMember.php +++ b/src/Entity/GroupMember.php @@ -123,8 +123,8 @@ class GroupMember 'profile_id' => ['type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'], 'is_admin' => ['type' => 'bool', 'default' => false, 'description' => 'is this user an admin?'], 'uri' => ['type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['group_id', 'profile_id'], 'unique keys' => [ diff --git a/src/Entity/Invitation.php b/src/Entity/Invitation.php index 18356aea10..a50986c63d 100644 --- a/src/Entity/Invitation.php +++ b/src/Entity/Invitation.php @@ -123,8 +123,8 @@ class Invitation 'user_id' => ['type' => 'int', 'not null' => true, 'description' => 'who sent the invitation'], 'address' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'invitation sent to'], 'address_type' => ['type' => 'varchar', 'length' => 8, 'not null' => true, 'description' => 'address type ("email", "xmpp", "sms")'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'], 'registered_user_id' => ['type' => 'int', 'not null' => false, 'description' => 'if the invitation is converted, who the new user is'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], ], 'primary key' => ['code'], 'foreign keys' => [ diff --git a/src/Entity/LocationService.php b/src/Entity/LocationService.php index 2eff49273a..4cabe5601d 100644 --- a/src/Entity/LocationService.php +++ b/src/Entity/LocationService.php @@ -97,8 +97,8 @@ class LocationService 'fields' => [ 'id' => ['type' => 'int', 'size' => 'tiny', 'not null' => true, 'description' => 'identifier for the location service'], 'description' => ['type' => 'varchar', 'length' => 191, 'description' => 'description of the service'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date the record was created'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['id'], ]; diff --git a/src/Entity/Notification.php b/src/Entity/Notification.php index 21106de54e..2957b03567 100644 --- a/src/Entity/Notification.php +++ b/src/Entity/Notification.php @@ -111,8 +111,8 @@ class Notification 'notice_id' => ['type' => 'int', 'not null' => true, 'description' => 'notice_id to give attention'], 'profile_id' => ['type' => 'int', 'not null' => true, 'description' => 'profile_id for feed receiver'], 'reason' => ['type' => 'varchar', 'length' => 191, 'description' => 'Optional reason why this was brought to the attention of profile_id'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['notice_id', 'profile_id'], 'foreign keys' => [ diff --git a/src/Entity/Profile.php b/src/Entity/Profile.php index 2a8ac78fcd..86cf2256ee 100644 --- a/src/Entity/Profile.php +++ b/src/Entity/Profile.php @@ -214,8 +214,8 @@ class Profile 'lon' => ['type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'longitude'], 'location_id' => ['type' => 'int', 'description' => 'location id if possible'], 'location_service' => ['type' => 'int', 'description' => 'service used to obtain location id'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['id'], 'indexes' => [ diff --git a/src/Entity/ProfileBlock.php b/src/Entity/ProfileBlock.php index 46988fc72a..8564232872 100644 --- a/src/Entity/ProfileBlock.php +++ b/src/Entity/ProfileBlock.php @@ -85,7 +85,7 @@ class ProfileBlock 'fields' => [ 'blocker' => ['type' => 'int', 'not null' => true, 'description' => 'user making the block'], 'blocked' => ['type' => 'int', 'not null' => true, 'description' => 'profile that is blocked'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date of blocking'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['blocker', 'blocked'], 'foreign keys' => [ diff --git a/src/Entity/ProfileList.php b/src/Entity/ProfileList.php index a92e2f2eb6..08f6662c41 100644 --- a/src/Entity/ProfileList.php +++ b/src/Entity/ProfileList.php @@ -189,8 +189,8 @@ class ProfileList 'mainpage' => ['type' => 'varchar', 'length' => 191, 'description' => 'page to link to'], 'tagged_count' => ['type' => 'int', 'default' => 0, 'description' => 'number of people tagged with this tag by this user'], 'follower_count' => ['type' => 'int', 'default' => 0, 'description' => 'number of followers to this tag'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date the tag was added'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date the tag was modified'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['tagger', 'tag'], 'unique keys' => [ diff --git a/src/Entity/ProfilePrefs.php b/src/Entity/ProfilePrefs.php index 3b4f43958e..427bdeacaf 100644 --- a/src/Entity/ProfilePrefs.php +++ b/src/Entity/ProfilePrefs.php @@ -123,8 +123,8 @@ class ProfilePrefs 'namespace' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'namespace, like pluginname or category'], 'topic' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'preference key, i.e. description, age...'], 'data' => ['type' => 'blob', 'description' => 'topic data, may be anything'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['profile_id', 'namespace', 'topic'], 'foreign keys' => [ diff --git a/src/Entity/ProfileTag.php b/src/Entity/ProfileTag.php index 05392ffea0..bf37f2b6e1 100644 --- a/src/Entity/ProfileTag.php +++ b/src/Entity/ProfileTag.php @@ -98,7 +98,7 @@ class ProfileTag 'tagger' => ['type' => 'int', 'not null' => true, 'description' => 'user making the tag'], 'tagged' => ['type' => 'int', 'not null' => true, 'description' => 'profile tagged'], 'tag' => ['type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'hash tag associated with this notice'], - 'modified' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date the tag was added'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['tagger', 'tagged', 'tag'], 'foreign keys' => [ diff --git a/src/Entity/ProfileTagFollow.php b/src/Entity/ProfileTagFollow.php index 49ec6ca980..3ad4e57473 100644 --- a/src/Entity/ProfileTagFollow.php +++ b/src/Entity/ProfileTagFollow.php @@ -97,8 +97,8 @@ class ProfileTagFollow 'fields' => [ 'profile_tag_id' => ['type' => 'int', 'not null' => true, 'description' => 'foreign key to profile_tag'], 'profile_id' => ['type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'], - 'modified' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['profile_tag_id', 'profile_id'], 'foreign keys' => [ diff --git a/src/Entity/RelatedGroup.php b/src/Entity/RelatedGroup.php index 9f0c5ebf46..35bf764309 100644 --- a/src/Entity/RelatedGroup.php +++ b/src/Entity/RelatedGroup.php @@ -86,7 +86,7 @@ class RelatedGroup 'fields' => [ 'group_id' => ['type' => 'int', 'not null' => true, 'description' => 'foreign key to user_group'], 'related_group_id' => ['type' => 'int', 'not null' => true, 'description' => 'foreign key to user_group'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], ], 'primary key' => ['group_id', 'related_group_id'], 'foreign keys' => [ diff --git a/src/Entity/ReservedNickname.php b/src/Entity/ReservedNickname.php index 6dbcfed406..fd7ca30d25 100644 --- a/src/Entity/ReservedNickname.php +++ b/src/Entity/ReservedNickname.php @@ -73,7 +73,7 @@ class ReservedNickname 'description' => 'A reserved nickname', 'fields' => [ 'nickname' => ['type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'nickname not to use'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], ], 'primary key' => ['nickname'], ]; diff --git a/src/Entity/SmsCarrier.php b/src/Entity/SmsCarrier.php index e67497cac0..942251dccc 100644 --- a/src/Entity/SmsCarrier.php +++ b/src/Entity/SmsCarrier.php @@ -110,8 +110,8 @@ class SmsCarrier 'id' => ['type' => 'int', 'not null' => true, 'description' => 'primary key for SMS carrier'], 'name' => ['type' => 'varchar', 'length' => 64, 'description' => 'name of the carrier'], 'email_pattern' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'sprintf pattern for making an email address from a phone number'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['id'], 'unique keys' => [ diff --git a/src/Entity/UserLocationPrefs.php b/src/Entity/UserLocationPrefs.php index 6078a9166c..2076c4e629 100644 --- a/src/Entity/UserLocationPrefs.php +++ b/src/Entity/UserLocationPrefs.php @@ -95,8 +95,8 @@ class UserLocationPrefs 'fields' => [ 'user_id' => ['type' => 'int', 'not null' => true, 'description' => 'user who has the preference'], 'share_location' => ['type' => 'bool', 'default' => true, 'description' => 'Whether to share location data'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['user_id'], 'foreign keys' => [ diff --git a/src/Entity/UserNotificationPrefs.php b/src/Entity/UserNotificationPrefs.php index 3bbfe1fce8..2ed3fbaba0 100644 --- a/src/Entity/UserNotificationPrefs.php +++ b/src/Entity/UserNotificationPrefs.php @@ -153,8 +153,8 @@ class UserNotificationPrefs 'dm' => ['type' => 'bool', 'not null' => true, 'default' => false, 'description' => 'Notify someone sends us a direct message'], 'post_on_status_change' => ['type' => 'bool', 'not null' => true, 'default' => false, 'description' => 'Post a notice when our status in service changes'], 'enable_posting' => ['type' => 'bool', 'default' => true, 'description' => 'Enable posting from this service'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['user_id', 'transport'], 'unique keys' => [ diff --git a/src/Entity/UserUrlShortenerPrefs.php b/src/Entity/UserUrlShortenerPrefs.php index 55dcc0a36e..557851a357 100644 --- a/src/Entity/UserUrlShortenerPrefs.php +++ b/src/Entity/UserUrlShortenerPrefs.php @@ -123,8 +123,8 @@ class UserUrlShortenerPrefs 'url_shortening_service' => ['type' => 'varchar', 'length' => 50, 'default' => 'internal', 'description' => 'service to use for auto-shortening URLs'], 'max_url_length' => ['type' => 'int', 'not null' => true, 'description' => 'urls greater than this length will be shortened, 0 = always, -1 = never'], 'max_notice_length' => ['type' => 'int', 'not null' => true, 'description' => 'notices with content greater than this value will have all urls shortened, 0 = always, -1 = only if notice text is longer than max allowed'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['user_id'], 'foreign keys' => [