nuxt-hub / core

Build full-stack applications with Nuxt on CloudFlare, with zero configuration.
https://hub.nuxt.com
Apache License 2.0
991 stars 57 forks source link

Nuxt Devtools Hub Database SQL Runner doesn't create indexes #94

Closed ra-jeev closed 3 months ago

ra-jeev commented 6 months ago

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).

atinux commented 6 months ago

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 commented 5 months ago

This should be fixed now @ra-jeev

Can you confirm?

ra-jeev commented 5 months ago

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?

farnabaz commented 4 months ago

@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

ra-jeev commented 4 months ago

@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.