#!/usr/bin/env php
<?php
/*
 * Wrapper to call phinx with configuration file in a folder which does
 * not hold the "db" folder
 */
require_once(realpath(dirname(__FILE__)."/../config/config.php"));

$phinx_path = realpath(BASEDIR."/vendor/bin/phinx");
$config_path = realpath(BASEDIR."/config/phinx.php");
$default_args = ["--configuration=$config_path"];

$command = false;
$arguments = [];

if(count($argv) > 1) {
	$command = $argv[1];
	$arguments = array_slice($argv, 1);

  //var_dump($arguments);
	if(in_array($command, ["breakpoint", "create", "migrate", "rollback", "status", "test", "seed:create", "seed:run", "list:aliases"])) {
		$arguments = array_merge($default_args, $arguments);
	}
  //var_dump($arguments);
}

pcntl_exec($phinx_path, $arguments);
