Example #1
0
	/**
	 *
	 *
	 *
	 */
	public function action_migrate() {
		// only accessible via the command line
		if (!Kohana::$is_cli)
		{
			throw new HTTP_Exception_403('Access via CLI only');
		}

        // try and ensure the cache and log dirs are writeable
        @chmod(APPPATH.'/cache', 0777);
        @chmod(APPPATH.'/logs', 0777);

		// get the parameters
		$connection = $this->request->param('connection', NULL);
		$to_version = $this->request->param('to_version', NULL);
		$from_version = $this->request->param('from_version', NULL);

		$migration = new Model_Migration($connection);

		if($from_version === NULL)
		{
			$from_version = $this->get_schema_version();
		}
		$migration->set_schema_version($from_version);
		
		if ($to_version === NULL)
		{
			$to_version = $this->get_app_version();
		}

		if($migration->migrate_to($to_version))
		{
			$this->after_migrate($migration);
		}
	}