mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-08-23 17:37:25 +00:00
db: prepare a notification rules table
This commit is contained in:
parent
0c5fb6cb30
commit
0f6e93f1ca
2 changed files with 59 additions and 0 deletions
24
sql/2016-06-01-notifications.sql
Normal file
24
sql/2016-06-01-notifications.sql
Normal file
|
@ -0,0 +1,24 @@
|
|||
-- Recent additions to add after db init (.gz)
|
||||
-- mysql yaamp -p < file.sql
|
||||
|
||||
CREATE TABLE `notifications` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`idcoin` int(11) NOT NULL,
|
||||
`enabled` int(1) NOT NULL DEFAULT '0',
|
||||
`description` varchar(128) NULL,
|
||||
`conditiontype` varchar(32) NULL,
|
||||
`conditionvalue` double NULL,
|
||||
`notifytype` varchar(32) NULL,
|
||||
`notifycmd` varchar(512) NULL,
|
||||
`lastchecked` int(10) UNSIGNED NOT NULL,
|
||||
`lasttriggered` int(10) UNSIGNED NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- KEYS
|
||||
|
||||
ALTER TABLE `notifications`
|
||||
ADD KEY `notif_coin` (`idcoin`),
|
||||
ADD INDEX `notif_checked` (`lastchecked`);
|
||||
|
||||
ALTER TABLE `notifications` ADD CONSTRAINT fk_notif_coin FOREIGN KEY (`idcoin`)
|
||||
REFERENCES coins (`id`) ON DELETE CASCADE;
|
35
web/yaamp/models/db_notificationsModel.php
Normal file
35
web/yaamp/models/db_notificationsModel.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
class db_notifications extends CActiveRecord
|
||||
{
|
||||
public static function model($className=__CLASS__)
|
||||
{
|
||||
return parent::model($className);
|
||||
}
|
||||
|
||||
public function tableName()
|
||||
{
|
||||
return 'notifications';
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return array(
|
||||
array('idcoin', 'safe'),
|
||||
);
|
||||
}
|
||||
|
||||
public function relations()
|
||||
{
|
||||
return array(
|
||||
'coin' => array(self::BELONGS_TO, 'db_coins', 'idcoin', 'alias'=>'nc'),
|
||||
);
|
||||
}
|
||||
|
||||
public function attributeLabels()
|
||||
{
|
||||
return array(
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Reference in a new issue