Skip to content

Commit

Permalink
support psql and pg_restore commands in schema load (#34711)
Browse files Browse the repository at this point in the history
* support psql and pg_restore command in schema load

* Update PostgresSchemaState.php

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
matejvelikonja and taylorotwell committed Oct 6, 2020
1 parent 54c7151 commit ad05060
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Illuminate/Database/Schema/PostgresSchemaState.php
Expand Up @@ -51,7 +51,13 @@ protected function appendMigrationData(string $path)
*/
public function load($path)
{
$process = $this->makeProcess('PGPASSWORD=$LARAVEL_LOAD_PASSWORD pg_restore --host=$LARAVEL_LOAD_HOST --port=$LARAVEL_LOAD_PORT --username=$LARAVEL_LOAD_USER --dbname=$LARAVEL_LOAD_DATABASE $LARAVEL_LOAD_PATH');
$command = 'PGPASSWORD=$LARAVEL_LOAD_PASSWORD pg_restore --host=$LARAVEL_LOAD_HOST --port=$LARAVEL_LOAD_PORT --username=$LARAVEL_LOAD_USER --dbname=$LARAVEL_LOAD_DATABASE $LARAVEL_LOAD_PATH';

if (preg_match('/\.sql$/', $path) !== false) {
$command = 'PGPASSWORD=$LARAVEL_LOAD_PASSWORD psql --file=$LARAVEL_LOAD_PATH --host=$LARAVEL_LOAD_HOST --port=$LARAVEL_LOAD_PORT --username=$LARAVEL_LOAD_USER --dbname=$LARAVEL_LOAD_DATABASE';
}

$process = $this->makeProcess($command);

$process->mustRun(null, array_merge($this->baseVariables($this->connection->getConfig()), [
'LARAVEL_LOAD_PATH' => $path,
Expand Down

0 comments on commit ad05060

Please sign in to comment.