When starting the emulator I see 2 databases in the realtime database emulator. One with <project id> and the other <project id>-default-rtdb .

Can anybody explain or reference some docs on why this is?
This is my setup files
firebase.json
{
"database": {
"rules": "database.rules.json"
},
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
],
"source": "functions"
},
"emulators": {
"auth": {
"port": 9099
},
"functions": {
"port": 5001
},
"database": {
"port": 9000
},
"pubsub": {
"port": 8085
},
"ui": {
"enabled": true
}
}
}
functions/package.json
{
"name": "functions",
"scripts": {
"lint": "eslint --ext .js,.ts .",
"build": "tsc",
"serve": "npm run build && firebase emulators:start --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "14"
},
"main": "lib/index.js",
"dependencies": {
"firebase-admin": "^9.8.0",
"firebase-functions": "^3.14.1"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^3.9.1",
"@typescript-eslint/parser": "^3.8.0",
"eslint": "^7.6.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-import": "^2.22.0",
"firebase-functions-test": "^0.2.0",
"typescript": "^3.8.0"
},
"private": true
}
So I just figured it out. Adding a "database" section to the top level of the firebase.json file makes the emulator create 2 databases. Additionally, if the name of the project in .firebaserc starts with demo AND there's a "database" section added to the top level of your firebase.json file then there will be 3 total Realtime Databases created.
So, having a firebase.json file that looks like this:
{ "database": {
"rules": "database.rules.json"
},
"functions": [
{
"source": "functions",
"codebase": "default",
"ignore": [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log"
]
}
],
"emulators": {
"auth": {
"port": 9099
},
"database": {
"port": 9000
},
"ui": {
"enabled": true
},
"singleProjectMode": true
}
}
and a .firebaserc file that looks like this:
{
"projects": {
"default": "demo-MyProject-development"
}
}
results in 3 databases being created.
I've decided that that I'm going to go without adding the rules file to my firebase.json (thus removing the "database" section from the file) and writing the rules manually into the browser.
My files now look like this:
firebase.json
{
"functions": [
{
"source": "functions",
"codebase": "default",
"ignore": [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log"
]
}
],
"emulators": {
"auth": {
"port": 9099
},
"database": {
"port": 9000
},
"ui": {
"enabled": true
},
"singleProjectMode": true
}
}
.firebaserc
{
"projects": {
"default": "MyProject-development"
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With