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

Exception restoring psql dump in 8.8 #34694

Closed
matejvelikonja opened this issue Oct 5, 2020 · 8 comments · Fixed by #34711
Closed

Exception restoring psql dump in 8.8 #34694

matejvelikonja opened this issue Oct 5, 2020 · 8 comments · Fixed by #34711
Assignees

Comments

@matejvelikonja
Copy link
Contributor

matejvelikonja commented Oct 5, 2020

  • Laravel Version: 8.8.0
  • PHP Version: 7.4.11
  • Database Driver & Version: postgres 12.4

Description:

After upgrading to Laravel 8.8., migration failed to restore migration squash created in previous version of Laravel.

Error Output:
================
pg_restore: error: input file appears to be a text format dump. Please use psql.

Steps To Reproduce:

  • Run php artisan schema:dump --prune in 8.7
  • Upgrade to 8.8
  • Clear database and run migrations.

I think the issue happens in this commit fcf175b.

The other question is, why changing from text dump to binary dump, as binary dump is not visible in VCS?

@taylorotwell
Copy link
Member

I think you will have to re-dump, because we had some problems with previous version of schema dump.

@matejvelikonja
Copy link
Contributor Author

But what's the reasoning to move from plain text dump to custom-format archive suitable for input into pg_restore?
Is it not better to have plain text dumps in VCS instead of a binary one?

@taylorotwell
Copy link
Member

I don't really know except that it was part of this PR that fixed an issue:

#34281

#34293

@matejvelikonja
Copy link
Contributor Author

@mfn, @d-stephane would you mind to reason why going for binary dump?

@d-stephane
Copy link

d-stephane commented Oct 6, 2020

Install laravel with a version lower than 8.8 and start the migration.
Then do "php artisan schema: dump --prune" and look in the generated file. You will find at the end this:

INSERT INTO public.migrations VALUES (1, '2014_10_12_000000_create_users_table', 1);
INSERT INTO public.migrations VALUES (2, '2014_10_12_100000_create_password_resets_table', 1);
INSERT INTO public.migrations VALUES (3, '2019_08_19_000000_create_failed_jobs_table', 1);

If you have to install this project on another server you will have to start the migration.
It is the file obtained with the dump that will be loaded and not the migration files because "--prune" option used.
Until then everything works. If you add and run new migration -> error !
Look in the database of your new project:

test3=# SELECT * FROM migrations_id_seq;
 last_value | log_cnt | is_called 
------------+---------+-----------
          1 |      32 | t

The value of last_value is incorrect.
With a pg_dump -Fc I don't have this problem.
I don't know if it's clear

PS : sorry for my bad English.....

@matejvelikonja
Copy link
Contributor Author

@d-stephane ah, I see. I've also encountered this issue, but I have fixed it manually.

However, I don't like having a binary file in the VCS. Since you don't see changed in the schema. But if there is no other option....

Ok, at least this change has to be somehow marked in the changelog. And it's a breaking change, since schema dump from <8.8 does not work in 8.8.

@taylorotwell
Copy link
Member

If someone has a fix without switching to the binary dump let me know.

@matejvelikonja
Copy link
Contributor Author

🤔 maybe at least support for both pg_restore and psql command could be added in here based on the $path.

They you could at least use php artisan migrate --seed --schema-path=database/schema/pgsql-schema.sql...

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

Successfully merging a pull request may close this issue.

4 participants