6.1 KiB
Executable File
6.1 KiB
Executable File
DB State – Fleet / Cost / Service Search
Snapshot: 2026-01-28
Source: “Adatbázis állapot napló” (user log)
Scope: Fleet management + cost tracking + service search
Out of scope: CRM (explicit), Email/Auth/Bot/Subscriptions (kezelve, de nem most)
1. Canonical status (most reliable)
1.1 Database base
- Schema separation:
dataschema is the business schema (public cleanup in progress earlier, later marked stable). - Scale: ~40 tables reported as “stabil” on 2026-01-28 (2105–2230 blocks).
- Integrity: FK constraints + enums “élesek” (2026-01-28 2219).
1.2 Backup reference
- Backup created:
/mnt/nas/git_vault/backup_20260128_alap_kesz.sql(20260128_2130) - Action: Use this as baseline snapshot identifier for future diffs.
2. In-scope modules
2.1 Fleet: vehicle registry & hierarchy
Reported as implemented
- Vehicle hierarchy guaranteed: Category -> Brand -> Model -> Variant (20260128_2145)
- Vehicle categories seeded:
CAR,MOTORCYCLE,TRUCK(20260128_2200) - Vehicle variants extended with:
powerfuelcylinder(2026-01-28 22:45)
VIN verification
vin_deadlinelogic (14 days) for temporary vehicles (2026-01-28 22:15)- User Vehicles extended with:
vin_verifiedvin_deadline(20260128_2230)
OPEN / NEED CONFIRMATION
- Exact table names for fleet core (mentioned:
vehicles,vehicle_ownership,user_vehicles). - Confirm whether
user_vehiclesexists or it’s a logical label for ownership.
2.2 Cost Tracking (expenses / fueling / TCO)
Reported as partially implemented
- Mentioned: “companies, equipment and subscription tables live” and “specifications (tire, service interval) added” (2026-01-28 21:50)
- Mentioned custom variable:
custom_service_interval_kmintroduced (2026-01-28 21:50)
OPEN / NEED CONFIRMATION (critical)
- Expense tables (expected examples):
expenses/vehicle_expensesfuel_logs/refuelsservice_events/maintenance_records
- Expense category enum exists:
expense_category(reported in 20260128_2105) - We must confirm:
- columns (amount, currency, vendor, odometer, date, invoice link)
- whether costs are per vehicle and per org (tenant).
2.3 Service Search / Marketplace (matching)
Reported as implemented
MatchingServiceexists +/api/v1/search/matchendpoint created (v2.1 / 2026-01-27)- Ranking formula recorded:
S = (Pdist * Wdist) + (Prate * Wrate) + Btier(v1.9)
- Dynamic weights served via ConfigService reading from
data.system_settings(v1.9–v1.7) - Geo base:
data.organization_locationscreated to support multi-site providers (v2.2–v2.6)- lat/lng stored there; join to organizations
Provider entities
data.organizationsis canonical org tableorgtype.SERVICEenum introduced for service providers (v2.7)service_specialtiesexists (v2.0)
OPEN / NEED CONFIRMATION
- Whether distance calculation is in SQL or Python (Haversine mention, but no final implementation proof).
- Whether PostGIS is used (not mentioned) vs plain numeric calculation.
3. Config / rules engine (used by in-scope modules)
system_settings canonical structure
- Canonical columns:
key_name(varchar)value_json(jsonb)- overrides:
region_code,tier_id,org_id
- Unique index:
idx_settings_lookupover(key_name, COALESCE(region_code,''), COALESCE(tier_id,0), COALESCE(org_id,0))
- Confirmed “sync with ConfigService” (v1.7)
Known keys (from variable map)
max_vehiclesdefault 3search_radiusdefault 20 (mentioned)- ranking policy weights exist via system_settings or
ranking_policies
4. Out of scope (present but not in current focus)
Keep in DB, ignore in implementation planning for now.
- Auth v1/v2, verification_tokens, audit_logs
- email_providers/email_logs/email_templates
- subscription tiers / org_subscriptions / notification rules
- bot_discovery_logs & bot module
5. Known fixes already applied (from logs)
system_settingsandemail_templatesgot akeycolumn earlier, then standardized tokey_name/value_jsonfor system_settings.- verification_tokens expiration validation: “now() based check” added.
- Sequences resynced with
setval(...)to resolve ID collisions. - Enum issue fixed (
tokentype email_verifyadded).
6. Risks & ambiguity markers
High risk (must verify)
- Cost tracking schema: tables/columns not explicitly listed.
- Fleet ownership:
vehicle_ownershipvsuser_vehiclesnaming. - Ranking storage split:
ranking_policiestable exists but weights also insystem_settings.
Medium risk
- Duplicate log entries may hide a later revert.
- “40 tables stable” statement needs objective verification.
7. Verification checklist (run on DB, capture output)
Run these and paste results into a new section “Verification Output”.
- List schemas and table count
SELECT table_schema, count(*) FROM information_schema.tables WHERE table_type='BASE TABLE' GROUP BY 1 ORDER BY 1;
- Confirm canonical tables exist
SELECT to_regclass('data.system_settings'), to_regclass('data.organizations'), to_regclass('data.organization_locations');
- system_settings columns
SELECT column_name, data_type FROM information_schema.columns WHERE table_schema='data' AND table_name='system_settings' ORDER BY ordinal_position;
- idx_settings_lookup exists
SELECT indexname, indexdef FROM pg_indexes WHERE schemaname='data' AND tablename='system_settings';
- Find cost tables (discovery)
SELECT table_name FROM information_schema.tables WHERE table_schema='data' AND table_name ILIKE '%expense%' OR table_name ILIKE '%fuel%' OR table_name ILIKE '%service%' ORDER BY 1;
- Enumerations list
SELECT t.typname, e.enumlabel FROM pg_type t JOIN pg_enum e ON t.oid=e.enumtypid ORDER BY t.typname, e.enumsortorder;
8. Next actions (implementation-oriented)
- Freeze baseline: label backup as DB_BASELINE_20260128
- Validate in-scope tables and fill missing schema details (cost module)
- Create “Module Status” doc based on verified tables:
- Fleet
- Cost
- Service Search