Skip to content

DataBase

Martin Mendoza edited this page May 8, 2025 · 5 revisions

πŸ“¦ Database Overview

Welcome to the StateForce database wiki page. This section serves as the central place to understand how our database is structured, how to run it locally, and how to contribute to its data model and structure.


πŸ› οΈ Database Engine

We use PostgreSQL as our relational database engine.

  • Version: >= 17.4
  • Chosen for: stability, strong data integrity, and support for geospatial data (via PostGIS, future-proofing our needs).

πŸ“ DB Schema & Documentation

The full ERD and schema documentation are hosted on dbdocs.io:

πŸ‘‰ View the full schema on dbdocs.io

This includes:

  • Tables and attributes
  • Relationships (FKs, associations)
  • Descriptions for each model

πŸš€ Getting Started Locally

To spin up the database in your local environment:

1. Install PostgreSQL

Make sure PostgreSQL is installed on your system (via Homebrew or another method):

brew install postgresql
brew services start postgresql
psql --version

2. Setup the Database

In your Rails project, run:

rails db:create db:migrate db:seed

3. Database Configuration

Check config/database.yml for credentials and connection settings and set the environment variables at .env file


🌱 Seed Data

We use a db/seeds.rb file to prepopulate the database to development: To seed the database:

rails db:seed

πŸ§ͺ Resetting the DB

To reset your local database:

rails db:reset

This will drop, recreate, migrate, and seed the database from scratch.


πŸ“Œ Notes

  • If you add or change models, always run rails db:migrate and ensure schema.rb is updated.
  • Migrations should be atomic and reversible.
  • Keep seed data minimal, clean, and realistic.

πŸ“š StateForce Wiki Sidebar

Welcome to the StateForce Wiki! Use this sidebar to navigate through the documentation.


🏠 Home


πŸ›  System Design


πŸ—„ Database


🎨 Design & Style


🚦 User Workflows


πŸ§ͺ Testing


πŸ“Ž Others

This sidebar provides quick access to all the documentation pages. For detailed information, click on the desired section.

Clone this wiki locally