public function columnTypes()
 {
     return [[Schema::TYPE_PK, Schema::primaryKey(), 'integer PRIMARY KEY AUTOINCREMENT NOT NULL'], [Schema::TYPE_PK . '(8)', Schema::primaryKey(8), 'integer PRIMARY KEY AUTOINCREMENT NOT NULL'], [Schema::TYPE_PK . ' CHECK (value > 5)', Schema::primaryKey()->check('value > 5'), 'integer PRIMARY KEY AUTOINCREMENT NOT NULL CHECK (value > 5)'], [Schema::TYPE_PK . '(8) CHECK (value > 5)', Schema::primaryKey(8)->check('value > 5'), 'integer PRIMARY KEY AUTOINCREMENT NOT NULL CHECK (value > 5)'], [Schema::TYPE_STRING, Schema::string(), 'varchar(255)'], [Schema::TYPE_STRING . '(32)', Schema::string(32), 'varchar(32)'], [Schema::TYPE_STRING . ' CHECK (value LIKE "test%")', Schema::string()->check('value LIKE "test%"'), 'varchar(255) CHECK (value LIKE "test%")'], [Schema::TYPE_STRING . '(32) CHECK (value LIKE "test%")', Schema::string(32)->check('value LIKE "test%"'), 'varchar(32) CHECK (value LIKE "test%")'], [Schema::TYPE_STRING . ' NOT NULL', Schema::string()->notNull(), 'varchar(255) NOT NULL'], [Schema::TYPE_TEXT, Schema::text(), 'text'], [Schema::TYPE_TEXT . '(255)', Schema::text(255), 'text'], [Schema::TYPE_TEXT . ' CHECK (value LIKE "test%")', Schema::text()->check('value LIKE "test%"'), 'text CHECK (value LIKE "test%")'], [Schema::TYPE_TEXT . '(255) CHECK (value LIKE "test%")', Schema::text(255)->check('value LIKE "test%"'), 'text CHECK (value LIKE "test%")'], [Schema::TYPE_TEXT . ' NOT NULL', Schema::text()->notNull(), 'text NOT NULL'], [Schema::TYPE_TEXT . '(255) NOT NULL', Schema::text(255)->notNull(), 'text NOT NULL'], [Schema::TYPE_SMALLINT, Schema::smallInteger(), 'smallint'], [Schema::TYPE_SMALLINT . '(8)', Schema::smallInteger(8), 'smallint'], [Schema::TYPE_INTEGER, Schema::integer(), 'integer'], [Schema::TYPE_INTEGER . '(8)', Schema::integer(8), 'integer'], [Schema::TYPE_INTEGER . ' CHECK (value > 5)', Schema::integer()->check('value > 5'), 'integer CHECK (value > 5)'], [Schema::TYPE_INTEGER . '(8) CHECK (value > 5)', Schema::integer(8)->check('value > 5'), 'integer CHECK (value > 5)'], [Schema::TYPE_INTEGER . ' NOT NULL', Schema::integer()->notNull(), 'integer NOT NULL'], [Schema::TYPE_BIGINT, Schema::bigInteger(), 'bigint'], [Schema::TYPE_BIGINT . '(8)', Schema::bigInteger(8), 'bigint'], [Schema::TYPE_BIGINT . ' CHECK (value > 5)', Schema::bigInteger()->check('value > 5'), 'bigint CHECK (value > 5)'], [Schema::TYPE_BIGINT . '(8) CHECK (value > 5)', Schema::bigInteger(8)->check('value > 5'), 'bigint CHECK (value > 5)'], [Schema::TYPE_BIGINT . ' NOT NULL', Schema::bigInteger()->notNull(), 'bigint NOT NULL'], [Schema::TYPE_FLOAT, Schema::float(), 'float'], [Schema::TYPE_FLOAT . '(16,5)', Schema::float(16, 5), 'float'], [Schema::TYPE_FLOAT . ' CHECK (value > 5.6)', Schema::float()->check('value > 5.6'), 'float CHECK (value > 5.6)'], [Schema::TYPE_FLOAT . '(16,5) CHECK (value > 5.6)', Schema::float(16, 5)->check('value > 5.6'), 'float CHECK (value > 5.6)'], [Schema::TYPE_FLOAT . ' NOT NULL', Schema::float()->notNull(), 'float NOT NULL'], [Schema::TYPE_DECIMAL, Schema::decimal(), 'decimal(10,0)'], [Schema::TYPE_DECIMAL . '(12,4)', Schema::decimal(12, 4), 'decimal(12,4)'], [Schema::TYPE_DECIMAL . ' CHECK (value > 5.6)', Schema::decimal()->check('value > 5.6'), 'decimal(10,0) CHECK (value > 5.6)'], [Schema::TYPE_DECIMAL . '(12,4) CHECK (value > 5.6)', Schema::decimal(12, 4)->check('value > 5.6'), 'decimal(12,4) CHECK (value > 5.6)'], [Schema::TYPE_DECIMAL . ' NOT NULL', Schema::decimal()->notNull(), 'decimal(10,0) NOT NULL'], [Schema::TYPE_DATETIME, Schema::dateTime(), 'datetime'], [Schema::TYPE_DATETIME . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", Schema::dateTime()->check("value BETWEEN '2011-01-01' AND '2013-01-01'"), "datetime CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')"], [Schema::TYPE_DATETIME . ' NOT NULL', Schema::dateTime()->notNull(), 'datetime NOT NULL'], [Schema::TYPE_TIMESTAMP, Schema::timestamp(), 'timestamp'], [Schema::TYPE_TIMESTAMP . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", Schema::timestamp()->check("value BETWEEN '2011-01-01' AND '2013-01-01'"), "timestamp CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')"], [Schema::TYPE_TIMESTAMP . ' NOT NULL', Schema::timestamp()->notNull(), 'timestamp NOT NULL'], [Schema::TYPE_TIME, Schema::time(), 'time'], [Schema::TYPE_TIME . " CHECK (value BETWEEN '12:00:00' AND '13:01:01')", Schema::time()->check("value BETWEEN '12:00:00' AND '13:01:01'"), "time CHECK (value BETWEEN '12:00:00' AND '13:01:01')"], [Schema::TYPE_TIME . ' NOT NULL', Schema::time()->notNull(), 'time NOT NULL'], [Schema::TYPE_DATE, Schema::date(), 'date'], [Schema::TYPE_DATE . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", Schema::date()->check("value BETWEEN '2011-01-01' AND '2013-01-01'"), "date CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')"], [Schema::TYPE_DATE . ' NOT NULL', Schema::date()->notNull(), 'date NOT NULL'], [Schema::TYPE_BINARY, Schema::binary(), 'blob'], [Schema::TYPE_BOOLEAN, Schema::boolean(), 'boolean'], [Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1', Schema::boolean()->notNull()->default(1), 'boolean NOT NULL DEFAULT 1'], [Schema::TYPE_MONEY, Schema::money(), 'decimal(19,4)'], [Schema::TYPE_MONEY . '(16,2)', Schema::money(16, 2), 'decimal(16,2)'], [Schema::TYPE_MONEY . ' CHECK (value > 0.0)', Schema::money()->check('value > 0.0'), 'decimal(19,4) CHECK (value > 0.0)'], [Schema::TYPE_MONEY . '(16,2) CHECK (value > 0.0)', Schema::money(16, 2)->check('value > 0.0'), 'decimal(16,2) CHECK (value > 0.0)'], [Schema::TYPE_MONEY . ' NOT NULL', Schema::money()->notNull(), 'decimal(19,4) NOT NULL']];
 }
 public function up()
 {
     $tableOptions = null;
     if ($this->db->driverName === 'mysql') {
         $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
     }
     $this->createTable('{{%widget_menu}}', ['id' => Schema::primaryKey(), 'key' => Schema::string(32)->notNull(), 'title' => Schema::string()->notNull(), 'items' => Schema::text()->notNull(), 'status' => Schema::smallInteger()->notNull()->default(0)], $tableOptions);
 }
 public function up()
 {
     $tableOptions = null;
     if ($this->db->driverName === 'mysql') {
         $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
     }
     $this->createTable('{{%page}}', ['id' => Schema::primaryKey(), 'slug' => Schema::string(2048)->notNull(), 'title' => Schema::string(512)->notNull(), 'body' => Schema::string()->notNull(), 'view' => Schema::string(), 'status' => Schema::smallInteger()->notNull(), 'created_at' => Schema::integer(), 'updated_at' => Schema::integer()], $tableOptions);
 }
 public function up()
 {
     $tableOptions = null;
     if ($this->db->driverName === 'mysql') {
         $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
     }
     $this->createTable('{{%widget_text}}', ['id' => Schema::primaryKey(), 'key' => Schema::string()->notNull(), 'title' => Schema::string()->notNull(), 'body' => Schema::text()->notNull(), 'status' => Schema::smallInteger(), 'created_at' => Schema::integer(), 'updated_at' => Schema::integer()], $tableOptions);
     $this->createIndex('idx_widget_text_key', '{{%widget_text}}', 'key');
 }
 public function up()
 {
     $tableOptions = null;
     if ($this->db->driverName === 'mysql') {
         // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
         $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
     }
     $this->createTable('{{%user}}', ['id' => Schema::primaryKey(), 'username' => Schema::string()->notNull()->unique(), 'auth_key' => Schema::string(32)->notNull(), 'password_hash' => Schema::string()->notNull(), 'password_reset_token' => Schema::string()->unique(), 'email' => Schema::string()->notNull()->unique(), 'status' => Schema::smallInteger()->notNull()->default(10), 'created_at' => Schema::integer()->notNull(), 'updated_at' => Schema::integer()->notNull()], $tableOptions);
 }
 public function up()
 {
     $tableOptions = null;
     if ($this->db->driverName === 'mysql') {
         $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
     }
     $this->createTable('{{%user}}', ['id' => Schema::primaryKey(), 'username' => Schema::string(32), 'auth_key' => Schema::string(32)->notNull(), 'password_hash' => Schema::string()->notNull(), 'password_reset_token' => Schema::string(), 'oauth_client' => Schema::string(), 'oauth_client_user_id' => Schema::string(), 'email' => Schema::string()->notNull(), 'status' => Schema::smallInteger()->notNull()->default(User::STATUS_ACTIVE), 'created_at' => Schema::integer(), 'updated_at' => Schema::integer(), 'logged_at' => Schema::integer()], $tableOptions);
     $this->createTable('{{%user_profile}}', ['user_id' => Schema::primaryKey(), 'firstname' => Schema::string(), 'middlename' => Schema::string(), 'lastname' => Schema::string(), 'avatar_path' => Schema::string(), 'avatar_base_url' => Schema::string(), 'locale' => Schema::string(32)->notNull(), 'gender' => Schema::smallInteger(1)], $tableOptions);
     $this->addForeignKey('fk_user', '{{%user_profile}}', 'user_id', '{{%user}}', 'id', 'cascade', 'cascade');
 }
 public function safeUp()
 {
     $tableOptions = null;
     if ($this->db->driverName === 'mysql') {
         $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
     }
     $this->createTable('{{%widget_carousel}}', ['id' => Schema::primaryKey(), 'key' => Schema::string()->notNull(), 'status' => Schema::smallInteger()->default(0)], $tableOptions);
     $this->createTable('{{%widget_carousel_item}}', ['id' => Schema::primaryKey(), 'carousel_id' => Schema::integer()->notNull(), 'base_url' => Schema::string(1024), 'path' => Schema::string(1024), 'type' => Schema::string(), 'url' => Schema::string(1024), 'caption' => Schema::string(1024), 'status' => Schema::smallInteger()->notNull()->default(0), 'order' => Schema::integer()->default(0), 'created_at' => Schema::integer(), 'updated_at' => Schema::integer()], $tableOptions);
     $this->addForeignKey('fk_item_carousel', '{{%widget_carousel_item}}', 'carousel_id', '{{%widget_carousel}}', 'id', 'cascade', 'cascade');
 }
 public function safeUp()
 {
     $tableOptions = null;
     if ($this->db->driverName === 'mysql') {
         $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
     }
     $this->createTable('{{%article_category}}', ['id' => Schema::primaryKey(), 'slug' => Schema::string(1024)->notNull(), 'title' => Schema::string(512)->notNull(), 'body' => Schema::text(), 'parent_id' => Schema::integer(), 'status' => Schema::smallInteger()->notNull()->default(0), 'created_at' => Schema::integer(), 'updated_at' => Schema::integer()], $tableOptions);
     $this->createTable('{{%article}}', ['id' => Schema::primaryKey(), 'slug' => Schema::string(1024)->notNull(), 'title' => Schema::string(512)->notNull(), 'body' => Schema::text()->notNull(), 'view' => Schema::string(), 'category_id' => Schema::integer(), 'thumbnail_base_url' => Schema::string(1024), 'thumbnail_path' => Schema::string(1024), 'author_id' => Schema::integer(), 'updater_id' => Schema::integer(), 'status' => Schema::smallInteger()->notNull()->default(0), 'published_at' => Schema::integer(), 'created_at' => Schema::integer(), 'updated_at' => Schema::integer()], $tableOptions);
     $this->createTable('{{%article_attachment}}', ['id' => Schema::primaryKey(), 'article_id' => Schema::integer()->notNull(), 'path' => Schema::string()->notNull(), 'base_url' => Schema::string(), 'type' => Schema::string(), 'size' => Schema::integer(), 'name' => Schema::string(), 'created_at' => Schema::integer()]);
     $this->addForeignKey('fk_article_attachment_article', '{{%article_attachment}}', 'article_id', '{{%article}}', 'id', 'cascade', 'cascade');
     $this->addForeignKey('fk_article_author', '{{%article}}', 'author_id', '{{%user}}', 'id', 'cascade', 'cascade');
     $this->addForeignKey('fk_article_updater', '{{%article}}', 'updater_id', '{{%user}}', 'id', 'set null', 'cascade');
     $this->addForeignKey('fk_article_category', '{{%article}}', 'category_id', '{{%article_category}}', 'id');
     $this->addForeignKey('fk_article_category_section', '{{%article_category}}', 'parent_id', '{{%article_category}}', 'id', 'cascade', 'cascade');
 }