0

I created a database in the Firebase Realtime project, but now it seems that the location I picked was not the best choice, therefore I wanted to migrate the data.

It turns out that there is no possibility to automatically move/migrate the database, so I figured I would remove the invalid DB, create a new one and set it as default, then remove the old one.

Unfortunately, it seems that this is impossible as the default database doesn't have 'Delete' option as documentation mentions. API methods for firebase admin management don't have this feature listed as well.

The question is: is it possible / how to set another database as a default one?

Thanks and best regards!

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
user1013607
  • 115
  • 2
  • 13
  • When you initialize firebase, you can pass it a set of options, such as the database you want to use. You can get the database name\ref from firebase console. – Huthaifa Muayyad Nov 09 '21 at 08:17

1 Answers1

1

It turns out that there is no possibility to automatically move/migrate the database.

Yes, there is no way you can change the default location of the database, once it was created.

The question is: is it possible / how to set another database as a default one?

No, you cannot create "another" default database. What you can do, however, is to create a new instance of the Realtime Database that can be located in a totally different location than the default one. According to the official documentation of the Realtime Database locations:

If you create a new Realtime Database instance, you're prompted to select the location of the instance in the Firebase console workflow. Each Realtime Database instance in your project can be located in a different location. The currently supported locations for Realtime Database instances are listed below along with their associated database URL schemes.

And then use it accordingly. It's not the default one, but it will indeed do the job.

Please also see below, how you can set a different the location to a database:

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
  • Thank you for the reply! However I encountered another issue. Now when I try to deploy functions, which are the database triggers, they seem to be listening to the default database. It also seems there is CLI api for database:profile where I can pass --instance parameter, but it fails. By any chance is there a way to specify Realtime Databse instance during functions deploy? – user1013607 Nov 09 '21 at 09:49
  • Without seeing the code, I cannot be much of a help. So please post a new question, here on StackOverflow, using its own [MCVE](https://stackoverflow.com/help/mcve), so I and other Firebase developers can help you. – Alex Mamo Nov 09 '21 at 09:52