diff --git a/bin/craft-copy-import-db.php b/bin/craft-copy-import-db.php index 41cfdee..7a30ca0 100755 --- a/bin/craft-copy-import-db.php +++ b/bin/craft-copy-import-db.php @@ -26,11 +26,6 @@ $dotenv->load(); } -// Bootstrap Craft -/** @var \craft\console\Application $app */ -define('CRAFT_ENVIRONMENT', getenv('ENVIRONMENT') ?: 'production'); -$app = require $root . '/vendor/craftcms/cms/bootstrap/console.php'; - if (count($argv) < 2 || stristr($argv[1], '.sql') == false) { echo "No import file given"; exit(1); @@ -52,27 +47,14 @@ exit(1); } -if ($app->getIsInstalled()) { - echo "Craft is already installed!" . PHP_EOL; - if (!in_array('--force', $argv)) { - echo "Abort. No --force flag given." . PHP_EOL; - exit(1); - } -} - -if (!$app->getConfig()->getDb()->password) { - echo "No DB Config found." . PHP_EOL; - exit(1); -} -$db = $app->getConfig()->getDb(); $cmd = 'mysql -u {DB_USER} -p{DB_PASSWORD} -h {DB_SERVER} {DB_DATABASE} < {file} && echo 1'; $tokens = [ '{file}' => $file, - '{DB_USER}' => $db->user, - '{DB_PASSWORD}' => $db->password, - '{DB_SERVER}' => $db->server ?: getenv('DB_SERVER'), - '{DB_DATABASE}' => $db->database ?: getenv('DB_DATABASE'), + '{DB_USER}' => getenv('DB_USER'), + '{DB_PASSWORD}' => getenv('DB_PASSWORD'), + '{DB_SERVER}' => getenv('DB_SERVER'), + '{DB_DATABASE}' => getenv('DB_DATABASE'), ]; $cmd = str_replace(array_keys($tokens), array_values($tokens), $cmd);