ariga / atlas

Manage your database schema as code
https://atlasgo.io
Apache License 2.0
5.98k stars 266 forks source link

Error: sql/sqlclient: unknown driver "libsql+ws". See https://atlasgo.io/url #2274

Closed zestsystem closed 1 year ago

zestsystem commented 1 year ago

Hello I've been following the issue #1951, which was finally solved by #2010 seemingly making local development with sqld possible. But I am still met with the Error: sql/sqlclient: unknown driver "libsql+ws". See https://atlasgo.io/url when I try to use atlas schema apply command against the local sqld instance. I am currently on v.0.15.0 of atlas.

I start my sqld process that listens on port 6969 with this:

  turso dev --db-file db-file --port 6969

My atlas hcl:

variable "destructive" {
  type    = bool
  default = false
}

variable "token" {
  type    = string
  default = getenv("TURSO_DB_AUTH_TOKEN")
}

env "dev" {
  url     = "libsql+ws://localhost:6969"
  exclude = ["_litestream*"]
}

env "turso" {
  url     = "libsql+wss://${getenv("TURSO_DB_PRL")}?authToken=${var.token}"
  exclude = ["_litestream*"]
  diff {
    skip {
      drop_schema = !var.destructive
      drop_table  = !var.destructive
    }
  }
}

my atlas apply command

atlas schema apply --env=dev --var destructive=true --to file://schema.hcl

My guess is that connecting to turso using a configuraton file has been left out and still only accepts wss:// scheme?

https://atlasgo.io/guides/sqlite/turso (this doc only mentions libsql+wss://)

giautm commented 1 year ago

Hello, I ran your script without any issue on the canary version of atlas-cli. You can install that version using this script

curl -sSf https://atlasgo.sh | sh

Please try again and let me know if the issue still existing. Also, we have a guide for turso here: https://atlasgo.io/guides/sqlite/turso

Screenshot 2023-11-10 at 16 28 58
zestsystem commented 1 year ago

Ok I figured out where its going wrong... My nix flake for atlas v0.15.0 is failing to build so I was probably using v0.14.1 as fallback. Weird how it would show me the version 0.15.0 on atlas version though.

While 0.14.1 is built just fine, 0.15.0 fails to build.

Screenshot 2023-11-12 at 11 16 49 AM

I think the problem is introduced with this change: cmd/internal/sqlparse/pgparse: move to pgquery (https://github.com/ariga/atlas/pull/2143)

Maybe this is relevant: https://discourse.nixos.org/t/trouble-packaging-sqlc/18261/9

My undertanding of go and nix isn't deep enough to be certain though. Will continue to explore this more.

zestsystem commented 1 year ago

The issue has been resolved with this PR:

https://github.com/NixOS/nixpkgs/pull/267409