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

atlas migrate apply --url $DATABASE_URL fails #2509

Open
domenkozar opened this issue Feb 3, 2024 · 7 comments
Open

atlas migrate apply --url $DATABASE_URL fails #2509

domenkozar opened this issue Feb 3, 2024 · 7 comments

Comments

@domenkozar
Copy link

Error: sql/migrate: execute: read revisions: pq: relation "atlas_schema_revisions.atlas_schema_revisions" does not exist

Using Atlas 0.18.

@a8m
Copy link
Member

a8m commented Feb 3, 2024

Hey, @domenkozar 👋

migrate apply is one of the most frequently used Atlas commands, so I suspect there may be something incorrect in your setup unless I'm overlooking something.

If the atlas_schema_revisions table resides in its own schema, it means you are operating on the entire database (or multiple schemas), not just a single one - is it correct? Could you please provide a few commands that reproduce this issue, similar to the one below?

image

@domenkozar
Copy link
Author

I'm not sure what else to provide, I'm using https://neon.tech/ for postgres store.

--revisions-schema public workarounds the issue.

@a8m
Copy link
Member

a8m commented Feb 18, 2024

Hey! Just fyi, I found the issue for this - neondatabase/neon#3148. TL;DR, Neon does not respect the search_path parameter and we'll need to work around this.


Important

Update: Neon users, please use: --revisions-schema public until the issue is resolved in Neon side, or Atlas has a special handling for Neon-based URLs.

@jakubno
Copy link

jakubno commented Sep 3, 2024

@a8m I have the same problem. On a brand new database created on Supabase I am getting:

Error: upsert revision-table id: pq: relation "atlas_schema_revisions.atlas_schema_revisions" does not exist

But atlas_schema_revisions table is present in public schema.

I am running:

atlas migrate apply --env local --url $(POSTGRES_CONNECTION_STRING) --baseline "20000101000000"

I am on:

atlas version v0.27.0

and my atlas.hcl:

// Define an environment named "local"
env "local" {
  // Declare where the schema definition resides.
  // Also supported: ["file://multi.hcl", "file://schema.hcl"].
  src = "ent://pkg/schema/"

  // Define the URL of the Dev Database for this environment
  // See: https://atlasgo.io/concepts/dev-database
  dev = "docker://postgres/15/dev"

  migration {
    // Define the path to the migration directory.
    // See: https://entgo.io/docs/migrate/#migration-directory
    dir = "file://migrations"
  }

  diff {
    skip {
      drop_func = true
      drop_trigger = true
      drop_schema = true
    }
  }
}

If you need anything else, let me know, happy to provide more info.

@NolanTrem
Copy link

+1 for @jakubno 's issue here with Supabase.

We're using Hatchet, who uses Atlas, in R2R and I see: relation "atlas_schema_revisions.atlas_schema_revisions" does not exist for their migrations.

@nkuz2
Copy link

nkuz2 commented Sep 18, 2024

+1 @jakubno 's issue with Supabase as well @a8m, do you have any thoughts on this besides those mentioned in #2601?

@a8m
Copy link
Member

a8m commented Sep 18, 2024

If the schema revisions table resides in the public schema, you need to set: --revisions-schema public. That's probably because the database you're using does not respect the search_path parameter (like explained here).

By default, Atlas uses the atlas_schema_revisions schema when the scope of work is "database" and not "schema" (you can read more about it here).

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

No branches or pull requests

5 participants