· 10 years ago · Aug 21, 2016, 04:34 PM
1<?php
2
3use yii\db\Schema;
4use yii\db\Migration;
5
6class m150516_131630_tbl_widget_user extends Migration
7{
8 public function up()
9 {
10
11 $this->execute("
12 CREATE TABLE IF NOT EXISTS `user_widget` (
13 `id` int(11) NOT NULL AUTO_INCREMENT,
14 `title` varchar(255) NOT NULL,
15 `description` text,
16 `uid` int(11) NOT NULL,
17 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
18 PRIMARY KEY (`id`)
19 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
20 ");
21
22 }
23
24 public function down()
25 {
26 echo "m150516_131630_tbl_widget_user cannot be reverted.\n";
27
28 return false;
29 }
30
31 /*
32 // Use safeUp/safeDown to run migration code within a transaction
33 public function safeUp()
34 {
35 }
36
37 public function safeDown()
38 {
39 }
40 */
41}