Beispiel #1
0
 public function dbInstall()
 {
     $db = Yii::$app->db;
     $tableOptions = null;
     if ($db->driverName === 'mysql') {
         $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=MyISAM';
     }
     $db->createCommand()->createTable(Category::tableName(), ['file_id' => 'pk', 'title' => Schema::TYPE_STRING . '(128) NOT NULL', 'file' => Schema::TYPE_STRING . '(255) NOT NULL', 'size' => Schema::TYPE_INTEGER . ' NOT NULL', 'slug' => Schema::TYPE_STRING . '(128) DEFAULT NULL', 'downloads' => Schema::TYPE_INTEGER . " DEFAULT '0'", 'time' => Schema::TYPE_INTEGER . " DEFAULT '0'", 'order_num' => Schema::TYPE_INTEGER], $tableOptions)->execute();
     $db->createCommand()->createIndex('slug', Category::tableName(), 'slug', true)->execute();
 }
 public function insertGallery()
 {
     if (gallery\models\Category::find()->count()) {
         return '`<b>' . gallery\models\Category::tableName() . '</b>` table is not empty, skipping...';
     }
     $this->db->createCommand('TRUNCATE TABLE `' . gallery\models\Category::tableName() . '`')->query();
     $album1 = new gallery\models\Category(['title' => 'Album 1', 'image' => '/uploads/gallery/album-1.jpg', 'order_num' => 2]);
     $album1->makeRoot();
     $this->attachSeo($album1, 'Album 1 H1', 'Extended Album 1 title');
     $this->attachPhotos($album1, ['/uploads/photos/album-1-9.jpg', '/uploads/photos/album-1-8.jpg', '/uploads/photos/album-1-7.jpg', '/uploads/photos/album-1-6.jpg', '/uploads/photos/album-1-5.jpg', '/uploads/photos/album-1-4.jpg', '/uploads/photos/album-1-3.jpg', '/uploads/photos/album-1-2.jpg', '/uploads/photos/album-1-1.jpg']);
     $album2 = new gallery\models\Category(['title' => 'Album 2', 'image' => '/uploads/gallery/album-2.jpg', 'order_num' => 1]);
     $album2->makeRoot();
     $this->attachSeo($album2, 'Album 2 H1', 'Extended Album 2 title');
     return 'Gallery data inserted.';
 }
 public function down()
 {
     $this->dropTable(models\Admin::tableName());
     $this->dropTable(models\LoginForm::tableName());
     $this->dropTable(models\Module::tableName());
     $this->dropTable(models\Photo::tableName());
     $this->dropTable(models\Setting::tableName());
     $this->dropTable(Carousel::tableName());
     $this->dropTable(catalog\models\Category::tableName());
     $this->dropTable(catalog\models\Item::tableName());
     $this->dropTable(article\models\Category::tableName());
     $this->dropTable(article\models\Item::tableName());
     $this->dropTable(Feedback::tableName());
     $this->dropTable(File::tableName());
     $this->dropTable(gallery\models\Category::tableName());
     $this->dropTable(Guestbook::tableName());
     $this->dropTable(News::tableName());
     $this->dropTable(Page::tableName());
     $this->dropTable(Subscriber::tableName());
     $this->dropTable(History::tableName());
     $this->dropTable(Text::tableName());
 }