/** * {@inheritdoc} */ public function safeUp() { //刪除一條數據 $this->delete('membership_order',[ 'application_id' => 398 ]); } /** * {@inheritdoc} */ public function safeDown() { $this->dropTable('membership_order'); return true; }
public function up()
{
//創建數據表test_table並且定義表中字段
$this->createTable('test_table', [
//`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY
'id' => $this->primaryKey(),
//`title` varchar(300) not null
'title' => $this->string(300)->notNull(),
//`content` text
'content' => $this->text(),
// `create_time` datetime
'create_time' => $this->dateTime(),
]);
//插入一條數據
$this->insert('test_table',[
'id' => 1,
'title' => '哆啦A夢',
'content' => '大雄'
]);
}