tursodatabase / turso-cli

Command line interface to Turso.
https://turso.tech
MIT License
228 stars 37 forks source link

Do basic dump file validation before uploading it #870

Closed athoscouto closed 5 months ago

athoscouto commented 5 months ago

Usage:

➜  turso-cli git:(main) ✗ turso db create --from-dump foo
Error: could not open file foo: open foo: no such file or directory
➜  turso-cli git:(main) ✗ sqlite3 foo "create table a(a)"
➜  turso-cli git:(main) ✗ turso db create --from-dump foo
Error: invalid dump file: you're trying to use a SQLite database file as a dump. Use the --from-db flag instead of --from-dump
➜  turso-cli git:(main) ✗ echo "not a dump" > foo.dump
➜  turso-cli git:(main) ✗ turso db create --from-dump foo.dump
Error: invalid dump file: file doens't look like a dump: first line should be 'PRAGMA foreign_keys=OFF;'
➜  turso-cli git:(main) ✗ sqlite3 foo .dump > foo.dump
➜  turso-cli git:(main) ✗ turso db create --from-dump foo.dump
Uploaded data in 1 seconds.

Created database able-blackout at group local in 3.219s.

Start an interactive SQL shell with:

   turso db shell able-blackout

To see information about the database, including a connection URL, run:

   turso db show able-blackout

To get an authentication token for the database, run:

   turso db tokens create able-blackout

Motivation: today uploading an incorrect dump fails silently.