feat(db): don't use weird pgsql extension to generate uuids, require postgres 13+
This commit is contained in:
parent
9e1acbf1b5
commit
08d57c6c36
|
|
@ -1,10 +1,9 @@
|
|||
-- Create extensions
|
||||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
||||
CREATE EXTENSION IF NOT EXISTS "pg_trgm";
|
||||
|
||||
-- Create users table
|
||||
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,
|
||||
email VARCHAR(255) UNIQUE NOT NULL,
|
||||
password_hash VARCHAR(255) NOT NULL,
|
||||
|
|
@ -14,7 +13,7 @@ CREATE TABLE IF NOT EXISTS users (
|
|||
|
||||
-- Create documents table
|
||||
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,
|
||||
original_filename VARCHAR(255) 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 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,
|
||||
ocr_language VARCHAR(10) DEFAULT 'eng',
|
||||
concurrent_ocr_jobs INT DEFAULT 4,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
-- Add OCR queue table for robust processing
|
||||
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,
|
||||
status VARCHAR(20) DEFAULT 'pending',
|
||||
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;
|
||||
|
||||
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,
|
||||
hour INT DEFAULT EXTRACT(HOUR FROM NOW()),
|
||||
total_processed INT DEFAULT 0,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
-- Create notifications table for backend-to-frontend 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,
|
||||
notification_type VARCHAR(20) NOT NULL CHECK (notification_type IN ('success', 'error', 'info', 'warning')),
|
||||
title VARCHAR(255) NOT NULL,
|
||||
|
|
|
|||
Loading…
Reference in New Issue