I have following code in my migration file:
public function up() {
$this->execute('
CREATE TABLE IF NOT EXISTS `ad_court` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=18 ;');
$this->insert('ad_court',array(
'name' =>'Хўжалик суди',
));
$this->insert('ad_court',array(
'name' =>'Фуқаролик суди',
));
}
But, when I migrate it is showing error message:
insert into ad_court ...exception 'CDbException' with message
'CDbCommand failed to execute the SQL
statement: SQLSTATE[42S02]: Base table or view not found:
1146 Table 'chamber_local_site.ad_court' doesn't exist.
I need to create a new table and insert values inside it. How can I do it in one migration class?
As user guide there is that code,you may use this: