Issue #1 new

Postgres error: relation "goose_db_version" already exists

Josh Bleecher Snyder
created an issue

Running any goose command I now get:

pq: L:"1013" R:"heap_create_with_catalog" S:"ERROR" M:"relation \"goose_db_version\" already exists" C:"42P07" F:"heap.c"

This is a newly introduced issue, sometime since 039efed. It happens only in my prod environment, not dev.

I will look into it over the next week, although it will be a slow process thanks to go's lack of support for specifying commits in import statements. :(

Filing this here in the interim in case someone else just knows the answer offhand.

Comments (6)

  1. Liam Staskawicz repo owner

    Oh - without any deeper investigation, this is likely due to the fact that there were a couple schema changes to the internal goose_db_version table.

    It would probably be best to provide a "meta" migration for this, to account for existing version records, but I haven't created such a thing just yet.

  2. Josh Bleecher Snyder reporter

    Liam Staskawicz sounds right. I'll just drop and recreate for now. I can see that you would want to give the meta-migrations thing some thought, to avoid needing meta-meta-migrations. :)

    I'm also happy to help design and/or implement meta-migrations when the time comes.

  3. yaccz

    I'm just doing first steps with goose and I hit this error.

    I created my first migration on my workstation with goose create, uploaded things to my server and now whether I run goose status or goose up I get this error.

    This seemed weired to me even before I installed it, because I don't see nowhere something like goose init to create the goose metadata about database as is usual with db migration tools.

    And now I have to go read the source to figure out how to execute the createVersionTableSql() and whatever else it needs.

  4. yaccz

    It appears that in order to run the creation of metadata table the code expects errors.New("table does not exist") while returned is actually pq: relation "goose_db_version" does not exist

  5. Log in to comment