Answers.Body: <p>Not sure how the database backup was created and what's being used to restore it, but using this would fix the error:</p>
  
  <pre><code>CREATE SEQUENCE IF NOT EXISTS 'public.assetindexdata_id_seq'
  </code></pre>
  
  <p>Alternatively, if you delete the database to destroy all of the associated metadata, then it shouldn't matter.</p>
  
  <p><a href="https://www.postgresql.org/docs/9.5/sql-createsequence.html" rel="nofollow noreferrer">https://www.postgresql.org/docs/9.5/sql-createsequence.html</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-09T17:18:53.067Z
Answers.Text: I used multiple methods with the same results, latest Craft backup but lets see if that works.
Answers.UserDisplayName: Jason McCallister
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-09T22:28:36.933Z
Answers.Text: This did the trick, there was a previous install on the database that was dropped but the sequence was still there. Thanks Brad!
Answers.UserDisplayName: Jason McCallister
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-09T03:29:58.933Z
Answers.LastActivityDate: 2019-07-09T03:29:58.933Z
Answers.UserDisplayName: Brad Bell
Body: <p>I'm using PostgreSQL locally and everything is working as expected. However, when I decided to move/restore the database to the staging environment I am getting this error (even through the tables do not exist).</p>
  
  <p>Has anyone experienced this before?</p>
  
  <pre><code>restore_pg_11.0: [archiver (db)] could not execute query: ERROR:  relation "assetindexdata_id_seq" already exists
      Command was: CREATE SEQUENCE public.assetindexdata_id_seq
      AS integer
      START WITH 1
      INCREMENT BY 1
      NO MINVALUE
      NO MAXVALUE
      CACHE 1;
  </code></pre>
  
Tags: <database><error><back-up>
Title: ERROR: relation "assetindexdata_id_seq" already exists on new database
ThreadText: # ERROR: relation "assetindexdata_id_seq" already exists on new database
  
  (Asked by: username_0 on 2019-07-08)
  
  I'm using PostgreSQL locally and everything is working as expected. However, when I decided to move/restore the database to the staging environment I am getting this error (even through the tables do not exist).
  
  Has anyone experienced this before?
  
  ```
  restore_pg_11.0: [archiver (db)] could not execute query: ERROR:  relation "assetindexdata_id_seq" already exists
      Command was: CREATE SEQUENCE public.assetindexdata_id_seq
      AS integer
      START WITH 1
      INCREMENT BY 1
      NO MINVALUE
      NO MAXVALUE
      CACHE 1;
  
  ```
  
  **Tags:** database, error, back-up
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-07-09. Score: 1 | Accepted answer
  
  Not sure how the database backup was created and what's being used to restore it, but using this would fix the error:
  
  ```
  CREATE SEQUENCE IF NOT EXISTS 'public.assetindexdata_id_seq'
  
  ```
  
  Alternatively, if you delete the database to destroy all of the associated metadata, then it shouldn't matter.
  
  <https://www.postgresql.org/docs/9.5/sql-createsequence.html>
  
  > **Comments:**
  > **username_0**: I used multiple methods with the same results, latest Craft backup but lets see if that works.  
  > **username_0**: This did the trick, there was a previous install on the database that was dropped but the sequence was still there. Thanks username_1!  
  
  ---
  
  