Exemplo n.º 1
0
 public function up()
 {
     echo "holly";
     $this->truncateTable("menu");
     $this->truncateTable("openformat");
     if (dbMaster::tableExists("AuthAssignment")) {
         $this->dropTable("AuthAssignment");
         $this->dropTable("Rights");
         $this->dropTable("AuthItem");
         $this->dropTable("AuthItemChild");
     }
     $table = Yii::$app->db->schema->getTableSchema('menu');
     if (!isset($table->columns['order'])) {
         $this->renameColumn("menu", "sort", "order");
         $this->renameColumn("menu", "url", "route");
         $this->renameColumn("menu", "label", "name");
     }
     $this->batchInsert("openformat", ['id', 'description', 'type', 'size', 'record', 'export', 'import', 'type_id'], $this->openformat);
     $this->batchInsert("menu", ['id', 'name', 'route', 'icon', 'parent', 'order'], $this->menu);
     //create authassiment,x,u
     if (!dbMaster::tableExists("auth_assignment")) {
         $this->createTable('auth_assignment', ['item_name' => Schema::TYPE_STRING . ' NOT NULL', 'user_id' => Schema::TYPE_STRING . ' NOT NULL', 'created_at' => Schema::TYPE_INTEGER]);
         $this->createTable('auth_item', ['name' => Schema::TYPE_STRING . ' NOT NULL', 'type' => Schema::TYPE_INTEGER, 'description' => Schema::TYPE_TEXT, 'rule_name' => Schema::TYPE_STRING, 'data' => Schema::TYPE_TEXT, 'created_at' => Schema::TYPE_INTEGER, 'updated_at' => Schema::TYPE_INTEGER]);
         $this->createTable('auth_item_child', ['parent' => Schema::TYPE_STRING . ' NOT NULL', 'child' => Schema::TYPE_STRING . ' NOT NULL']);
         $this->createTable('auth_rule', ['parent' => Schema::TYPE_STRING . ' NOT NULL', 'child' => Schema::TYPE_TEXT, 'created_at' => Schema::TYPE_INTEGER, 'updated_at' => Schema::TYPE_INTEGER]);
         $this->batchInsert("auth_assignment", ['item_name', 'user_id', 'created_at'], $this->auth_assignment);
         $this->batchInsert("auth_item", ['name', 'type', 'description', 'rule_name', 'data', 'created_at', 'updated_at'], $this->auth_item);
         $this->batchInsert("auth_item_child", ['parent', 'child'], $this->auth_item_child);
     }
     //companies..
     $companys = Company::find()->All();
     foreach ($companys as $company) {
         //update payment,config
         $this->update($company->prefix . 'paymentType', ['value' => '\\app\\components\\payments\\Cash'], ['id' => 1]);
         $this->update($company->prefix . 'paymentType', ['value' => '\\app\\components\\payments\\Check'], ['id' => 2]);
         $this->update($company->prefix . 'paymentType', ['value' => '\\app\\components\\payments\\PelaCredit'], ['id' => 3]);
         $this->update($company->prefix . 'paymentType', ['value' => '\\app\\components\\payments\\Bank'], ['id' => 4]);
         $this->update($company->prefix . 'paymentType', ['value' => '\\app\\components\\payments\\ManualCredit'], ['id' => 5]);
         $this->update($company->prefix . 'paymentType', ['value' => '\\app\\components\\payments\\PelaCreditPaymnts'], ['id' => 6]);
         $this->update($company->prefix . 'paymentType', ['value' => '\\app\\components\\payments\\SourceTax'], ['id' => 7]);
         $this->update($company->prefix . 'config', ["eavType" => "list(app\\models\\Currecies)"], ["id" => "company.cur"]);
         $this->update($company->prefix . 'config', ["eavType" => "list(app\\models\\Currecies)"], ["id" => "company.seccur"]);
         $this->update($company->prefix . 'config', ["eavType" => 'select({"1":"monthly","2":"bi-monthly"})'], ["id" => "company.tax.irs"]);
         $this->update($company->prefix . 'config', ["eavType" => 'select({"1":"monthly","2":"bi-monthly"})'], ["id" => "company.tax.vat"]);
         if (dbMaster::tableExists($company->prefix . "AuthAssignment")) {
             $this->dropTable($company->prefix . "AuthAssignment");
             $this->dropTable($company->prefix . "Rights");
             $this->dropTable($company->prefix . "AuthItem");
             $this->dropTable($company->prefix . "AuthItemChild");
         }
         if (!dbMaster::tableExists($company->prefix . 'auth_assignment')) {
             $this->createTable($company->prefix . 'auth_assignment', ['item_name' => Schema::TYPE_STRING . ' NOT NULL', 'user_id' => Schema::TYPE_STRING . ' NOT NULL', 'created_at' => Schema::TYPE_INTEGER]);
             $this->createTable($company->prefix . 'auth_item', ['name' => Schema::TYPE_STRING . ' NOT NULL', 'type' => Schema::TYPE_INTEGER, 'description' => Schema::TYPE_TEXT, 'rule_name' => Schema::TYPE_STRING, 'data' => Schema::TYPE_TEXT, 'created_at' => Schema::TYPE_INTEGER, 'updated_at' => Schema::TYPE_INTEGER]);
             $this->createTable($company->prefix . 'auth_item_child', ['parent' => Schema::TYPE_STRING . ' NOT NULL', 'child' => Schema::TYPE_STRING . ' NOT NULL']);
             $this->createTable($company->prefix . 'auth_rule', ['parent' => Schema::TYPE_STRING . ' NOT NULL', 'child' => Schema::TYPE_TEXT, 'created_at' => Schema::TYPE_INTEGER, 'updated_at' => Schema::TYPE_INTEGER]);
             $this->batchInsert($company->prefix . "auth_assignment", ['item_name', 'user_id', 'created_at'], $this->auth_assignment);
             $this->batchInsert($company->prefix . "auth_item", ['name', 'type', 'description', 'rule_name', 'data', 'created_at', 'updated_at'], $this->auth_item);
             $this->batchInsert($company->prefix . "auth_item_child", ['parent', 'child'], $this->auth_item_child);
         }
     }
     return true;
 }
Exemplo n.º 2
0
 public function newBackup($prefix = null)
 {
     $backup = ["backup" => time(), "prefix" => $prefix, "columns" => [], "data" => []];
     foreach ($this->getTables() as $table) {
         if ($prefix !== null) {
             if (strpos($table, $prefix) === 0) {
                 $backup = dbMaster::newTableBackup($table, $prefix, $backup);
             }
         } else {
             $backup = dbMaster::newTableBackup($table, $prefix, $backup);
         }
     }
     return $backup;
 }
Exemplo n.º 3
0
 private function createDb()
 {
     $yiiBasepath = Yii::$app->basePath;
     //$mysql=$yiiBasepath."/data/company-lite.sql";
     $master = new dbMaster();
     //$master->loadFile($yiiBasepath . "/data/company-lite.sql", Yii::$app->db->tablePrefix);
     $master->loadFile($yiiBasepath . DIRECTORY_SEPARATOR . "data" . DIRECTORY_SEPARATOR . "company.sql", $this->prefix);
     \app\helpers\Linet3Helper::getOverrides("buildCompany", ["dbMaster" => new $master(), 'prefix' => $this->prefix]);
 }