-
Notifications
You must be signed in to change notification settings - Fork 0
DataBase
Welcome to the StateForce database wiki page. This section serves as the central hub for understanding how our database is structured, how to run it locally, and how to contribute to its data model.
We use PostgreSQL as our relational database engine.
-
Version:
>= 17.4 - Chosen for: Stability, strong data integrity, and support for geospatial data.
The complete ERD and schema documentation are hosted on dbdocs.io:
π View the full schema on dbdocs.io
This includes:
- Tables and attributes
- Relationships (foreign keys, associations)
- Descriptions for each model
- Table index usage
To spin up the database in your local environment:
Ensure PostgreSQL is installed on your system:
psql --version
brew install postgresql
brew services start postgresqlCheck config/database.yml for credentials and connection settings.
Copy the environment variables file:
cp .env.example .envIn your Rails project, run:
rails db:setupThis will create the database, run migrations, and seed it from scratch.
We use the db/seeds.rb file to prepopulate the development database.
To seed the database:
rails db:seed-
Access Control Database access is restricted to authorized users and applications. Credentials are securely managed using environment variables and are never hardcoded or committed to version control.
-
Role-Based Permissions PostgreSQL roles and privileges are configured to enforce the principle of least privilege for both application and administrative users.
-
Network Security All database connections use SSL/TLS to protect data in transit. Access is restricted to trusted IPs or verified Heroku apps.
-
Sensitive Data Sensitive information is encrypted at rest when supported by the hosting provider. The application avoids logging or exposing confidential data.
-
Environment Separation Separate databases are used for development, testing, and production to prevent data leaks and accidental modifications.
-
Monitoring Database logs and access patterns are monitored to detect suspicious activity or unauthorized access attempts.
-
Automated Backups Backups are performed automatically and periodically using Heroku's built-in backup tools (Heroku Postgres), ensuring recoverability in case of accidental data loss or corruption.
-
Backup Frequency Regular snapshots are scheduled base use and changes.
-
Backup Retention Retention policies are managed by Heroku. Backups can be restored to any available point within the retention window.
For more details about Heroku Postgres backups, see: Heroku Postgres Documentation
- If you add or change models, always run
rails db:migrateand ensureschema.rbis updated. - Migrations should be atomic and reversible.
- Keep seed data minimal, clean, and realistic.
We are always looking for feedback and contributions to improve StateForce. Feel free to open issues, suggest edits, or submit pull requests to the repository.
- Repo: StateForce GitHub
- Contact: martinmendozadev@gmail.com
If you encounter issues or need assistance, please reach out via:
- Email: martinmendozadev@gmail.com
- GitHub Issues: Submit an Issue
This documentation and the StateForce platform are licensed under the Apache License 2.0.
Thank you for using StateForce! π¨
Together, we are improving emergency response operations in real-time.
Welcome to the StateForce Wiki! Use this sidebar to navigate through the documentation.
This sidebar provides quick access to all the documentation pages. For detailed information, click on the desired section.