Note that there are some explanatory texts on larger screens.

plurals
  1. POpsql ERROR: relation already exists
    primarykey
    data
    text
    <p>I'm writing a rails project using postgres and there is some data in the server. And I want dump the data from the remote end to the local, so I write script to do it, but some errors come out.</p> <p>This's the dump script:</p> <pre><code>run "PGPASSWORD='#{remote_settings['password']}' pg_dump -U #{remote_settings["username"]} #{"-h '#{remote_settings["host"]}'" if remote_settings["host"]} '#{remote_settings["database"]}' &gt; #{remote_sql_file_path}" </code></pre> <p>There's some codes to transport..</p> <pre><code>Transport codes </code></pre> <p>And this's the restore script:</p> <pre><code>run_locally "PGPASSWORD='#{local_settings['password']}' psql -U #{local_settings["username"]} -d #{local_settings["database"]} -f #{local_sql_file_path}" </code></pre> <p>I get the data file successfully, but when there're some <strong>ERRORs* when **restore script</strong> is run:</p> <pre><code>psql:tmp/production-ib5k_production-2013-02-21_18:42:09.sql:46: ERROR: relation "refinery_images" already exists psql:tmp/production-ib5k_production-2013-02-21_18:42:09.sql:49: ERROR: role "ib5k" does not exist psql:tmp/production-ib5k_production-2013-02-21_18:42:09.sql:60: ERROR: relation "refinery_images_id_seq" already exists psql:tmp/production-ib5k_production-2013-02-21_18:42:09.sql:63: ERROR: role "ib5k" does not exist psql:tmp/production-ib5k_production-2013-02-21_18:42:09.sql:83: ERROR: relation "refinery_page_part_translations" already exists psql:tmp/production-ib5k_production-2013-02-21_18:42:09.sql:86: ERROR: role "ib5k" does not exist ... sql:tmp/production-ib5k_production-2013-02-21_18:42:09.sql:525: ERROR: duplicate key value violates unique constraint "refinery_images_pkey" DETAIL: Key (id)=(1) already exists. CONTEXT: COPY refinery_images, line 2: "" psql:tmp/production-ib5k_production-2013-02-21_18:42:09.sql:547: ERROR: duplicate key value violates unique constraint "refinery_page_part_translations_pkey" DETAIL: Key (id)=(1) already exists. CONTEXT: COPY refinery_page_part_translations, line 8: "" psql:tmp/production-ib5k_production-2013-02-21_18:42:09.sql:569: ERROR: duplicate key value violates unique constraint "refinery_page_parts_pkey" DETAIL: Key (id)=(1) already exists. CONTEXT: COPY refinery_page_parts, line 8: "" ... </code></pre> <p>And the database in local will not be updated. I want to know how to solve it? Adding some arguments? Thank you in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload