Search code examples
ruby-on-railspostgresqlbackupdump

The dump file is not applied to the database (Rails, PostgeSQL)


I am applying a database backup file to my Rails project, but objects are not created in my database

(The dump (backup) file is at the root of the project)

My backtrace: sorry if it's too big, cut a lot

$ rake db:drop
Dropped database 'project_development'
Dropped database 'project_test'

$ rake db:create
Created database 'project_development'
Created database 'project_test'

$ psql project_development<dump
SET
SET
SET
SET
SET
 set_config 
------------
 
(1 row)

SET
SET
SET
SET
SET
SET
CREATE TABLE
ALTER TABLE
CREATE SEQUENCE
CREATE SEQUENCE
ALTER TABLE
ALTER SEQUENCE
ALTER TABLE
COPY 0
COPY 1
COPY 1
COPY 0
COPY 4
COPY 40
COPY 0
 setval 
--------
      1
(1 row)

 setval 
--------
      1
(1 row)

ALTER TABLE
CREATE INDEX
ALTER TABLE

Everything is successful, but the data does not appear

$ rails c
Contact.all
  Contact Load (0.5ms)  SELECT "contacts".* FROM "contacts" LIMIT $1  [["LIMIT", 11]]
=> #<ActiveRecord::Relation []>

Solution

  • There is a possibility that the Dump file is empty. Check its size, the presence of data in the file itself, whether the format is correct. In my case, most likely this solved the problem