[DATABASE] Set all primary keys as "not null" explicitly

This commit is contained in:
Alexei Sorokin
2019-09-11 12:27:40 +03:00
committed by Diogo Peralta Cordeiro
parent 2b0251213f
commit 6b4344968d
4 changed files with 117 additions and 83 deletions

View File

@@ -1,35 +1,30 @@
<?php
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// GNU social is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
/**
* Store last-touched ID for various timelines
*
* PHP version 5
*
* @category Data
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/
*
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2010, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* @category Data
* @package GNUsocial
* @author Evan Prodromou <evan@status.net>
* @copyright 2010 StatusNet, Inc.
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
if (!defined('STATUSNET')) {
exit(1);
}
defined('GNUSOCIAL') || die();
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
@@ -40,13 +35,11 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
* So, we store the last ID we see from a timeline, and store it. Next time
* around, we use that ID in the since_id parameter.
*
* @category Action
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/
* @category Action
* @copyright 2010 StatusNet, Inc.
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*
* @see DB_DataObject
* @see DB_DataObject
*/
class Twitter_synch_status extends Managed_DataObject
{
@@ -62,7 +55,7 @@ class Twitter_synch_status extends Managed_DataObject
return array(
'fields' => array(
'foreign_id' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'Foreign message ID'),
'timeline' => array('type' => 'varchar', 'length' => 191, 'description' => 'timeline name'),
'timeline' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'timeline name'),
'last_id' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'last id fetched'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
@@ -71,7 +64,7 @@ class Twitter_synch_status extends Managed_DataObject
);
}
static function getLastId($foreign_id, $timeline)
public static function getLastId($foreign_id, $timeline)
{
$tss = self::pkeyGet(array('foreign_id' => $foreign_id,
'timeline' => $timeline));
@@ -83,7 +76,7 @@ class Twitter_synch_status extends Managed_DataObject
}
}
static function setLastId($foreign_id, $timeline, $last_id)
public static function setLastId($foreign_id, $timeline, $last_id)
{
$tss = self::pkeyGet(array('foreign_id' => $foreign_id,
'timeline' => $timeline));