How to Use defineAttributes To Specify NOT NULL and DEFAULT '1' in MySQL Record
I am porting a plugin from another framework and it has the following MySql tables structure. Is there an easy way to create the same table structure within craft plugin?
CREATE TABLE IF NOT EXISTS `exp_shortcut_shortcuts` ( `shortcut_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `site_id` smallint(3) unsigned NOT NULL default '1', `entry_id` smallint(3) unsigned NOT NULL default '0', `field_id` smallint(3) unsigned NOT NULL default '0', `autogenerated` char(1) NOT NULL default 'y', `shortcut` varchar(100) NOT NULL default '', `full_url_model` varchar(255) NOT NULL default '', `full_url` varchar(255) NOT NULL default '', `entry_date` int(11) unsigned NOT NULL default '0', `edit_date` int(11) unsigned NOT NULL default '0', PRIMARY KEY (`shortcut_id`), INDEX (`shortcut`) ) ;; namespace Craft; class ShortcutRecord extends BaseRecord { public function getTableName() { return 'shortcut_shortcuts'; } public function primaryKey() { return 'shortcut_id'; } protected function defineAttributes() { return array( 'shortcut_id' => array(AttributeType::Number, 'column' => ColumnType::PK), 'site_id' => array(AttributeType::Number, 'column' => ColumnType::TinyInt),
I see how to add TinyInt. How do I specify NOT NULL and default '1'?