mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
Repository Structure:
- Move files from cluttered root directory into organized structure
- Create archive/ for archived data and scraper results
- Create bugulma/ for the complete application (frontend + backend)
- Create data/ for sample datasets and reference materials
- Create docs/ for comprehensive documentation structure
- Create scripts/ for utility scripts and API tools
Backend Implementation:
- Implement 3 missing backend endpoints identified in gap analysis:
* GET /api/v1/organizations/{id}/matching/direct - Direct symbiosis matches
* GET /api/v1/users/me/organizations - User organizations
* POST /api/v1/proposals/{id}/status - Update proposal status
- Add complete proposal domain model, repository, and service layers
- Create database migration for proposals table
- Fix CLI server command registration issue
API Documentation:
- Add comprehensive proposals.md API documentation
- Update README.md with Users and Proposals API sections
- Document all request/response formats, error codes, and business rules
Code Quality:
- Follow existing Go backend architecture patterns
- Add proper error handling and validation
- Match frontend expected response schemas
- Maintain clean separation of concerns (handler -> service -> repository)
78 lines
3.5 KiB
SQL
Executable File
78 lines
3.5 KiB
SQL
Executable File
-- Create trust metrics and data quality tables
|
|
-- Migration: 010_create_trust_tables.up.sql
|
|
|
|
-- Trust metrics table for storing trust and quality scores
|
|
CREATE TABLE IF NOT EXISTS trust_metrics (
|
|
id TEXT PRIMARY KEY,
|
|
organization_id TEXT NOT NULL,
|
|
metric_type VARCHAR(50) NOT NULL, -- organization, resource_flow, site
|
|
metric_name VARCHAR(100) NOT NULL,
|
|
value DECIMAL(5,4) CHECK (value >= 0 AND value <= 1), -- 0.0 to 1.0
|
|
score VARCHAR(20), -- excellent, good, fair, poor
|
|
evidence JSONB,
|
|
last_updated TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
valid_until TIMESTAMP WITH TIME ZONE,
|
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
|
|
);
|
|
|
|
-- Create indexes for trust_metrics
|
|
CREATE INDEX IF NOT EXISTS idx_trust_metrics_org_id ON trust_metrics(organization_id);
|
|
CREATE INDEX IF NOT EXISTS idx_trust_metrics_type ON trust_metrics(metric_type);
|
|
CREATE INDEX IF NOT EXISTS idx_trust_metrics_name ON trust_metrics(metric_name);
|
|
CREATE INDEX IF NOT EXISTS idx_trust_metrics_updated ON trust_metrics(last_updated);
|
|
|
|
-- Verified data table for tracking verification status
|
|
CREATE TABLE IF NOT EXISTS verified_data (
|
|
id TEXT PRIMARY KEY,
|
|
organization_id TEXT NOT NULL,
|
|
data_type VARCHAR(50) NOT NULL, -- organization, resource_flow, site
|
|
data_id TEXT NOT NULL,
|
|
status VARCHAR(20) DEFAULT 'unverified', -- unverified, pending, verified, rejected
|
|
verified_by TEXT,
|
|
verified_at TIMESTAMP WITH TIME ZONE,
|
|
evidence JSONB,
|
|
expires_at TIMESTAMP WITH TIME ZONE,
|
|
notes TEXT,
|
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
|
|
);
|
|
|
|
-- Create indexes for verified_data
|
|
CREATE INDEX IF NOT EXISTS idx_verified_data_org_id ON verified_data(organization_id);
|
|
CREATE INDEX IF NOT EXISTS idx_verified_data_status ON verified_data(status);
|
|
CREATE INDEX IF NOT EXISTS idx_verified_data_verified_at ON verified_data(verified_at);
|
|
CREATE INDEX IF NOT EXISTS idx_verified_data_expires_at ON verified_data(expires_at);
|
|
|
|
-- Historical success table for tracking performance metrics
|
|
CREATE TABLE IF NOT EXISTS historical_success (
|
|
id TEXT PRIMARY KEY,
|
|
organization_id TEXT NOT NULL,
|
|
match_id TEXT,
|
|
metric_type VARCHAR(50) NOT NULL, -- completion_rate, satisfaction, volume
|
|
value DECIMAL(5,4) CHECK (value >= 0 AND value <= 1), -- 0.0 to 1.0
|
|
period VARCHAR(20), -- monthly, quarterly, yearly
|
|
recorded_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
|
data JSONB,
|
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
|
|
);
|
|
|
|
-- Create indexes for historical_success
|
|
CREATE INDEX IF NOT EXISTS idx_historical_success_org_id ON historical_success(organization_id);
|
|
CREATE INDEX IF NOT EXISTS idx_historical_success_match_id ON historical_success(match_id);
|
|
CREATE INDEX IF NOT EXISTS idx_historical_success_type ON historical_success(metric_type);
|
|
CREATE INDEX IF NOT EXISTS idx_historical_success_recorded_at ON historical_success(recorded_at);
|
|
|
|
-- Add foreign key constraints
|
|
ALTER TABLE trust_metrics ADD CONSTRAINT fk_trust_metrics_org
|
|
FOREIGN KEY (organization_id) REFERENCES organizations(id) ON DELETE CASCADE;
|
|
|
|
ALTER TABLE verified_data ADD CONSTRAINT fk_verified_data_org
|
|
FOREIGN KEY (organization_id) REFERENCES organizations(id) ON DELETE CASCADE;
|
|
|
|
ALTER TABLE historical_success ADD CONSTRAINT fk_historical_success_org
|
|
FOREIGN KEY (organization_id) REFERENCES organizations(id) ON DELETE CASCADE;
|
|
|
|
ALTER TABLE historical_success ADD CONSTRAINT fk_historical_success_match
|
|
FOREIGN KEY (match_id) REFERENCES matches(id) ON DELETE SET NULL;
|