I have created my first non (default) database but I'm struggling with updating it's security rules.
I'm using the firebase cli and I've tried:
firebase deploy --only firestore
firebase deploy --only firestore:<databaseid>
But in both cases the (default) database gets updated but not my new database.
Help? 🙂
Solved! Go to Solution.
Thanks for this, I'm afraid I made a stupid typo in my sample commands. I meant to type:
firebase deploy --only firestore
I eventually figured out the problem. I needed to manually add entries in my firebase.json file so that the "firestore" section was an array with an object for each database. e.g.
It seems you're facing some challenges with updating security rules for a non-default Firebase Realtime Database using the Firebase CLI. Let's clarify the correct commands and process:
Current Commands:
firebase deploy --only firebase
: This command is not specifically designed for deploying Realtime Database rules. It's more commonly used for deploying Firebase functions or hosting configurations.firebase deploy --only firebase:<databaseId>
: This syntax is not correct for deploying rules to Realtime Database instances. The <databaseId>
format is generally used for deploying specific Firebase functions or hosting sites, not for database rules.Correct Commands for Realtime Database:
firebase deploy --only database
: This command deploys the rules defined in database.rules.json
for the default Realtime Database instance.firebase deploy --only database:<targetName>
: To deploy rules to a non-default Realtime Database, you first need to define a target using the Firebase CLI and then deploy to that target. The <targetName>
is a custom name you assign to your database instance when setting up deployment targets.Setting Up Deployment Targets:
firebase use --add
to set up an alias for your Firebase project.firebase target:apply database <targetName> <databaseInstanceName>
, where <targetName>
is a custom name for your target, and <databaseInstanceName>
is the instance name of your non-default database.Deploying to a Non-Default Database:
firebase deploy --only database:<targetName>
to deploy your rules to the specified non-default database.Additional Points:
firebase.json
.Resources:
This should help you correctly update the security rules for your non-default Firebase Realtime Database.
Thanks for this, I'm afraid I made a stupid typo in my sample commands. I meant to type:
firebase deploy --only firestore
I eventually figured out the problem. I needed to manually add entries in my firebase.json file so that the "firestore" section was an array with an object for each database. e.g.
That's for documenting this, I spent hours pouring over the Firebase docs with no success. Your help saved me, thanks so much for sharing.