/** * Process table to get migrations fields. * * @param string $table * @return array */ public function process($table) { $this->migrationRows = []; $primaryKey = $this->schema->getPrimaryKey($table); $foreign = $this->schema->getForeign($table); $indexes = $this->schema->getIndexes($table); $timestamps = $this->schema->getTimestamps($table); $laravelTimestamps = $this->hasLaravelTimestamps($timestamps); foreach ($this->schema->getColumns($table) as $column) { $name = $column->getName(); // If you have default timestamps in the special order in your table we // will check their names while processing in order not parsing them // as default timestamp field with our grammar instance. if ($laravelTimestamps && in_array($name, $this->timestamps)) { continue; } $status = $this->processRow($column, $name == $primaryKey, in_array($name, $indexes['unique'])); if ($status) { $this->processForeign($column, $foreign); } } // If we have default laravel timestamps in the table we will generate // the necessary migration row. $this->processTimestamps($laravelTimestamps); //$this->processIndexes($indexes['index']); $this->processIndexesWithoutForeigns($indexes['index'], array_keys($foreign)); return $this->migrationRows; }
/** * Compile many to * relationship. * * @param array $foreigns * @param string $table */ protected function compileManyToRelationship($foreigns, $table) { $indexes = $this->schema->getIndexes($table); if ($this->isManyToManyRelationship($foreigns, $indexes['unique'])) { $this->compileManyToManyRelationship($foreigns, $table); } else { foreach ($foreigns as $name => $foreign) { $this->compileOneToRelationship($foreign, $name, in_array($name, $indexes['unique']), $table); } } }