-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Support for libsql and Turso #1042
base: master
Are you sure you want to change the base?
Conversation
@avezina-ubik Can you please correct the database connection uri in Should read
In your unit tests you correctly insert the Can you also add instructions on how to connect to a turso local dev/self-hosted server (e.g.:
@dhui this might be another reason to move to individual CI tasks for each database. Then we can spin up sideband docker services and test cli commands against live local db instances to ensure the cli commands also work. Cheers, Without the scheme in the connection string you will get the following error: > migrate -source file://./migrations -verbose --database "libsql://rando-db-bryanvaz.turso.io?authToken=[TOKEN]&query" up
2024/03/09 18:12:13 error: unsupported URL scheme:
This driver supports only URLs that start with libsql://, file://, https://, http://, wss:// and ws:// while this works: > migrate -source file://./migrations -verbose --database "libsql://https://rando-db-bryanvaz.turso.io?authToken=[TOKEN]" up
2024/03/09 18:15:09 Start buffering 20240309225149/u CreateCatCondoTable
2024/03/09 18:15:09 Read and execute 20240309225149/u CreateCatCondoTable
2024/03/09 18:15:09 Finished 20240309225149/u CreateCatCondoTable (read 79.775833ms, ran 122.719125ms)
2024/03/09 18:15:09 Finished after 219.338542ms
2024/03/09 18:15:09 Closing source and database |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update and test drop command - currently not working
return version, dirty, nil | ||
} | ||
|
||
func (d *LibSQL) Drop() (err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please write a test for the drop
command. It currently does not work:
❯ ./scripts/migrate drop
2024/03/09 18:46:33 Are you sure you want to drop the entire database schema? [y/N]
y
2024/03/09 18:46:34 Dropping the entire database schema
2024/03/09 18:46:34 error: failed to execute SQL: DROP TABLE sqlite_sequence
SQLite error: table sqlite_sequence may not be dropped in line 0: DROP TABLE sqlite_sequence in line 0: DROP TABLE sqlite_sequence
The following table is a libsql system table and should not be dropped:
sqlite_sequence
Additionally to cover most usecases:
- Please drop views using
DROP VIEW
before you drop tables. This list can be obtained via:SELECT name FROM sqlite_master WHERE type = 'table'
- The order of the tables in the
sqlite_master
is a hint as to the order in which they were created and thus any FK constraints; therefore you should drop the tables in reverse order to avoid hitting FK constraint issues.
- Fixed Drop failing when a table has AUTOINCREMENT - Updated README.md to explain URL scheme - Updated README.md to add instructions on how to connect to a turso dev
Hey @bryanvaz! Thanks for the review. I updated the README and tried to prioritez the Fixed the Drop() too |
Let me know if there is anything I can do to help this PR get merged. I would really like to see this happen soon |
Hey @avezina-ubik, thank you for moving this forward. Under notes, you write that Replacing with |
Hi @keenanwl I will update the README soon with github.com/tursodatabase/libsql-client-go. From what I understand (though I'm a bit confused by Turso's documentation):
The thing is, Correct me if I am wrong, but this project seems to require CGO_ENABLED=0: Line 17 in 04b36eb
So this is why I went with As for your issue I am not sure I understand quite well the problem since you can update your schema pointing at Turso's remote URL:
Your embedded replicas will then receive WALs and sync the changes. |
Hey guys, I noticed that using this driver to interact with a file (e.g. Besides a URL parsing issue (which can be easily fixed), there's also a dependency on a SQLite driver. Would it be acceptable for this database implementation to only support interacting with libsql servers? Here are my thoughts:
My suggestion (see last commit) :
If you prefer, I can import a SQLite driver and make it work. Regards |
Hi @avezina-ubik. Sounds reasonable. Looks like you are correct about cgo being disabled for the CLI - I didn't realize that was an issue, since I don't use it. However, when imported as a library, then sqlite3 migrations have been working fine for me (using: 1) and I assumed libsql would be a drop-in replacement (e.g. no If indeed most users are working with the CLI or Turso-remote, then yes, I would also agree that prioritizing |
Oh! I understand your problem now @keenanwl. I assumed you were using the CLI. Since you are already importing I thought about filing an issue with I am pretty sure you already thought about that, but to avoid importing |
It's not the cleanest but we could add a build tag to switch between |
Hey @avezina-ubik |
Don't think it's gonna happen to be honest. Best bet would be to fork a build and have you own Docker image. I am still using something like this : #1038 (comment) and it's been working great. |
Resolves #1038