[DATABASE] Introduce a bool type in schema

PostgreSQL has a clear distinction between integers and booleans, so it makes
sense to draw a clear line.
This commit is contained in:
Alexei Sorokin
2019-09-11 11:25:39 +03:00
committed by Diogo Peralta Cordeiro
parent 9d87c37ac1
commit 3f17a0efea
39 changed files with 1324 additions and 1280 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/>.
/**
* Data class for email summary status
*
* 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';
@@ -38,19 +33,17 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
*
* Email summary information for users
*
* @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 Email_summary_status extends Managed_DataObject
{
public $__table = 'email_summary_status'; // table name
public $user_id; // int(4) primary_key not_null
public $send_summary; // tinyint not_null
public $send_summary; // bool not_null default_true
public $last_summary_id; // int(4) null
public $created; // datetime not_null
public $modified; // datetime not_null
@@ -60,9 +53,9 @@ class Email_summary_status extends Managed_DataObject
return array(
'fields' => array(
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id'),
'send_summary' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'not null' => true, 'description' => 'whether to send a summary or not'),
'send_summary' => array('type' => 'bool', 'default' => true, 'not null' => true, 'description' => 'whether to send a summary or not'),
'last_summary_id' => array('type' => 'int', 'description' => 'last summary id'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'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'),
),
'primary key' => array('user_id'),
@@ -79,7 +72,7 @@ class Email_summary_status extends Managed_DataObject
*
* @return int flag for whether to send this user a summary email
*/
static function getSendSummary($user_id)
public static function getSendSummary($user_id)
{
$ess = Email_summary_status::getKV('user_id', $user_id);
@@ -97,7 +90,7 @@ class Email_summary_status extends Managed_DataObject
*
* @return Email_summary_status instance for this user, with count already incremented.
*/
static function getLastSummaryID($user_id)
public static function getLastSummaryID($user_id)
{
$ess = Email_summary_status::getKV('user_id', $user_id);