mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
Initial commit
This commit is contained in:
37
.bolt/supabase_discarded_migrations/0007_bronze_castle.sql
Normal file
37
.bolt/supabase_discarded_migrations/0007_bronze_castle.sql
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
# 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');
|
Reference in New Issue
Block a user