how can I truncate all tables in the new drizzle studio? Previously there was a drop down button
tsia
5 Replies
Hi, @shikishikichangchang! As for now, there is no such option, but it will be added in the future
Thanks that would be really helpful. Why was that feature removed?
As I know it's due to studio redesign
I have created 2 files + 1 script to do it from the terminal. Just copy and paste them and you should be fine. Edit them to suit your needs.
This code will be executed using the
tsx
package. It asks a confirmation twice before executing. You can edit the prompts as you wish.
Here's the file that will be executed by the exec
function after the 2 confirmations (don't forget to edit the command in the function to match your file path).
In my implementation, I totally drop the tables. If you just want to truncate them (deleting all of the rows but keeping the table), change DROP TABLE
to TRUNCATE TABLE
Now add this script into your package.json
file:
Edit it to match the path of the file containing the prompts. You can change the script command as well.
Now you can use pnpm db:drop
in your terminal. It will trigger the prompts and after 2 confirmations, it will execute the drop/truncation function.thanks!