-
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, support for geospatial data, and robust scalability.
The complete ERD and schema documentation are hosted on dbdocs.io:
π View the full schema on dbdocs.io
- Tables: Users, Incidents, Resources, Audit Logs, etc.
- Relationships: Foreign keys and associations between tables.
- Indexes: Optimized for search and query performance.
- Descriptions: Detailed explanations of each table and attribute.
Follow these steps to set 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 example environment variables file:
cp .env.example .envRun the following Rails command to set up the database:
rails db:setupThis will:
- Create the database.
- Run migrations.
- Seed it with initial data.
We use the db/seeds.rb file to prepopulate the development database with realistic data.
rails db:seed- Default user roles (Admin, Guest, etc.).
- Sample incidents for testing.
- Mock resources like ambulances, hospitals, and rescue units.
- 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.
- PostgreSQL roles and privileges enforce the principle of least privilege for both application and administrative users.
- All database connections use SSL/TLS to protect data in transit.
- Access is restricted to trusted IPs or verified Heroku apps.
- Sensitive information is encrypted at rest when supported by the hosting provider.
- The application avoids logging or exposing confidential data.
- Separate databases are used for development, testing, and production to prevent accidental modifications or data leaks.
- Database logs and access patterns are monitored to detect suspicious activity or unauthorized access attempts.
- Backups are performed automatically and periodically using Heroku Postgres tools, ensuring recoverability in case of data loss or corruption.
- Regular snapshots are scheduled based on usage and changes.
- Heroku manages retention policies, allowing restoration to any available point within the retention window.
π For more details about Heroku Postgres backups, see:
Heroku Postgres Documentation
- Always ensure migrations are atomic and reversible.
- Use
rails db:migrateto update the schema and confirm changes.
- After running migrations, ensure the
schema.rbfile is updated and committed to version control.
- Keep seed data minimal, clean, and realistic.
- Avoid overloading the database with unnecessary test data.
- If you suspect a security breach or data loss, contact the project administrators immediately.
- Regularly test database backups to ensure they can be restored successfully.
- For contributions to the data model, follow the established coding standards and conventions.
This page serves as a comprehensive resource for managing and maintaining the StateForce database. If you have questions or need assistance, feel free to reach out to the project team.
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.