Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Support psql and pg_restore commands in schema load #34711

Merged
merged 2 commits into from Oct 6, 2020
Merged

[8.x] Support psql and pg_restore commands in schema load #34711

merged 2 commits into from Oct 6, 2020

Conversation

matejvelikonja
Copy link
Contributor

This PR adds support for schema restore for psql driver from either .sql or .dump files.

Fixes #34694

@taylorotwell
Copy link
Member

How is this going to fix it? Are you passing the --path option explicitly to the command?

@matejvelikonja
Copy link
Contributor Author

yes, via php artisan migrate --schema-path=database/schema/pgsql-schema.sql

@taylorotwell taylorotwell merged commit ad05060 into laravel:8.x Oct 6, 2020
@GrahamCampbell GrahamCampbell changed the title support psql and pg_restore commands in schema load [8.x] Support psql and pg_restore commands in schema load Oct 6, 2020
$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) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this line is wrong. When I'm trying to dump and do a fresh migrate now I get an error due to the fact that it's trying to load a .dump file using psql instead of pg_restore.

I believe if (fnmatch('*.sql', $path)) might be an easier option here. preg_match does not give a boolean result, it returns an int value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exception restoring psql dump in 8.8
3 participants