feat: expand documents to include manuals
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
-- Migration: Add 'manual' document type and scan_for_maintenance column
|
||||
-- Purpose: Support vehicle/equipment manuals with future maintenance schedule scanning
|
||||
|
||||
-- Step 1: Extend document_type CHECK constraint to include 'manual'
|
||||
-- Note: Must drop and recreate since PostgreSQL doesn't support ALTER CONSTRAINT
|
||||
ALTER TABLE documents DROP CONSTRAINT IF EXISTS documents_document_type_check;
|
||||
ALTER TABLE documents ADD CONSTRAINT documents_document_type_check
|
||||
CHECK (document_type IN ('insurance', 'registration', 'manual'));
|
||||
|
||||
-- Step 2: Add scan_for_maintenance boolean column
|
||||
-- Only applicable to 'manual' type, defaults to false
|
||||
ALTER TABLE documents ADD COLUMN IF NOT EXISTS scan_for_maintenance BOOLEAN DEFAULT false;
|
||||
|
||||
-- Step 3: Create partial index for future maintenance scanning queries
|
||||
CREATE INDEX IF NOT EXISTS idx_documents_scan_for_maintenance
|
||||
ON documents(scan_for_maintenance)
|
||||
WHERE scan_for_maintenance = true AND deleted_at IS NULL AND document_type = 'manual';
|
||||
Reference in New Issue
Block a user