db: prepare a notification rules table

This commit is contained in:
Tanguy Pruvot 2016-06-01 14:32:18 +02:00
parent 0c5fb6cb30
commit 0f6e93f1ca
2 changed files with 59 additions and 0 deletions

View 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;

View 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(
);
}
}