Deleting Entire Database and all Documents

I’m finding the fwitter a fantastic source of helpful information and everyday I’m learning something new from it.

One thing I realised today is I am often deleting databases from the dashboard after some of my tests while I learn the product.

From reading this https://github.com/fauna-brecht/fwitter/blob/d36a82e18a601fff7083504928e42fc6eb916b4d/scripts/destroy.js
It deletes all the roles, udf etc. before calling delete on the database.

  1. Is this the recommended way and why?

Ideally I’d like to know if its possible to be charged storage for deleted data etc?

Thank you :slight_smile:
Glad to see that my efforts help people.

It deletes all the roles, udf etc. before calling delete on the database.

That’s not exactly what the code is doing (or I might have made a small logic mistake). There are actually two ways the logic in the setup/destroy scripts work for my own convenience while working on it:

  • Nuke the whole database and recreate it

  • Destroy all resources and recreate them.

The first has the disadvantage that that requires extra explanation, it basically uses a key of a parent database and the whole application works on a child database that is created in that parent database. I use a child database to make sure that if I nuke the database I don’t lose the admin key which I use for the setup scripts.

The second is the default and has the disadvantage that you have to wait for ±60 seconds for cached roles/function names to disappear since you are reusing the same database.

  1. Is this the recommended way and why?

I assume this is less relevant due to my answer on the previous question. But to be clear, all of this is my approach. At this point, we do not have a recommended official way to destroy/setup or define resources in a IaaC way. One of the articles I’d like to write will be about that, I think we can still improve much of the current Fwitter approach there. In that case, I’ll touch base with our engineering team to see whether my recommendations could be considered official. Until now, consider it as my approach that made sense to me.

Ideally I’d like to know if its possible to be charged storage for deleted data etc?

Not sure what you mean?

1 Like

thanks that makes sense.

I’d be interested to see what the community does for setup/destroy/iaac approaches. It’s something I’m trying to do atm and understand how graphql fits into to this.

Your last question isn’t needed as I missed your use of child databases. I imagined you were destroying resources implicitly because of a bug, as it’s due to using child databases, this makes more sense .

thank you!

One thing I did by accident is “Override Schema” in the graphql area of the dashboard and that definitely removed all of my UDFs and deleted all of my data and rebuilt the collection using whatever types I had defined in my schema.graphql. You could probably upload a schema.graphql file that does not define anything (or very little) and it would be the same as nuking. Also my client keys and everything still worked so I just had to reseed the database but it’s an option! :smiley: