Example #1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     //
     $this->info('Database Backup Start...');
     $tableNames = Schema::getConnection()->getDoctrineSchemaManager()->listTableNames();
     foreach ($tableNames as $tableName) {
         Iseed::generateSeed($tableName);
         $this->info('Seeded: ' . $tableName);
     }
     $this->info('Database Backup End...');
 }
Example #2
0
 public function backup()
 {
     $tables = [];
     foreach (DB::select('SHOW TABLES') as $key => $value) {
         $table_name = array_values((array) $value)[0];
         array_push($tables, $table_name);
     }
     if (count($tables)) {
         foreach ($tables as $tableName) {
             Iseed::generateSeed($tableName);
         }
     }
 }
Example #3
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $this->info('数据库备份工作--Begin');
     $tables = [];
     foreach (DB::select('SHOW TABLES') as $key => $value) {
         $table_name = array_values((array) $value)[0];
         array_push($tables, $table_name);
     }
     if (count($tables)) {
         foreach ($tables as $tableName) {
             Iseed::generateSeed($tableName);
             $this->info($tableName . ' Seeded');
         }
     }
     $this->info('数据库Seed备份工作--End');
 }
Example #4
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $this->info('Database Backup Start...');
     $path = $this->getMigrationPath();
     $files = $this->files->glob($path . '/*_*.php');
     $files = array_map(function ($file) {
         return str_replace('.php', '', basename($file));
     }, $files);
     sort($files);
     $tables = [];
     $fileNames = [];
     foreach ($files as $value) {
         $name = preg_replace('/.*create_(.*)_table/', '$1', $value);
         array_push($fileNames, $name);
     }
     foreach (DB::select('SHOW TABLES') as $k => $v) {
         $tableName = array_values((array) $v)[0];
         array_push($tables, $tableName);
     }
     foreach ($fileNames as $value) {
         if (($key = array_search($value, $tables)) !== false) {
             unset($tables[$key]);
             Iseed::generateSeed($value);
             $this->info($value . ' Seeded');
         } else {
             foreach ($tables as $key => $tableName) {
                 if (strpos($value, $tableName) !== false) {
                     unset($tables[$key]);
                     Iseed::generateSeed($tableName);
                     $this->info($tableName . ' Seeded');
                     break;
                 }
             }
         }
     }
     if (count($tables)) {
         foreach ($tables as $tableName) {
             Iseed::generateSeed($tableName);
             $this->info($tableName . ' Seeded');
         }
     }
     $this->info('Database Backup End...');
 }