- Restore blue PageHeader on Dashboard (/app-components) - Update homepage (/) with subtle header design without blue bar - Add uniform PageHeader styling to application edit page - Fix Rapporten link on homepage to point to /reports overview - Improve header descriptions spacing for better readability
137 lines
5.1 KiB
Markdown
137 lines
5.1 KiB
Markdown
# Database Tables Audit
|
|
|
|
**Date:** 2026-01-09
|
|
**Purpose:** Verify all database tables are actually being used and clean up unused ones.
|
|
|
|
## Summary
|
|
|
|
✅ **All active tables are in use**
|
|
❌ **Removed:** `cached_objects` (legacy, replaced by normalized schema)
|
|
|
|
## Table Usage Status
|
|
|
|
### ✅ Active Tables (Normalized Schema)
|
|
|
|
These tables are part of the current normalized schema and are actively used:
|
|
|
|
1. **`schemas`** - ✅ USED
|
|
- Stores Jira Assets schema metadata
|
|
- Used by: `SchemaRepository`, `schemaDiscoveryService`, `schemaConfigurationService`
|
|
|
|
2. **`object_types`** - ✅ USED
|
|
- Stores discovered object types from Jira schema
|
|
- Used by: `SchemaRepository`, `schemaDiscoveryService`, `schemaCacheService`, `schemaConfigurationService`
|
|
|
|
3. **`attributes`** - ✅ USED
|
|
- Stores discovered attributes per object type
|
|
- Used by: `SchemaRepository`, `schemaDiscoveryService`, `schemaCacheService`, `queryBuilder`
|
|
|
|
4. **`objects`** - ✅ USED
|
|
- Stores minimal object metadata
|
|
- Used by: `normalizedCacheStore`, `ObjectCacheRepository`, `QueryService`, `dataIntegrityService`
|
|
|
|
5. **`attribute_values`** - ✅ USED
|
|
- EAV pattern for storing all attribute values
|
|
- Used by: `normalizedCacheStore`, `ObjectCacheRepository`, `QueryService`, `queryBuilder`, `dataIntegrityService`
|
|
|
|
6. **`object_relations`** - ✅ USED
|
|
- Stores relationships between objects
|
|
- Used by: `normalizedCacheStore`, `ObjectCacheRepository`, `QueryService`, `dataIntegrityService`, `DebugController`
|
|
|
|
7. **`sync_metadata`** - ✅ USED
|
|
- Tracks sync state
|
|
- Used by: `normalizedCacheStore`, `cacheStore.old.ts` (legacy)
|
|
|
|
8. **`schema_mappings`** - ⚠️ DEPRECATED but still in use
|
|
- Maps object types to schema IDs
|
|
- **Status:** Marked as DEPRECATED in schema comments, but still actively used by `schemaMappingService`
|
|
- **Note:** According to refactor plan, this should be removed after consolidation
|
|
- Used by: `schemaMappingService`, `jiraAssetsClient`, `jiraAssets`, `dataValidation` routes
|
|
|
|
### ✅ Active Tables (Classification Database)
|
|
|
|
9. **`classification_history`** - ✅ USED
|
|
- Stores AI classification history
|
|
- Used by: `databaseService`, `classifications` routes, `dashboard` routes
|
|
|
|
10. **`session_state`** - ✅ USED
|
|
- Stores session state for classification workflow
|
|
- Used by: `databaseService`
|
|
|
|
### ✅ Active Tables (Authentication & Authorization)
|
|
|
|
11. **`users`** - ✅ USED
|
|
- User accounts
|
|
- Used by: `userService`, `authService`, `auth` routes
|
|
|
|
12. **`roles`** - ✅ USED
|
|
- Role definitions
|
|
- Used by: `roleService`, `roles` routes
|
|
|
|
13. **`permissions`** - ✅ USED
|
|
- Permission definitions
|
|
- Used by: `roleService`, `roles` routes
|
|
|
|
14. **`role_permissions`** - ✅ USED
|
|
- Junction table: roles ↔ permissions
|
|
- Used by: `roleService`
|
|
|
|
15. **`user_roles`** - ✅ USED
|
|
- Junction table: users ↔ roles
|
|
- Used by: `roleService`, `userService`
|
|
|
|
16. **`user_settings`** - ✅ USED
|
|
- Per-user settings (PAT, AI keys, etc.)
|
|
- Used by: `userSettingsService`
|
|
|
|
17. **`sessions`** - ✅ USED
|
|
- User sessions (OAuth and local auth)
|
|
- Used by: `authService`
|
|
|
|
18. **`email_tokens`** - ✅ USED
|
|
- Email verification and password reset tokens
|
|
- Used by: `userService`
|
|
|
|
## ❌ Removed Tables
|
|
|
|
### `cached_objects` - REMOVED (Legacy)
|
|
|
|
**Status:** ❌ Removed from schema generation
|
|
**Reason:** Replaced by normalized schema (`objects` + `attribute_values` tables)
|
|
|
|
**Previous Usage:**
|
|
- Only used by deprecated `cacheStore.old.ts`
|
|
- Old schema stored all object data as JSON in a single table
|
|
- New normalized schema uses EAV pattern for better querying and flexibility
|
|
|
|
**Cleanup Actions:**
|
|
- ✅ Removed from `generate-schema.ts` script
|
|
- ✅ Removed from `backend/src/generated/db-schema.sql`
|
|
- ✅ Removed from `backend/src/generated/db-schema-postgres.sql`
|
|
- ✅ Added comment in migration script explaining it's only for legacy data migration
|
|
|
|
**Migration Note:**
|
|
- Migration script (`migrate-sqlite-to-postgres.ts`) still references `cached_objects` for migrating old data
|
|
- This is intentional - needed for one-time migration from old schema to new schema
|
|
|
|
## Notes
|
|
|
|
### Schema Mappings Table
|
|
|
|
The `schema_mappings` table is marked as DEPRECATED in the schema comments but is still actively used. According to the refactor plan (`docs/REFACTOR-PHASE-2B-3-STATUS.md`), this table should be removed after consolidation of schema services. For now, it remains in use and should not be deleted.
|
|
|
|
### Legacy Files
|
|
|
|
The following files still reference old schema but are deprecated:
|
|
- `backend/src/services/cacheStore.old.ts` - Old cache store implementation
|
|
- `backend/src/generated/db-schema.sql` - Legacy schema (now cleaned up)
|
|
- `backend/src/generated/db-schema-postgres.sql` - Legacy schema (now cleaned up)
|
|
|
|
## Conclusion
|
|
|
|
✅ **All 18 active tables are in use**
|
|
✅ **1 unused table (`cached_objects`) has been removed from schema generation**
|
|
⚠️ **1 table (`schema_mappings`) is marked deprecated but still in use - keep for now**
|
|
|
|
The database schema is now clean with only actively used tables defined in the schema generation scripts.
|