public function fire() { if (!$this->option('tenant')) { return parent::fire(); } if ($this->option('tenant') == 'all') { $websites = $this->website->all(); } else { $websites = $this->website->queryBuilder()->whereIn('id', explode(',', $this->option('tenant')))->get(); } // forces database to tenant if (!$this->option('database')) { $this->input->setOption('database', 'tenant'); } foreach ($websites as $website) { $this->info("Migrating for {$website->id}: {$website->present()->name}"); $website->database->setCurrent(); $this->repository->setSource($website->database->name); try { $this->repository->createRepository(); } catch (PDOException $e) { if (str_contains($e->getMessage(), ['Base table or view already exists'])) { $this->info("Migration table already exists: {$e->getMessage()}"); continue; } } $this->info('Migration table created successfully.'); } }
/** * Execute the console command. * * @return void */ public function fire() { try { parent::fire(); } catch (PDOException $e) { if (!isset($e->errorInfo[1]) || $e->errorInfo[1] != 1050) { throw $e; } $this->info('Migration table already exists'); } $this->checkMigrationDirectory(); }