punimtag/viewer-frontend/migrations/add-write-access-column.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

22 lines
797 B
SQL

-- Migration: Add has_write_access column to users table
-- Run this as a PostgreSQL superuser or with appropriate permissions
-- Add the has_write_access column with default false
ALTER TABLE users
ADD COLUMN IF NOT EXISTS has_write_access BOOLEAN NOT NULL DEFAULT false;
-- Create an index on has_write_access for faster queries
CREATE INDEX IF NOT EXISTS idx_users_has_write_access ON users(has_write_access);
-- Update existing users: only admins should have write access initially
-- (You may want to adjust this based on your needs)
UPDATE users
SET has_write_access = false
WHERE has_write_access IS NULL;
-- Verify the column was added
SELECT column_name, data_type, column_default
FROM information_schema.columns
WHERE table_name = 'users' AND column_name = 'has_write_access';