redo database
This commit is contained in:
parent
cc422c109b
commit
3740e6bd23
@ -47,6 +47,38 @@ class PackageController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function actionRestore()
|
||||
{
|
||||
$file = 'https://gist.githubusercontent.com/cornernote/d18f9048b230a8075be1/raw/bc76dc90013422053642865111ff8a5553fa6dd5/packages.json';
|
||||
$this->stdout('Importing restore from ' . $file . "\n");
|
||||
$data = json_decode(file_get_contents($file), true);
|
||||
$count = count($data);
|
||||
foreach ($data as $k => $row) {
|
||||
$this->stdout('[' . ($k + 1) . '/' . $count . '] ', Console::FG_GREY);
|
||||
$this->stdout($row['name'] . ' ' . $row['url'] . ': ');
|
||||
$package = Package::find()->where(['name' => $row['name']])->one();
|
||||
if (!$package) {
|
||||
$package = new Package();
|
||||
$package->name = $row['name'];
|
||||
}
|
||||
if (!$package->url) {
|
||||
$package->url = $row['url'];
|
||||
}
|
||||
if ($package->save()) {
|
||||
$this->stdout('Saved!' . "\n", Console::FG_GREEN);
|
||||
} else {
|
||||
$this->stdout('Errors', Console::FG_RED);
|
||||
foreach ($package->errors as $attribute => $errors) {
|
||||
$this->stdout(' -- ' . $attribute . ' ' . implode(', ', $errors), Console::FG_RED);
|
||||
}
|
||||
$this->stdout("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
use yii\db\Schema;
|
||||
|
||||
class m150809_000001_update_package extends Migration
|
||||
{
|
||||
const TABLE = '{{%package}}';
|
||||
|
||||
public function up()
|
||||
{
|
||||
$this->addColumn(self::TABLE, 'readme', Schema::TYPE_TEXT);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->dropColumn(self::TABLE, 'readme');
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
use yii\db\Schema;
|
||||
|
||||
class m150810_000001_update_package extends Migration
|
||||
{
|
||||
const TABLE = '{{%package}}';
|
||||
|
||||
public function up()
|
||||
{
|
||||
$this->addColumn(self::TABLE, 'readme_format', Schema::TYPE_STRING . '(8)');
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->dropColumn(self::TABLE, 'readme_format');
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
use yii\db\Schema;
|
||||
|
||||
class m150810_000002_update_package extends Migration
|
||||
{
|
||||
const TABLE = '{{%package}}';
|
||||
|
||||
public function up()
|
||||
{
|
||||
$this->dropColumn(self::TABLE, 'screenshot');
|
||||
$this->addColumn(self::TABLE, 'screenshots', Schema::TYPE_TEXT);
|
||||
$this->addColumn(self::TABLE, 'authors', Schema::TYPE_TEXT);
|
||||
$this->addColumn(self::TABLE, 'license', Schema::TYPE_TEXT);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->addColumn(self::TABLE, 'screenshot', Schema::TYPE_STRING);
|
||||
$this->dropColumn(self::TABLE, 'authors');
|
||||
$this->dropColumn(self::TABLE, 'screenshots');
|
||||
$this->dropColumn(self::TABLE, 'license');
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
use yii\db\Schema;
|
||||
|
||||
class m150810_000003_update_package extends Migration
|
||||
{
|
||||
const TABLE = '{{%package}}';
|
||||
|
||||
public function up()
|
||||
{
|
||||
$this->dropColumn(self::TABLE, 'bower');
|
||||
$this->dropColumn(self::TABLE, 'readme');
|
||||
$this->dropColumn(self::TABLE, 'screenshots');
|
||||
$this->dropColumn(self::TABLE, 'authors');
|
||||
$this->dropColumn(self::TABLE, 'license');
|
||||
$this->addColumn(self::TABLE, 'bower', Schema::TYPE_BINARY);
|
||||
$this->addColumn(self::TABLE, 'readme', Schema::TYPE_BINARY);
|
||||
$this->addColumn(self::TABLE, 'screenshots', Schema::TYPE_BINARY);
|
||||
$this->addColumn(self::TABLE, 'authors', Schema::TYPE_BINARY);
|
||||
$this->addColumn(self::TABLE, 'license', Schema::TYPE_BINARY);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->dropColumn(self::TABLE, 'bower');
|
||||
$this->dropColumn(self::TABLE, 'readme');
|
||||
$this->dropColumn(self::TABLE, 'screenshots');
|
||||
$this->dropColumn(self::TABLE, 'authors');
|
||||
$this->dropColumn(self::TABLE, 'license');
|
||||
$this->addColumn(self::TABLE, 'bower', Schema::TYPE_TEXT);
|
||||
$this->addColumn(self::TABLE, 'readme', Schema::TYPE_TEXT);
|
||||
$this->addColumn(self::TABLE, 'screenshots', Schema::TYPE_TEXT);
|
||||
$this->addColumn(self::TABLE, 'authors', Schema::TYPE_TEXT);
|
||||
$this->addColumn(self::TABLE, 'license', Schema::TYPE_TEXT);
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
use yii\db\Schema;
|
||||
|
||||
class m150811_000001_update_package extends Migration
|
||||
{
|
||||
const TABLE = '{{%package}}';
|
||||
|
||||
public function up()
|
||||
{
|
||||
$this->addColumn(self::TABLE, 'forum', Schema::TYPE_STRING . '(255)');
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->dropColumn(self::TABLE, 'forum');
|
||||
}
|
||||
}
|
@ -3,22 +3,28 @@
|
||||
use yii\db\Migration;
|
||||
use yii\db\Schema;
|
||||
|
||||
class m150808_000001_create_package extends Migration
|
||||
class m150812_000001_create_package extends Migration
|
||||
{
|
||||
const TABLE = '{{%package}}';
|
||||
|
||||
public function up()
|
||||
{
|
||||
$this->dropTable(self::TABLE);
|
||||
$this->createTable(self::TABLE, [
|
||||
'id' => Schema::TYPE_PK,
|
||||
'name' => Schema::TYPE_STRING . '(50) NOT NULL',
|
||||
'url' => Schema::TYPE_STRING . '(255) NOT NULL',
|
||||
'hits' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0',
|
||||
'bower' => Schema::TYPE_TEXT,
|
||||
'bower' => Schema::TYPE_BINARY,
|
||||
'readme' => Schema::TYPE_BINARY,
|
||||
'readme_format' => Schema::TYPE_STRING . '(8)',
|
||||
'homepage' => Schema::TYPE_STRING . '(255)',
|
||||
'forum' => Schema::TYPE_STRING . '(255)',
|
||||
'description' => Schema::TYPE_STRING . '(140)',
|
||||
'keywords' => Schema::TYPE_STRING . '(255)',
|
||||
'screenshot' => Schema::TYPE_STRING . '(255)',
|
||||
'screenshots' => Schema::TYPE_BINARY,
|
||||
'authors' => Schema::TYPE_BINARY,
|
||||
'license' => Schema::TYPE_BINARY,
|
||||
'created_at' => Schema::TYPE_DATETIME . ' NOT NULL',
|
||||
'updated_at' => Schema::TYPE_DATETIME . ' NOT NULL',
|
||||
], ($this->db->driverName === 'mysql' ? 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB' : null));
|
||||
@ -29,6 +35,5 @@ class m150808_000001_create_package extends Migration
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->dropTable(self::TABLE);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user