feat(db): don't use weird pgsql extension to generate uuids, require postgres 13+

This commit is contained in:
perf3ct 2025-06-14 23:14:49 +00:00
parent 8fed8c753e
commit 45ab63c0d6
3 changed files with 6 additions and 7 deletions

View File

@ -1,10 +1,9 @@
-- Create extensions -- Create extensions
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE EXTENSION IF NOT EXISTS "pg_trgm"; CREATE EXTENSION IF NOT EXISTS "pg_trgm";
-- Create users table -- Create users table
CREATE TABLE IF NOT EXISTS users ( CREATE TABLE IF NOT EXISTS users (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
username VARCHAR(255) UNIQUE NOT NULL, username VARCHAR(255) UNIQUE NOT NULL,
email VARCHAR(255) UNIQUE NOT NULL, email VARCHAR(255) UNIQUE NOT NULL,
password_hash VARCHAR(255) NOT NULL, password_hash VARCHAR(255) NOT NULL,
@ -14,7 +13,7 @@ CREATE TABLE IF NOT EXISTS users (
-- Create documents table -- Create documents table
CREATE TABLE IF NOT EXISTS documents ( CREATE TABLE IF NOT EXISTS documents (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
filename VARCHAR(255) NOT NULL, filename VARCHAR(255) NOT NULL,
original_filename VARCHAR(255) NOT NULL, original_filename VARCHAR(255) NOT NULL,
file_path VARCHAR(500) NOT NULL, file_path VARCHAR(500) NOT NULL,
@ -47,7 +46,7 @@ CREATE INDEX IF NOT EXISTS idx_documents_ocr_word_count ON documents(ocr_word_co
-- Create settings table -- Create settings table
CREATE TABLE IF NOT EXISTS settings ( CREATE TABLE IF NOT EXISTS settings (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID REFERENCES users(id) ON DELETE CASCADE UNIQUE, user_id UUID REFERENCES users(id) ON DELETE CASCADE UNIQUE,
ocr_language VARCHAR(10) DEFAULT 'eng', ocr_language VARCHAR(10) DEFAULT 'eng',
concurrent_ocr_jobs INT DEFAULT 4, concurrent_ocr_jobs INT DEFAULT 4,

View File

@ -1,6 +1,6 @@
-- Add OCR queue table for robust processing -- Add OCR queue table for robust processing
CREATE TABLE IF NOT EXISTS ocr_queue ( CREATE TABLE IF NOT EXISTS ocr_queue (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
document_id UUID REFERENCES documents(id) ON DELETE CASCADE, document_id UUID REFERENCES documents(id) ON DELETE CASCADE,
status VARCHAR(20) DEFAULT 'pending', status VARCHAR(20) DEFAULT 'pending',
priority INT DEFAULT 5, priority INT DEFAULT 5,
@ -31,7 +31,7 @@ ALTER TABLE documents ADD COLUMN IF NOT EXISTS ocr_error TEXT;
ALTER TABLE documents ADD COLUMN IF NOT EXISTS ocr_completed_at TIMESTAMPTZ; ALTER TABLE documents ADD COLUMN IF NOT EXISTS ocr_completed_at TIMESTAMPTZ;
CREATE TABLE IF NOT EXISTS ocr_metrics ( CREATE TABLE IF NOT EXISTS ocr_metrics (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
date DATE DEFAULT CURRENT_DATE, date DATE DEFAULT CURRENT_DATE,
hour INT DEFAULT EXTRACT(HOUR FROM NOW()), hour INT DEFAULT EXTRACT(HOUR FROM NOW()),
total_processed INT DEFAULT 0, total_processed INT DEFAULT 0,

View File

@ -1,6 +1,6 @@
-- Create notifications table for backend-to-frontend notifications -- Create notifications table for backend-to-frontend notifications
CREATE TABLE IF NOT EXISTS notifications ( CREATE TABLE IF NOT EXISTS notifications (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE, user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
notification_type VARCHAR(20) NOT NULL CHECK (notification_type IN ('success', 'error', 'info', 'warning')), notification_type VARCHAR(20) NOT NULL CHECK (notification_type IN ('success', 'error', 'info', 'warning')),
title VARCHAR(255) NOT NULL, title VARCHAR(255) NOT NULL,