/** * Revert back your migrations. * * @return void */ public function down() { //Roll back your changes done by up method. Schema::make('product', function ($table) { $table->drop(); }); }
/** * we will prepare query except columns given in model * and assign it to selectColumns to find the results */ private function prepareExceptColumns() { $ar = self::cyrus(); // we will get the table schema $select = Schema::make($this, function ($table) use($ar) { $table->database = $ar->getDatabase(); $table->tableName = $ar->getTableName(); return $table->getColumns(); }); $columns = $this->query($select->schema)->getAll(); // Get all column name which need to remove from the result set $exceptColumns = $ar->skip(); $columnArray = []; foreach ($columns as $key => $value) { if (!in_array($value->COLUMN_NAME, $exceptColumns)) { $columnArray[] = $value->COLUMN_NAME; } } $this->_selectColumns = (string) implode(',', $columnArray); }
/** * @param string $tableName */ public function makeMigration($tableName = 'migrations') { $this->connect(trim($this->getDefaultDatabaseConnection()), $tableName); //Create migration table in order to save migrations information Schema::make($this, function ($table) use($tableName) { $table->tableName = $tableName; $table->database = trim($this->getDefaultDatabaseConnection()); $table->create(array(array('column' => 'id', 'type' => 'int', 'length' => 11, 'increment' => true, 'key' => 'primary'), array('column' => 'migration', 'type' => 'string', 'length' => 255), array('column' => 'version', 'type' => 'int', 'null' => true), array('column' => 'created_at', 'type' => 'datetime')), 'InnoDB', 'latin1')->run(); }); }
/** * @param string $tableName */ public function makeMigration($tableName = 'migrations') { $this->connect(trim($this->getDefaultDatabaseConnection()), $tableName); //Create migration table in order to save migrations information Schema::make($tableName, function ($table) { //$table->tableName = $tableName; $table->on(trim($this->getDefaultDatabaseConnection())); $table->create([['column' => 'id', 'type' => 'int', 'length' => 11, 'increment' => true, 'key' => 'primary'], ['column' => 'migration', 'type' => 'string', 'length' => 255], ['column' => 'version', 'type' => 'int', 'null' => true]], 'InnoDB', 'latin1'); }); }