1
0
mirror of https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git synced 2025-08-14 00:25:46 +02:00

Initial commit

This commit is contained in:
MoonTestUse1
2024-12-23 19:27:44 +06:00
commit e81df4c87e
4952 changed files with 1705479 additions and 0 deletions

View 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');