punimtag/viewer-frontend/migrations/add-pending-photos-table.sql
Tanya de2144be2a feat: Add new scripts and update project structure for database management and user authentication
This commit introduces several new scripts for managing database operations, including user creation, permission grants, and data migrations. It also adds new documentation files to guide users through the setup and configuration processes. Additionally, the project structure is updated to enhance organization and maintainability, ensuring a smoother development experience for contributors. These changes support the ongoing transition to a web-based architecture and improve overall project functionality.
2026-01-06 13:53:24 -05:00

33 lines
1.2 KiB
SQL

-- Migration: Add pending_photos table for photo uploads
-- This table tracks photos uploaded by users that are pending admin approval
-- Run this in the punimtag_auth database
CREATE TABLE IF NOT EXISTS pending_photos (
id SERIAL PRIMARY KEY,
user_id INTEGER NOT NULL,
filename VARCHAR(255) NOT NULL,
original_filename VARCHAR(255) NOT NULL,
file_path TEXT NOT NULL,
file_size INTEGER NOT NULL,
mime_type VARCHAR(100) NOT NULL,
status VARCHAR(50) DEFAULT 'pending' CHECK (status IN ('pending', 'approved', 'rejected')),
submitted_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
reviewed_at TIMESTAMP,
reviewed_by INTEGER,
rejection_reason TEXT,
CONSTRAINT fk_pending_photos_user
FOREIGN KEY (user_id)
REFERENCES users(id)
ON DELETE CASCADE
);
-- Create indexes for efficient queries
CREATE INDEX IF NOT EXISTS idx_pending_photos_user_id ON pending_photos(user_id);
CREATE INDEX IF NOT EXISTS idx_pending_photos_status ON pending_photos(status);
CREATE INDEX IF NOT EXISTS idx_pending_photos_submitted_at ON pending_photos(submitted_at);
-- Add comment to table
COMMENT ON TABLE pending_photos IS 'Stores photos uploaded by users that are pending admin approval';