Keep EOS Schema
| EOSSchema.txt | ||
| README.md | ||
README — PostgreSQL Database Setup for EOS
This README provides instructions for creating and managing the EOS PostgreSQL database schema. The schema includes multiple tables (e.g.,
tickets_open_additional_infoand others). Each table DDL is stored in separate.sqlfiles such astest.txt.
Table of contents
- Purpose
- Prerequisites
- Database & schema overview
- Files included
- Quick start — create EOS database & load schema
- Detailed schema notes (example:
tickets_open_additional_info) - Adding more tables
- Best practices (migrations, backups, security)
- Troubleshooting
- Contact / maintainers
1. Purpose
The EOS database stores application data related to ticketing, feedback, and operational workflows. The repository contains SQL DDL files (one per table or per module). These define table structures, indexes, constraints, and comments.
2. Prerequisites
- PostgreSQL server (recommended: v12+).
psqlclient.- Privileges to create database, schema, and tables.
3. Database & schema overview
- Database name:
EOS - Schema: default is
public, unless otherwise specified. - Tables: multiple (
tickets_open_additional_info,tickets_open, …). Each is defined in.sqlfiles.
4. Files included
test.txt— SQL DDL fortickets_open_additional_info.- Additional
.sqlfiles — each will hold the DDL for other tables in EOS.
5. Quick start — create EOS database & load schema
1) Create the EOS database
createdb EOS
# or via psql
psql -U postgres -c "CREATE DATABASE EOS;"
2) Create application user (optional)
psql -U postgres -c "CREATE ROLE eos_user WITH LOGIN PASSWORD 'strong_password';"
psql -U postgres -c "GRANT CONNECT ON DATABASE EOS TO eos_user;"
3) Run schema files
# Run for a single table
psql -U postgres -d EOS -f /path/to/test.txt
# Run all tables (assuming all SQL files are in ./schema)
for f in ./schema/*.sql; do
psql -U postgres -d EOS -f "$f"
done
6. Detailed schema notes (example: tickets_open_additional_info)
The tickets_open_additional_info table is defined in test.txt. Highlights:
- Primary key:
ticket_id. - Important columns: state, city, vehicle_tagging, trip times, feedback fields.
- Indexes: on
ticket_id,state_name,city_name. - Comments: explain references (e.g.,
ticket_id→tickets_open.ticket_id).
Similar notes should be documented for each table when new .sql files are added.
7. Adding more tables
- Place new
.sqlfiles in theschema/directory (or alongsidetest.txt). - Each
.sqlshould containCREATE TABLE+ indexes + constraints. - Example:
tickets_open.sqltickets_closed.sqltickets_feedback.sql- etc.
To apply all:
psql -U postgres -d EOS -f tickets_open.sql
psql -U postgres -d EOS -f tickets_closed.sql
psql -U postgres -d EOS -f tickets_feedback.sql
8. Best practices
- Keep schema files under version control (Git).
- Use migration tools (Flyway, Liquibase) if schema changes are frequent.
- Define foreign keys between related tables (e.g.,
tickets_open_additional_info.ticket_id → tickets_open.ticket_id). - Remove redundant indexes (avoid duplicate PK + unique index).
- Use least-privilege users for the application (
SELECT/INSERT/UPDATEonly).
9. Troubleshooting
- "relation already exists" → drop the table or add
IF NOT EXISTS. - foreign key issues → ensure referenced table exists before dependent table.
- index duplication warnings → simplify schema.
10. Contact / maintainers
- Maintainer: (team/person name, email)
- Database:
EOS