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

@matejvelikonja matejvelikonja commented Oct 6, 2020

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

Fixes #34694

@taylorotwell
Copy link
Member

@taylorotwell taylorotwell commented Oct 6, 2020

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

@matejvelikonja
Copy link
Contributor Author

@matejvelikonja matejvelikonja commented Oct 6, 2020

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

@taylorotwell taylorotwell merged commit ad05060 into laravel:8.x Oct 6, 2020
7 checks passed
@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

@grEvenX grEvenX Oct 28, 2020

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.

3 participants