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

🐛 BUG: Cannot back up D1 DB with virtual tables #6305

Open
marksolly opened this issue Jul 22, 2024 · 1 comment
Open

🐛 BUG: Cannot back up D1 DB with virtual tables #6305

marksolly opened this issue Jul 22, 2024 · 1 comment
Labels
bug Something that isn't working d1 Relating to D1

Comments

@marksolly
Copy link

marksolly commented Jul 22, 2024

Which Cloudflare product(s) does this pertain to?

D1

What version(s) of the tool(s) are you using?

3.65.1

What version of Node are you using?

v20.14.0

What operating system and version are you using?

Linux Mint 21.3 (Kernel 5.15.0-113-generic)

Describe the Bug

Observed behavior

Wrangler exits with an error message when backing up a database that contains a virtual table.

Expected behavior

Virtual tables should be exported just like any other table, or ignored and the export should continue on tables which can be exported (with a warning). Under no circumstances should it be impossible to perform an export.

Steps to reproduce

  1. echo "CREATE VIRTUAL TABLE location_names_fts USING fts5(name, location_id UNINDEXED, tokenize='trigram');" > pending.sql
  2. npx wrangler d1 execute <database name> --remote --file=./pending.sql
  3. npx wrangler d1 export <database name> --remote --output=db_backup-22-07-2024.sql
  4. See error message: ✘ [ERROR] D1 Export error: cannot export databases with Virtual Tables (fts5)

Please provide a link to a minimal reproduction

Minimal reproduction provided in steps to reproduce

Please provide any relevant error logs

 ⛅️ wrangler 3.65.1
-------------------

🌀 Executing on remote database <REDACTED> (<REDACTED>):

✘ [ERROR] D1 Export error: cannot export databases with Virtual Tables (fts5)


If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose
✔ Would you like to report this error to Cloudflare? … yes
@marksolly marksolly added the bug Something that isn't working label Jul 22, 2024
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Jul 22, 2024
@marksolly
Copy link
Author

Attached is workaround for anyone else having the same problem. The attached script will download the database one table at a time, ignoring the virtual table you specify and then concatenate everything into one SQL file.
backup_db.js.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working d1 Relating to D1
Projects
None yet
Development

No branches or pull requests

2 participants