1
0
mirror of https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git synced 2025-08-14 00:25:46 +02:00
Files
AdministrationItDepartmens/.bolt/supabase_discarded_migrations/0007_bronze_castle.sql
MoonTestUse1 e81df4c87e Initial commit
2024-12-23 19:27:44 +06:00

37 lines
846 B
SQL

/*
# Create Users Table
1. New Tables
- `users`
- Basic user information and password storage
- Includes RLS policies for security
*/
-- Create extension for password hashing
CREATE EXTENSION IF NOT EXISTS pgcrypto;
-- Create users table
CREATE TABLE IF NOT EXISTS users (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
first_name text NOT NULL,
last_name text NOT NULL,
department text NOT NULL,
password_hash text NOT NULL,
created_at timestamptz DEFAULT now()
);
-- Enable RLS
ALTER TABLE users ENABLE ROW LEVEL SECURITY;
-- Create basic security policies
CREATE POLICY "Users can view own data"
ON users
FOR SELECT
TO authenticated
USING (id = auth.uid());
CREATE POLICY "Admins can manage all users"
ON users
FOR ALL
TO authenticated
USING (auth.jwt() ->> 'email' = 'admin@example.com');