Files
History_Api/db/migrations/000006_entities.up.sql
AzenKain adb65d8292
Some checks failed
Build and Release / release (push) Failing after 1m7s
UPDATE: Entity, Geo, Wiki
2026-04-22 17:45:09 +07:00

22 lines
584 B
SQL

CREATE TABLE IF NOT EXISTS entities (
id UUID PRIMARY KEY DEFAULT uuidv7(),
name TEXT NOT NULL,
description TEXT,
thumbnail_url TEXT,
is_deleted BOOLEAN NOT NULL DEFAULT false,
created_at TIMESTAMPTZ DEFAULT now(),
updated_at TIMESTAMPTZ DEFAULT now()
);
CREATE INDEX idx_entities_name_search
ON entities USING GIN (name gin_trgm_ops);
CREATE INDEX idx_entities_created_active
ON entities(created_at DESC)
WHERE is_deleted = false;
CREATE TRIGGER trigger_entities_updated_at
BEFORE UPDATE ON entities
FOR EACH ROW
EXECUTE FUNCTION update_updated_at();