Migrate Full (ok)
Ex 1
C:\xampp74\htdocs\oectest\migrations\m220724_073246_create_tables.php
<?php
use yii\db\Migration;
/**
* Class m220724_073246_create_tables
*/
class m220724_073246_create_tables extends Migration {
/**
* {@inheritdoc}
*/
public function up() {
$this->createTable('user', [
'id' => $this->primaryKey(),
'username' => $this->string(55)->notNull(),
'password' => $this->string(255)->notNull(),
'auth_key' => $this->string(255)->notNull(),
'access_token' => $this->string(255)->notNull(),
]);
$this->createTable('posts', [
'id' => $this->primaryKey(),
'title' => $this->string(125)->defaultValue(null),
'excerpt' => $this->string(125)->defaultValue(null),
'content' => $this->text()->defaultValue(null),
'category' => $this->string(45)->defaultValue(null),
'tags' => $this->string(125)->defaultValue(null),
'author' => $this->string(65)->defaultValue(null),
'slug' => $this->string(125)->defaultValue(null),
'createdOn' => $this->timestamp(),
'featuredImage' => $this->string(125)->defaultValue(null),
'published' => $this->integer(11),
'comments' => $this->integer(11)->defaultValue(null),
'likes' => $this->integer()->defaultValue(0),
'deleted' => $this->integer()->defaultValue(0),
]);
$this->createTable('post_comment', [
'id' => $this->primaryKey(),
'post_id' => $this->integer(11),
'user' => $this->string(65)->defaultValue(null),
'comment' => $this->text()->defaultValue(null),
'createdOn' => $this->timestamp()
]);
}
/**
* {@inheritdoc}
*/
public function down() {
$this->dropTable('user');
$this->dropTable('posts');
}
}
Ex 2
C:\xampp74\htdocs\oectest\migrations\m220724_073246_create_tables.php
Last updated
Was this helpful?