protected function writeMigrations($res) {
		uasort($res, function($a, $b) {
			if(isset($a['migrated']) && !isset($b['migrated']))
				return -1;
			elseif(!isset($a['migrated']) && isset($b['migrated']))
				return 1;
			elseif(isset($a['migrated']) && isset($b['migrated'])) {
				if($a['migrated'] !== $b['migrated'])
					return $a['migrated'] > $b['migrated'];
			}
			return $a['added'] > $b['added'];
		});

		$migrations = [];
		foreach($res as $migration=>$params)
			$migrations[$migration] = ['added'=>$params['added']];

		file_put_contents($this->dir.'/migrations.json', json_encode($migrations, JSON_PRETTY_PRINT));
	}