core icon indicating copy to clipboard operation
core copied to clipboard

Nuxt Devtools Hub Database SQL Runner doesn't create indexes

Open ra-jeev opened this issue 1 year ago • 1 comments

Try creating a unique index using the Nuxt Devtools Hub Database SQL Runner.

E.g. the below query doesn't give any error, but doesn't create the index as well.

CREATE UNIQUE INDEX users_email_key ON users(email); 

Is there some way to run the wrangler commands to run D1 queries in the terminal in a NuxtHub project? To be specific, can I execute the below command for interacting with the local DB?

bunx wrangler d1 execute <db_name> --local --file=./schema.sql

If yes, then what should be the DB name? I tried default and ran the command from the root folder and got the below error:

✘ [ERROR] Couldn't find a D1 DB with the name or binding 'default' in wrangler.toml.

And running the command from .data/hub (with modified file path) folder creates a new local database (not visible to Nuxt Devtools).

ra-jeev avatar May 04 '24 07:05 ra-jeev

This is an issue related to Drizzle Studio, I contacted the team and should be fixed very soon. Will keep you updated when fixed.

atinux avatar May 15 '24 10:05 atinux

This should be fixed now @ra-jeev

Can you confirm?

atinux avatar May 24 '24 13:05 atinux

Just tested it, and it works fine now.

Thank you @Atinux 🙏

Also, is it possible to do this 👇 right now?

any way to run the wrangler commands to run D1 queries in the terminal in a NuxtHub project? If yes, how?

ra-jeev avatar May 24 '24 15:05 ra-jeev

@ra-jeev Sadly It is not working with the default configuration, because wrangler force a specific directory for local. However you can make it work by setting hub.dir = '.data/hub/v3' and using below command

npx wrangler d1 execute DB -c .data/hub/v3/wrangler.toml --local --file=./schema.sql --persist-to=.data/hub

@Atinux It seems that wrangler hard-coded v3 directory and there is no way to change that via config. WDYT about moving default hub directory from .data/hub to .data/hub/v3. With this change everyone be able to run wrangler command just like above command. Its' shame that wrangler force v3

farnabaz avatar Jul 12 '24 13:07 farnabaz

@ra-jeev Sadly It is not working with the default configuration, because wrangler force a specific directory for local. However you can make it work by setting hub.dir = '.data/hub/v3' and using below command

npx wrangler d1 execute DB -c .data/hub/v3/wrangler.toml --local --file=./schema.sql --persist-to=.data/hub

@Atinux It seems that wrangler hard-coded v3 directory and there is no way to change that via config. WDYT about moving default hub directory from .data/hub to .data/hub/v3. With this change everyone be able to run wrangler command just like above command. Its' shame that wrangler force v3

Thanks for the heads up @farnabaz. Will test it out and revert.

ra-jeev avatar Jul 15 '24 05:07 ra-jeev