Have you ever found yourself in the situation where you need to rebuild and reconnect you Firebase database and storage bucket to your app? Whether it's because you've made a mistake, or there are data or database issues? Having just been through that exact scenario, after seven months of development, it's not the nicest of problems to overcome. So, in the spirit of community, I thought I would share how I resolved this issue, in case any of you face the same, and for those of you who wonder how you might deal with such an issue.
By trial and error, creating and deleting Firebase projects, I worked out the correct sequence to follow in order to reconnect my app to a new FB database and storage bucket. Following these steps, I was able to get FB and FF talking to each other. Now, whilst you might rightly say that FF already has a guide on how to do this in a "normal" scenario, the issue I had was that, because I already had the schema defined in FF, and in particular, the USERS collection, when I completed the steps laid out in the official guide, I couldn't authenticate users. I believe the reason for this is that, in the automated setup offered by FF, it doesn't always make the connection between the FF Users schema and FB if this is already set up. It's why FF offers to create a default USERS collection when you start a new project.
I hope it is of use to others, and more informed colleagues may well jump in to advise if this is the way to do things or if there is a better way. As everyone else, I am on a journey of learning. I hope this is of help to you
Navigating through the complex process of reconnecting your FlutterFlow app to a new Firebase Firestore database can be daunting, especially after months of development. Here's a concise guide on how to overcome this challenge based on personal experience, aimed at helping fellow developers who might face similar issues. This guide is particularly useful during development stages and should be approached with caution if data preservation is crucial. Remember, this process is not about backing up and restoring Firebase databases but rather a method to reconnect an app to a new database setup.
Step-by-Step Guide to Reconnecting Your App to Firebase
Preparation:
Prior to facing any database issues, use tools like Firefoo to export records from your Firebase database into CSV files for future restoration. This is crucial for preserving data (excluding storage data) in a new database. Firefoo also allows downloading the schema for documentation purposes.
Duplicate Your App:
Begin by duplicating your existing app within the FlutterFlow environment from the Dashboard. This ensures you have a backup before making significant changes.
Open Your Cloned App:
Navigate to Settings > Firebase in your cloned app. This is where you'll manage the connection to Firebase.
Reconnect to Firebase:
The process involves trial and error with creating and deleting Firebase projects to establish a new connection. The key is to ensure that FlutterFlow's Users collection schema is effectively linked to Firebase's authentication system.
Essential Steps in FlutterFlow:
A. Duplicate your FlutterFlow project.
B. Open the duplicated project and navigate to Settings > Firebase.
C. Clear any existing Firebase Project ID.
D. Use FlutterFlow's "Create Project" button to set up a new Firebase project.
E. Set up Email Authentication and Firebase Storage through FlutterFlow.
F. Upgrade to the Firebase Blaze plan if necessary, especially for functionalities like "Delete User References."
G. Auto-generate config files in FlutterFlow.
Configure Firestore Settings:
Within FlutterFlow, toggle the Users Collection switch OFF and then ON again, inputting the collection name as prompted. This critical step ensures the connection between your Users collection and Firebase authentication.
Deploy Firestore Rules and indexes, and, if on a Blaze plan, deploy "Delete User References."
Final Steps:
With the connection re-established, you can now use something like Firefoo to import your previously exported CSV files back into the new Firebase database. Note that importing User documents is not advised due to potential authentication mismatches.
This guide encapsulates the journey of rebuilding and reconnecting a Firebase database to a FlutterFlow app, distilled from firsthand experience. While this method worked in a specific scenario, the community is encouraged to share improvements or alternative approaches. Always remember, learning and adaptation are key components of development.