Move ai_guard_violations migration to migrations/ dir picked up by db-migrate
Some checks failed
build-and-release / build (graphic-designers) (push) Successful in 1m52s
build-and-release / build (cron) (push) Successful in 2m34s
build-and-release / build (makeup-artists) (push) Successful in 1m32s
build-and-release / build (video-editors) (push) Waiting to run
backend-integration-tests / ai-credits (push) Waiting to run
build-and-release / build (jobs) (push) Successful in 1m54s
build-and-release / build (customers) (push) Successful in 1m42s
build-and-release / build (companies) (push) Successful in 2m39s
build-and-release / build (gateway) (push) Successful in 1m7s
build-and-release / build (job-seekers) (push) Successful in 3m0s
build-and-release / build (tutors) (push) Has been cancelled
build-and-release / build (photographers) (push) Has been cancelled
build-and-release / build (developers) (push) Successful in 1m44s
build-and-release / build (payments) (push) Has been cancelled
build-and-release / build (fitness-trainers) (push) Successful in 1m51s
build-and-release / build (ugc-content-creators) (push) Has been cancelled
build-and-release / build (social-media-managers) (push) Has been cancelled
build-and-release / build (employees) (push) Successful in 2m6s
build-and-release / build (catering-services) (push) Successful in 2m17s
build-and-release / build (users) (push) Has been cancelled

migrations_new/ is not read by db-migrate (it only honors MIGRATIONS_DIR,
which defaults to /migrations, i.e. crates/db/migrations). The file was
misplaced and would never have run.
This commit is contained in:
Ashwin Kumar Sivakumar 2026-08-15 20:15:05 +05:30
parent d9b3bb4d94
commit 605f3bdaaa
2 changed files with 17 additions and 0 deletions

View file

@ -0,0 +1 @@
DROP TABLE IF EXISTS ai_guard_violations;

View file

@ -0,0 +1,16 @@
-- AI Guard Violations — records every message blocked by the content guard.
-- Migration: 20260815000001
CREATE TABLE IF NOT EXISTS ai_guard_violations (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID REFERENCES users(id) ON DELETE SET NULL,
message_excerpt TEXT NOT NULL, -- first 200 chars, never the full text
guard_type VARCHAR(40) NOT NULL, -- 'keyword' | 'length' | 'flood' | 'moderation_api'
reason TEXT NOT NULL, -- human-readable rejection reason
categories JSONB, -- OpenAI moderation categories (moderation_api only)
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_ai_guard_violations_user_id ON ai_guard_violations(user_id);
CREATE INDEX IF NOT EXISTS idx_ai_guard_violations_created_at ON ai_guard_violations(created_at DESC);
CREATE INDEX IF NOT EXISTS idx_ai_guard_violations_guard_type ON ai_guard_violations(guard_type);