From cecd2dc795e4df8964e920564eff62b6483ff0c4 Mon Sep 17 00:00:00 2001 From: phaichayon Date: Fri, 17 Jul 2026 00:19:02 +0700 Subject: [PATCH] run gen --- drizzle/0000_married_ink.sql | 46 - drizzle/0000_secret_sasquatch.sql | 515 +++ drizzle/0001_fancy_wolfpack.sql | 133 - drizzle/0002_unusual_whirlwind.sql | 17 - drizzle/0003_unify_users_training.sql | 103 - drizzle/0004_free_text_training_courses.sql | 15 - ...5_training_record_employee_id_nullable.sql | 1 - ...aining_record_employee_id_nullable_fix.sql | 1 - drizzle/0007_sticky_korath.sql | 102 - drizzle/0008_nosy_robin_chapel.sql | 2 - drizzle/0009_lean_hobgoblin.sql | 51 - drizzle/0010_romantic_marauders.sql | 58 - drizzle/0011_equal_cannonball.sql | 1 - drizzle/0012_change_duration_minutes.sql | 47 - drizzle/0013_glamorous_mysterio.sql | 80 - drizzle/0014_sweet_nico_minoru.sql | 1 - ...0015_permission_template_authorization.sql | 131 - drizzle/0016_curious_giant_man.sql | 89 - drizzle/0017_flowery_moondragon.sql | 4 - .../0018_organizations_soft_delete_repair.sql | 24 - drizzle/0019_content_approval_workflow.sql | 102 - drizzle/meta/0000_snapshot.json | 3904 +++++++++++++++- drizzle/meta/0001_snapshot.json | 1457 ------ drizzle/meta/0002_snapshot.json | 1486 ------ drizzle/meta/0005_snapshot.json | 1541 ------- drizzle/meta/0007_snapshot.json | 2309 ---------- drizzle/meta/0008_snapshot.json | 2330 ---------- drizzle/meta/0009_snapshot.json | 2643 ----------- drizzle/meta/0010_snapshot.json | 2844 ------------ drizzle/meta/0011_snapshot.json | 2871 ------------ drizzle/meta/0013_snapshot.json | 3177 ------------- drizzle/meta/0014_snapshot.json | 3178 ------------- drizzle/meta/0016_snapshot.json | 3959 ---------------- drizzle/meta/0017_snapshot.json | 3991 ----------------- drizzle/meta/_journal.json | 139 +- 35 files changed, 4414 insertions(+), 32938 deletions(-) delete mode 100644 drizzle/0000_married_ink.sql create mode 100644 drizzle/0000_secret_sasquatch.sql delete mode 100644 drizzle/0001_fancy_wolfpack.sql delete mode 100644 drizzle/0002_unusual_whirlwind.sql delete mode 100644 drizzle/0003_unify_users_training.sql delete mode 100644 drizzle/0004_free_text_training_courses.sql delete mode 100644 drizzle/0005_training_record_employee_id_nullable.sql delete mode 100644 drizzle/0006_training_record_employee_id_nullable_fix.sql delete mode 100644 drizzle/0007_sticky_korath.sql delete mode 100644 drizzle/0008_nosy_robin_chapel.sql delete mode 100644 drizzle/0009_lean_hobgoblin.sql delete mode 100644 drizzle/0010_romantic_marauders.sql delete mode 100644 drizzle/0011_equal_cannonball.sql delete mode 100644 drizzle/0012_change_duration_minutes.sql delete mode 100644 drizzle/0013_glamorous_mysterio.sql delete mode 100644 drizzle/0014_sweet_nico_minoru.sql delete mode 100644 drizzle/0015_permission_template_authorization.sql delete mode 100644 drizzle/0016_curious_giant_man.sql delete mode 100644 drizzle/0017_flowery_moondragon.sql delete mode 100644 drizzle/0018_organizations_soft_delete_repair.sql delete mode 100644 drizzle/0019_content_approval_workflow.sql delete mode 100644 drizzle/meta/0001_snapshot.json delete mode 100644 drizzle/meta/0002_snapshot.json delete mode 100644 drizzle/meta/0005_snapshot.json delete mode 100644 drizzle/meta/0007_snapshot.json delete mode 100644 drizzle/meta/0008_snapshot.json delete mode 100644 drizzle/meta/0009_snapshot.json delete mode 100644 drizzle/meta/0010_snapshot.json delete mode 100644 drizzle/meta/0011_snapshot.json delete mode 100644 drizzle/meta/0013_snapshot.json delete mode 100644 drizzle/meta/0014_snapshot.json delete mode 100644 drizzle/meta/0016_snapshot.json delete mode 100644 drizzle/meta/0017_snapshot.json diff --git a/drizzle/0000_married_ink.sql b/drizzle/0000_married_ink.sql deleted file mode 100644 index 4f014ee..0000000 --- a/drizzle/0000_married_ink.sql +++ /dev/null @@ -1,46 +0,0 @@ -CREATE TABLE "memberships" ( - "id" text PRIMARY KEY NOT NULL, - "user_id" text NOT NULL, - "organization_id" text NOT NULL, - "role" text DEFAULT 'owner' NOT NULL, - "permissions" text[] DEFAULT '{}' NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "organizations" ( - "id" text PRIMARY KEY NOT NULL, - "name" text NOT NULL, - "slug" text NOT NULL, - "image_url" text, - "plan" text DEFAULT 'free' NOT NULL, - "created_by" text NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "products" ( - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "products_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "organization_id" text NOT NULL, - "name" text NOT NULL, - "category" text NOT NULL, - "description" text NOT NULL, - "photo_url" text NOT NULL, - "price" double precision NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "users" ( - "id" text PRIMARY KEY NOT NULL, - "name" text NOT NULL, - "email" text NOT NULL, - "password_hash" text NOT NULL, - "image" text, - "active_organization_id" text, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE UNIQUE INDEX "organizations_slug_idx" ON "organizations" USING btree ("slug");--> statement-breakpoint -CREATE UNIQUE INDEX "users_email_idx" ON "users" USING btree ("email"); \ No newline at end of file diff --git a/drizzle/0000_secret_sasquatch.sql b/drizzle/0000_secret_sasquatch.sql new file mode 100644 index 0000000..376eede --- /dev/null +++ b/drizzle/0000_secret_sasquatch.sql @@ -0,0 +1,515 @@ +CREATE TYPE "public"."announcement_status" AS ENUM('draft', 'pending_review', 'approved', 'published', 'returned', 'rejected', 'archived');--> statement-breakpoint +CREATE TYPE "public"."approval_status" AS ENUM('draft', 'pending', 'approved', 'rejected', 'needs_revision');--> statement-breakpoint +CREATE TYPE "public"."import_status" AS ENUM('processing', 'completed', 'failed');--> statement-breakpoint +CREATE TYPE "public"."membership_role" AS ENUM('owner', 'admin', 'member');--> statement-breakpoint +CREATE TYPE "public"."notification_type" AS ENUM('approved', 'rejected', 'announcement', 'reminder');--> statement-breakpoint +CREATE TYPE "public"."online_lesson_status" AS ENUM('draft', 'pending_review', 'approved', 'published', 'returned', 'rejected', 'archived');--> statement-breakpoint +CREATE TYPE "public"."permission_override_effect" AS ENUM('allow', 'deny');--> statement-breakpoint +CREATE TYPE "public"."system_role" AS ENUM('standard', 'super_admin');--> statement-breakpoint +CREATE TYPE "public"."training_category" AS ENUM('K', 'S', 'A');--> statement-breakpoint +CREATE TYPE "public"."training_type" AS ENUM('online', 'onsite', 'internal', 'external');--> statement-breakpoint +CREATE TABLE "announcements" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "announcements_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "organization_id" text NOT NULL, + "title" text NOT NULL, + "content" text NOT NULL, + "attachment_file_name" text, + "attachment_file_type" text, + "attachment_file_size" integer, + "attachment_storage_key" text, + "attachment_file_url" text, + "start_date" timestamp with time zone NOT NULL, + "end_date" timestamp with time zone, + "is_pin" boolean DEFAULT false NOT NULL, + "status" "announcement_status" DEFAULT 'draft' NOT NULL, + "submitted_at" timestamp with time zone, + "submitted_by" text, + "reviewed_at" timestamp with time zone, + "reviewed_by" text, + "approved_at" timestamp with time zone, + "approved_by" text, + "published_at" timestamp with time zone, + "published_by" text, + "review_comment" text, + "created_by" text NOT NULL, + "updated_by" text, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "audit_logs" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "audit_logs_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "organization_id" text, + "user_id" text, + "module_name" text NOT NULL, + "action" text NOT NULL, + "entity_name" text, + "entity_id" text, + "old_value" jsonb, + "new_value" jsonb, + "ip_address" text, + "user_agent" text, + "created_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "certificates" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "certificates_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "organization_id" text NOT NULL, + "training_record_id" integer NOT NULL, + "file_name" text NOT NULL, + "file_type" text NOT NULL, + "file_size" integer NOT NULL, + "storage_key" text NOT NULL, + "file_url" text, + "uploaded_by" text NOT NULL, + "uploaded_at" timestamp with time zone DEFAULT now() NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "courses" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "courses_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "organization_id" text NOT NULL, + "course_code" text, + "name" text NOT NULL, + "category" text NOT NULL, + "organizer" text, + "standard_hours" double precision DEFAULT 0 NOT NULL, + "certificate_validity_months" integer, + "is_required" boolean DEFAULT false NOT NULL, + "certificate_required" boolean DEFAULT true NOT NULL, + "training_cost" double precision, + "description" text, + "is_active" boolean DEFAULT true NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "departments" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "departments_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "organization_id" text NOT NULL, + "code" text, + "name" text NOT NULL, + "description" text, + "is_active" boolean DEFAULT true NOT NULL, + "pending_master_review" boolean DEFAULT false NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "employee_training_targets" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "employee_training_targets_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "organization_id" text NOT NULL, + "user_id" text, + "employee_id" integer, + "year" integer NOT NULL, + "total_target_minutes" integer, + "total_hours" double precision NOT NULL, + "k_target_minutes" integer, + "k_hours" double precision NOT NULL, + "s_target_minutes" integer, + "s_hours" double precision NOT NULL, + "a_target_minutes" integer, + "a_hours" double precision NOT NULL, + "created_by" text NOT NULL, + "updated_by" text, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "employees" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "employees_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "organization_id" text NOT NULL, + "employee_code" text NOT NULL, + "prefix" text, + "first_name_th" text, + "last_name_th" text, + "first_name_en" text, + "last_name_en" text, + "display_name" text, + "full_name" text NOT NULL, + "email" text, + "phone" text, + "company_name" text, + "company" text, + "department_id" integer, + "position_id" integer, + "hired_at" timestamp with time zone, + "status" text DEFAULT 'active' NOT NULL, + "is_active" boolean DEFAULT true NOT NULL, + "pending_master_review" boolean DEFAULT false NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "import_jobs" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "import_jobs_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "organization_id" text NOT NULL, + "import_type" text NOT NULL, + "file_name" text NOT NULL, + "total_rows" integer DEFAULT 0 NOT NULL, + "success_rows" integer DEFAULT 0 NOT NULL, + "failed_rows" integer DEFAULT 0 NOT NULL, + "status" "import_status" DEFAULT 'processing' NOT NULL, + "error_message" text, + "created_by" text NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "memberships" ( + "id" text PRIMARY KEY NOT NULL, + "user_id" text NOT NULL, + "organization_id" text NOT NULL, + "role" "membership_role" DEFAULT 'owner' NOT NULL, + "permissions" text[] DEFAULT '{}' NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "notifications" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "notifications_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "organization_id" text NOT NULL, + "user_id" text NOT NULL, + "title" text NOT NULL, + "message" text NOT NULL, + "type" "notification_type" NOT NULL, + "reference_type" text, + "reference_id" text, + "is_read" boolean DEFAULT false NOT NULL, + "read_at" timestamp with time zone, + "created_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "online_lessons" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "online_lessons_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "organization_id" text NOT NULL, + "title" text NOT NULL, + "description" text, + "category" text, + "video_url" text, + "video_file_name" text, + "video_file_type" text, + "video_file_size" integer, + "video_storage_key" text, + "video_file_url" text, + "attachment_file_name" text, + "attachment_file_type" text, + "attachment_file_size" integer, + "attachment_storage_key" text, + "attachment_file_url" text, + "thumbnail_file_name" text, + "thumbnail_file_type" text, + "thumbnail_file_size" integer, + "thumbnail_storage_key" text, + "thumbnail_url" text, + "status" "online_lesson_status" DEFAULT 'draft' NOT NULL, + "submitted_at" timestamp with time zone, + "submitted_by" text, + "reviewed_at" timestamp with time zone, + "reviewed_by" text, + "approved_at" timestamp with time zone, + "approved_by" text, + "is_published" boolean DEFAULT false NOT NULL, + "published_at" timestamp with time zone, + "published_by" text, + "review_comment" text, + "created_by" text NOT NULL, + "updated_by" text, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "organizations" ( + "id" text PRIMARY KEY NOT NULL, + "name" text NOT NULL, + "slug" text NOT NULL, + "image_url" text, + "plan" text DEFAULT 'free' NOT NULL, + "is_active" boolean DEFAULT true NOT NULL, + "deleted_at" timestamp with time zone, + "deleted_by" text, + "pending_master_review" boolean DEFAULT false NOT NULL, + "created_by" text NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "permission_audit_logs" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "permission_audit_logs_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "organization_id" text, + "actor_user_id" text, + "target_user_id" text, + "template_id" integer, + "assignment_id" integer, + "override_id" integer, + "action" text NOT NULL, + "reason" text, + "before" jsonb, + "after" jsonb, + "created_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "permission_template_permissions" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "permission_template_permissions_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "template_id" integer NOT NULL, + "permission" text NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "permission_templates" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "permission_templates_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "organization_id" text NOT NULL, + "code" text NOT NULL, + "name" text NOT NULL, + "description" text, + "is_system" boolean DEFAULT false NOT NULL, + "is_default" boolean DEFAULT false NOT NULL, + "is_active" boolean DEFAULT true NOT NULL, + "deleted_at" timestamp with time zone, + "created_by" text, + "updated_by" text, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "positions" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "positions_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "organization_id" text NOT NULL, + "code" text, + "name" text NOT NULL, + "description" text, + "is_active" boolean DEFAULT true NOT NULL, + "pending_master_review" boolean DEFAULT false NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "products" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "products_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "organization_id" text NOT NULL, + "name" text NOT NULL, + "category" text NOT NULL, + "description" text NOT NULL, + "photo_url" text NOT NULL, + "price" double precision NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "training_matrices" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "training_matrices_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "organization_id" text NOT NULL, + "department_id" integer, + "position_id" integer, + "course_id" integer NOT NULL, + "is_required" boolean DEFAULT true NOT NULL, + "renewal_period_months" integer, + "note" text, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "training_policies" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "training_policies_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "organization_id" text NOT NULL, + "year" integer NOT NULL, + "total_target_minutes" integer, + "total_hours" double precision DEFAULT 30 NOT NULL, + "k_target_minutes" integer, + "k_hours" double precision DEFAULT 12 NOT NULL, + "s_target_minutes" integer, + "s_hours" double precision DEFAULT 12 NOT NULL, + "a_target_minutes" integer, + "a_hours" double precision DEFAULT 6 NOT NULL, + "is_active" boolean DEFAULT true NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "training_records" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "training_records_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "organization_id" text NOT NULL, + "user_id" text, + "employee_id" integer, + "course_id" integer, + "course_name" text NOT NULL, + "training_date" timestamp with time zone NOT NULL, + "training_type" "training_type" NOT NULL, + "submitted_minutes" integer, + "hours" double precision NOT NULL, + "approved_minutes" integer, + "approved_hours" double precision, + "category" "training_category", + "organizer" text, + "note" text, + "approval_status" "approval_status" DEFAULT 'pending' NOT NULL, + "reviewer_note" text, + "reject_reason" text, + "submitted_by_user_id" text, + "reviewed_by_user_id" text, + "reviewed_by" text, + "reviewed_at" timestamp with time zone, + "created_by" text NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "user_employee_maps" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "user_employee_maps_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "organization_id" text NOT NULL, + "user_id" text NOT NULL, + "employee_id" integer NOT NULL, + "provider" text, + "provider_user_id" text, + "source" text DEFAULT 'manual' NOT NULL, + "is_primary" boolean DEFAULT true NOT NULL, + "linked_at" timestamp with time zone DEFAULT now() NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "user_permission_overrides" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "user_permission_overrides_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "organization_id" text NOT NULL, + "user_id" text NOT NULL, + "permission" text NOT NULL, + "effect" "permission_override_effect" NOT NULL, + "reason" text, + "expires_at" timestamp with time zone, + "is_active" boolean DEFAULT true NOT NULL, + "created_by" text, + "revoked_by" text, + "revoked_at" timestamp with time zone, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "user_permission_template_assignments" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "user_permission_template_assignments_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "organization_id" text NOT NULL, + "user_id" text NOT NULL, + "template_id" integer NOT NULL, + "is_active" boolean DEFAULT true NOT NULL, + "assigned_by" text, + "assigned_at" timestamp with time zone DEFAULT now() NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "users" ( + "id" text PRIMARY KEY NOT NULL, + "name" text NOT NULL, + "email" text NOT NULL, + "username" text, + "password_hash" text, + "provider" text DEFAULT 'credentials' NOT NULL, + "provider_user_id" text, + "phone" text, + "image" text, + "system_role" "system_role" DEFAULT 'standard' NOT NULL, + "is_active" boolean DEFAULT true NOT NULL, + "employee_code" text, + "employee_id" integer, + "department_id" integer, + "position_id" integer, + "company_name" text, + "hired_at" timestamp with time zone, + "active_organization_id" text, + "last_login_at" timestamp with time zone, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +ALTER TABLE "announcements" ADD CONSTRAINT "announcements_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "announcements" ADD CONSTRAINT "announcements_submitted_by_users_id_fk" FOREIGN KEY ("submitted_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "announcements" ADD CONSTRAINT "announcements_reviewed_by_users_id_fk" FOREIGN KEY ("reviewed_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "announcements" ADD CONSTRAINT "announcements_approved_by_users_id_fk" FOREIGN KEY ("approved_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "announcements" ADD CONSTRAINT "announcements_published_by_users_id_fk" FOREIGN KEY ("published_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "announcements" ADD CONSTRAINT "announcements_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "announcements" ADD CONSTRAINT "announcements_updated_by_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "audit_logs" ADD CONSTRAINT "audit_logs_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "audit_logs" ADD CONSTRAINT "audit_logs_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "certificates" ADD CONSTRAINT "certificates_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "certificates" ADD CONSTRAINT "certificates_training_record_id_training_records_id_fk" FOREIGN KEY ("training_record_id") REFERENCES "public"."training_records"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "certificates" ADD CONSTRAINT "certificates_uploaded_by_users_id_fk" FOREIGN KEY ("uploaded_by") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "courses" ADD CONSTRAINT "courses_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "departments" ADD CONSTRAINT "departments_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "employee_training_targets" ADD CONSTRAINT "employee_training_targets_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "employee_training_targets" ADD CONSTRAINT "employee_training_targets_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "employee_training_targets" ADD CONSTRAINT "employee_training_targets_employee_id_employees_id_fk" FOREIGN KEY ("employee_id") REFERENCES "public"."employees"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "employee_training_targets" ADD CONSTRAINT "employee_training_targets_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "employee_training_targets" ADD CONSTRAINT "employee_training_targets_updated_by_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "employees" ADD CONSTRAINT "employees_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "employees" ADD CONSTRAINT "employees_department_id_departments_id_fk" FOREIGN KEY ("department_id") REFERENCES "public"."departments"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "employees" ADD CONSTRAINT "employees_position_id_positions_id_fk" FOREIGN KEY ("position_id") REFERENCES "public"."positions"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "import_jobs" ADD CONSTRAINT "import_jobs_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "import_jobs" ADD CONSTRAINT "import_jobs_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "memberships" ADD CONSTRAINT "memberships_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "memberships" ADD CONSTRAINT "memberships_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "notifications" ADD CONSTRAINT "notifications_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "notifications" ADD CONSTRAINT "notifications_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "online_lessons" ADD CONSTRAINT "online_lessons_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "online_lessons" ADD CONSTRAINT "online_lessons_submitted_by_users_id_fk" FOREIGN KEY ("submitted_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "online_lessons" ADD CONSTRAINT "online_lessons_reviewed_by_users_id_fk" FOREIGN KEY ("reviewed_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "online_lessons" ADD CONSTRAINT "online_lessons_approved_by_users_id_fk" FOREIGN KEY ("approved_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "online_lessons" ADD CONSTRAINT "online_lessons_published_by_users_id_fk" FOREIGN KEY ("published_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "online_lessons" ADD CONSTRAINT "online_lessons_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "online_lessons" ADD CONSTRAINT "online_lessons_updated_by_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "organizations" ADD CONSTRAINT "organizations_deleted_by_users_id_fk" FOREIGN KEY ("deleted_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "organizations" ADD CONSTRAINT "organizations_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "permission_audit_logs" ADD CONSTRAINT "permission_audit_logs_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "permission_audit_logs" ADD CONSTRAINT "permission_audit_logs_actor_user_id_users_id_fk" FOREIGN KEY ("actor_user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "permission_audit_logs" ADD CONSTRAINT "permission_audit_logs_target_user_id_users_id_fk" FOREIGN KEY ("target_user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "permission_audit_logs" ADD CONSTRAINT "permission_audit_logs_template_id_permission_templates_id_fk" FOREIGN KEY ("template_id") REFERENCES "public"."permission_templates"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "permission_audit_logs" ADD CONSTRAINT "permission_audit_logs_assignment_id_user_permission_template_assignments_id_fk" FOREIGN KEY ("assignment_id") REFERENCES "public"."user_permission_template_assignments"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "permission_audit_logs" ADD CONSTRAINT "permission_audit_logs_override_id_user_permission_overrides_id_fk" FOREIGN KEY ("override_id") REFERENCES "public"."user_permission_overrides"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "permission_template_permissions" ADD CONSTRAINT "permission_template_permissions_template_id_permission_templates_id_fk" FOREIGN KEY ("template_id") REFERENCES "public"."permission_templates"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "permission_templates" ADD CONSTRAINT "permission_templates_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "permission_templates" ADD CONSTRAINT "permission_templates_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "permission_templates" ADD CONSTRAINT "permission_templates_updated_by_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "positions" ADD CONSTRAINT "positions_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "products" ADD CONSTRAINT "products_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "training_matrices" ADD CONSTRAINT "training_matrices_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "training_matrices" ADD CONSTRAINT "training_matrices_department_id_departments_id_fk" FOREIGN KEY ("department_id") REFERENCES "public"."departments"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "training_matrices" ADD CONSTRAINT "training_matrices_position_id_positions_id_fk" FOREIGN KEY ("position_id") REFERENCES "public"."positions"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "training_matrices" ADD CONSTRAINT "training_matrices_course_id_courses_id_fk" FOREIGN KEY ("course_id") REFERENCES "public"."courses"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "training_policies" ADD CONSTRAINT "training_policies_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "training_records" ADD CONSTRAINT "training_records_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "training_records" ADD CONSTRAINT "training_records_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "training_records" ADD CONSTRAINT "training_records_employee_id_employees_id_fk" FOREIGN KEY ("employee_id") REFERENCES "public"."employees"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "training_records" ADD CONSTRAINT "training_records_course_id_courses_id_fk" FOREIGN KEY ("course_id") REFERENCES "public"."courses"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "training_records" ADD CONSTRAINT "training_records_submitted_by_user_id_users_id_fk" FOREIGN KEY ("submitted_by_user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "training_records" ADD CONSTRAINT "training_records_reviewed_by_user_id_users_id_fk" FOREIGN KEY ("reviewed_by_user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "training_records" ADD CONSTRAINT "training_records_reviewed_by_users_id_fk" FOREIGN KEY ("reviewed_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "training_records" ADD CONSTRAINT "training_records_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "user_employee_maps" ADD CONSTRAINT "user_employee_maps_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "user_employee_maps" ADD CONSTRAINT "user_employee_maps_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "user_employee_maps" ADD CONSTRAINT "user_employee_maps_employee_id_employees_id_fk" FOREIGN KEY ("employee_id") REFERENCES "public"."employees"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "user_permission_overrides" ADD CONSTRAINT "user_permission_overrides_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "user_permission_overrides" ADD CONSTRAINT "user_permission_overrides_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "user_permission_overrides" ADD CONSTRAINT "user_permission_overrides_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "user_permission_overrides" ADD CONSTRAINT "user_permission_overrides_revoked_by_users_id_fk" FOREIGN KEY ("revoked_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "user_permission_template_assignments" ADD CONSTRAINT "user_permission_template_assignments_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "user_permission_template_assignments" ADD CONSTRAINT "user_permission_template_assignments_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "user_permission_template_assignments" ADD CONSTRAINT "user_permission_template_assignments_template_id_permission_templates_id_fk" FOREIGN KEY ("template_id") REFERENCES "public"."permission_templates"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "user_permission_template_assignments" ADD CONSTRAINT "user_permission_template_assignments_assigned_by_users_id_fk" FOREIGN KEY ("assigned_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "users" ADD CONSTRAINT "users_employee_id_employees_id_fk" FOREIGN KEY ("employee_id") REFERENCES "public"."employees"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +CREATE UNIQUE INDEX "courses_org_name_idx" ON "courses" USING btree ("organization_id","name");--> statement-breakpoint +CREATE UNIQUE INDEX "departments_org_code_idx" ON "departments" USING btree ("organization_id","code");--> statement-breakpoint +CREATE UNIQUE INDEX "departments_org_name_idx" ON "departments" USING btree ("organization_id","name");--> statement-breakpoint +CREATE UNIQUE INDEX "employee_training_targets_org_user_year_idx" ON "employee_training_targets" USING btree ("organization_id","user_id","year");--> statement-breakpoint +CREATE UNIQUE INDEX "employee_training_targets_org_employee_year_idx" ON "employee_training_targets" USING btree ("organization_id","employee_id","year");--> statement-breakpoint +CREATE UNIQUE INDEX "employees_org_employee_code_idx" ON "employees" USING btree ("organization_id","employee_code");--> statement-breakpoint +CREATE UNIQUE INDEX "memberships_user_org_idx" ON "memberships" USING btree ("user_id","organization_id");--> statement-breakpoint +CREATE UNIQUE INDEX "organizations_slug_idx" ON "organizations" USING btree ("slug");--> statement-breakpoint +CREATE UNIQUE INDEX "permission_template_permissions_template_permission_idx" ON "permission_template_permissions" USING btree ("template_id","permission");--> statement-breakpoint +CREATE UNIQUE INDEX "permission_templates_org_code_idx" ON "permission_templates" USING btree ("organization_id","code");--> statement-breakpoint +CREATE UNIQUE INDEX "permission_templates_org_name_idx" ON "permission_templates" USING btree ("organization_id","name");--> statement-breakpoint +CREATE UNIQUE INDEX "positions_org_code_idx" ON "positions" USING btree ("organization_id","code");--> statement-breakpoint +CREATE UNIQUE INDEX "positions_org_name_idx" ON "positions" USING btree ("organization_id","name");--> statement-breakpoint +CREATE UNIQUE INDEX "training_policies_org_year_idx" ON "training_policies" USING btree ("organization_id","year");--> statement-breakpoint +CREATE UNIQUE INDEX "user_employee_maps_org_user_employee_idx" ON "user_employee_maps" USING btree ("organization_id","user_id","employee_id");--> statement-breakpoint +CREATE UNIQUE INDEX "user_permission_template_assignments_org_user_template_idx" ON "user_permission_template_assignments" USING btree ("organization_id","user_id","template_id");--> statement-breakpoint +CREATE UNIQUE INDEX "users_email_idx" ON "users" USING btree ("email");--> statement-breakpoint +CREATE UNIQUE INDEX "users_username_idx" ON "users" USING btree ("username");--> statement-breakpoint +CREATE UNIQUE INDEX "users_provider_user_id_idx" ON "users" USING btree ("provider","provider_user_id"); \ No newline at end of file diff --git a/drizzle/0001_fancy_wolfpack.sql b/drizzle/0001_fancy_wolfpack.sql deleted file mode 100644 index 2a41207..0000000 --- a/drizzle/0001_fancy_wolfpack.sql +++ /dev/null @@ -1,133 +0,0 @@ -CREATE TYPE "public"."approval_status" AS ENUM('pending', 'approved', 'rejected', 'needs_revision');--> statement-breakpoint -CREATE TYPE "public"."membership_role" AS ENUM('owner', 'admin', 'member');--> statement-breakpoint -CREATE TYPE "public"."training_type" AS ENUM('online', 'onsite', 'internal', 'external');--> statement-breakpoint -CREATE TABLE "certificates" ( - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "certificates_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "organization_id" text NOT NULL, - "training_record_id" integer NOT NULL, - "file_name" text NOT NULL, - "file_type" text NOT NULL, - "file_size" integer NOT NULL, - "storage_key" text NOT NULL, - "file_url" text, - "uploaded_by" text NOT NULL, - "uploaded_at" timestamp with time zone DEFAULT now() NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "courses" ( - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "courses_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "organization_id" text NOT NULL, - "name" text NOT NULL, - "category" text NOT NULL, - "organizer" text, - "standard_hours" double precision DEFAULT 0 NOT NULL, - "certificate_validity_months" integer, - "is_required" boolean DEFAULT false NOT NULL, - "description" text, - "is_active" boolean DEFAULT true NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "departments" ( - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "departments_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "organization_id" text NOT NULL, - "code" text, - "name" text NOT NULL, - "description" text, - "is_active" boolean DEFAULT true NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "employees" ( - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "employees_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "organization_id" text NOT NULL, - "employee_code" text NOT NULL, - "full_name" text NOT NULL, - "email" text, - "company" text, - "department_id" integer, - "position_id" integer, - "hired_at" timestamp with time zone, - "is_active" boolean DEFAULT true NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "positions" ( - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "positions_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "organization_id" text NOT NULL, - "code" text, - "name" text NOT NULL, - "description" text, - "is_active" boolean DEFAULT true NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "training_matrices" ( - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "training_matrices_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "organization_id" text NOT NULL, - "department_id" integer, - "position_id" integer, - "course_id" integer NOT NULL, - "is_required" boolean DEFAULT true NOT NULL, - "renewal_period_months" integer, - "note" text, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "training_records" ( - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "training_records_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "organization_id" text NOT NULL, - "employee_id" integer NOT NULL, - "course_id" integer NOT NULL, - "training_date" timestamp with time zone NOT NULL, - "training_type" "training_type" NOT NULL, - "hours" double precision NOT NULL, - "organizer" text, - "note" text, - "approval_status" "approval_status" DEFAULT 'pending' NOT NULL, - "reviewer_note" text, - "reviewed_by" text, - "reviewed_at" timestamp with time zone, - "created_by" text NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -ALTER TABLE "memberships" ALTER COLUMN "role" SET DEFAULT 'owner'::"public"."membership_role";--> statement-breakpoint -ALTER TABLE "memberships" ALTER COLUMN "role" SET DATA TYPE "public"."membership_role" USING "role"::"public"."membership_role";--> statement-breakpoint -ALTER TABLE "certificates" ADD CONSTRAINT "certificates_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "certificates" ADD CONSTRAINT "certificates_training_record_id_training_records_id_fk" FOREIGN KEY ("training_record_id") REFERENCES "public"."training_records"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "certificates" ADD CONSTRAINT "certificates_uploaded_by_users_id_fk" FOREIGN KEY ("uploaded_by") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "courses" ADD CONSTRAINT "courses_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "departments" ADD CONSTRAINT "departments_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "employees" ADD CONSTRAINT "employees_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "employees" ADD CONSTRAINT "employees_department_id_departments_id_fk" FOREIGN KEY ("department_id") REFERENCES "public"."departments"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "employees" ADD CONSTRAINT "employees_position_id_positions_id_fk" FOREIGN KEY ("position_id") REFERENCES "public"."positions"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "positions" ADD CONSTRAINT "positions_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "training_matrices" ADD CONSTRAINT "training_matrices_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "training_matrices" ADD CONSTRAINT "training_matrices_department_id_departments_id_fk" FOREIGN KEY ("department_id") REFERENCES "public"."departments"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "training_matrices" ADD CONSTRAINT "training_matrices_position_id_positions_id_fk" FOREIGN KEY ("position_id") REFERENCES "public"."positions"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "training_matrices" ADD CONSTRAINT "training_matrices_course_id_courses_id_fk" FOREIGN KEY ("course_id") REFERENCES "public"."courses"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "training_records" ADD CONSTRAINT "training_records_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "training_records" ADD CONSTRAINT "training_records_employee_id_employees_id_fk" FOREIGN KEY ("employee_id") REFERENCES "public"."employees"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "training_records" ADD CONSTRAINT "training_records_course_id_courses_id_fk" FOREIGN KEY ("course_id") REFERENCES "public"."courses"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "training_records" ADD CONSTRAINT "training_records_reviewed_by_users_id_fk" FOREIGN KEY ("reviewed_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "training_records" ADD CONSTRAINT "training_records_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint -CREATE UNIQUE INDEX "courses_org_name_idx" ON "courses" USING btree ("organization_id","name");--> statement-breakpoint -CREATE UNIQUE INDEX "departments_org_code_idx" ON "departments" USING btree ("organization_id","code");--> statement-breakpoint -CREATE UNIQUE INDEX "departments_org_name_idx" ON "departments" USING btree ("organization_id","name");--> statement-breakpoint -CREATE UNIQUE INDEX "employees_org_employee_code_idx" ON "employees" USING btree ("organization_id","employee_code");--> statement-breakpoint -CREATE UNIQUE INDEX "positions_org_code_idx" ON "positions" USING btree ("organization_id","code");--> statement-breakpoint -CREATE UNIQUE INDEX "positions_org_name_idx" ON "positions" USING btree ("organization_id","name");--> statement-breakpoint -ALTER TABLE "memberships" ADD CONSTRAINT "memberships_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "memberships" ADD CONSTRAINT "memberships_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "organizations" ADD CONSTRAINT "organizations_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "products" ADD CONSTRAINT "products_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -CREATE UNIQUE INDEX "memberships_user_org_idx" ON "memberships" USING btree ("user_id","organization_id"); \ No newline at end of file diff --git a/drizzle/0002_unusual_whirlwind.sql b/drizzle/0002_unusual_whirlwind.sql deleted file mode 100644 index 84cd86e..0000000 --- a/drizzle/0002_unusual_whirlwind.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TYPE "public"."system_role" AS ENUM('standard', 'super_admin');--> statement-breakpoint -ALTER TABLE "users" ADD COLUMN "phone" text;--> statement-breakpoint -ALTER TABLE "users" ADD COLUMN "system_role" "system_role" DEFAULT 'standard' NOT NULL;--> statement-breakpoint -ALTER TABLE "users" ADD COLUMN "is_active" boolean DEFAULT true NOT NULL;--> statement-breakpoint -UPDATE "users" -SET "system_role" = 'super_admin' -WHERE "id" = ( - SELECT "id" - FROM "users" - ORDER BY "created_at" ASC - LIMIT 1 -) -AND NOT EXISTS ( - SELECT 1 - FROM "users" - WHERE "system_role" = 'super_admin' -); diff --git a/drizzle/0003_unify_users_training.sql b/drizzle/0003_unify_users_training.sql deleted file mode 100644 index 4232b30..0000000 --- a/drizzle/0003_unify_users_training.sql +++ /dev/null @@ -1,103 +0,0 @@ -ALTER TABLE "users" ADD COLUMN "employee_code" text;--> statement-breakpoint -ALTER TABLE "users" ADD COLUMN "department_id" integer;--> statement-breakpoint -ALTER TABLE "users" ADD COLUMN "position_id" integer;--> statement-breakpoint -ALTER TABLE "users" ADD COLUMN "company_name" text;--> statement-breakpoint -ALTER TABLE "users" ADD COLUMN "hired_at" timestamp with time zone;--> statement-breakpoint -ALTER TABLE "training_records" ADD COLUMN "user_id" text;--> statement-breakpoint - -UPDATE "users" AS "u" -SET - "employee_code" = "e"."employee_code", - "department_id" = "e"."department_id", - "position_id" = "e"."position_id", - "company_name" = COALESCE("e"."company", "o"."name"), - "hired_at" = "e"."hired_at", - "updated_at" = NOW() -FROM "employees" AS "e" -INNER JOIN "organizations" AS "o" ON "o"."id" = "e"."organization_id" -WHERE "u"."email" IS NOT NULL - AND "e"."email" IS NOT NULL - AND LOWER("u"."email") = LOWER("e"."email");--> statement-breakpoint - -INSERT INTO "users" ( - "id", - "name", - "email", - "password_hash", - "system_role", - "is_active", - "employee_code", - "department_id", - "position_id", - "company_name", - "hired_at", - "active_organization_id" -) -SELECT - CONCAT('legacy-employee-', "e"."id", '-', "e"."organization_id") AS "id", - "e"."full_name", - COALESCE(LOWER("e"."email"), CONCAT('employee-', "e"."id", '@training-system.local')), - '$2b$10$sl8.hKi0l/KXnouzGgiRvOpNgZ9TT8RFvdPjQbgxCV5WirdWv1uBq', - 'standard', - false, - "e"."employee_code", - "e"."department_id", - "e"."position_id", - COALESCE("e"."company", "o"."name"), - "e"."hired_at", - "e"."organization_id" -FROM "employees" AS "e" -INNER JOIN "organizations" AS "o" ON "o"."id" = "e"."organization_id" -LEFT JOIN "users" AS "u" - ON ( - ("e"."email" IS NOT NULL AND LOWER("u"."email") = LOWER("e"."email")) - OR ("u"."employee_code" IS NOT NULL AND "u"."employee_code" = "e"."employee_code") - ) -WHERE "u"."id" IS NULL;--> statement-breakpoint - -INSERT INTO "memberships" ( - "id", - "user_id", - "organization_id", - "role", - "permissions" -) -SELECT - CONCAT('legacy-membership-', "e"."id", '-', "e"."organization_id"), - CONCAT('legacy-employee-', "e"."id", '-', "e"."organization_id"), - "e"."organization_id", - 'member', - ARRAY['products:read']::text[] -FROM "employees" AS "e" -LEFT JOIN "memberships" AS "m" - ON "m"."user_id" = CONCAT('legacy-employee-', "e"."id", '-', "e"."organization_id") - AND "m"."organization_id" = "e"."organization_id" -WHERE "m"."id" IS NULL - AND EXISTS ( - SELECT 1 - FROM "users" AS "u" - WHERE "u"."id" = CONCAT('legacy-employee-', "e"."id", '-', "e"."organization_id") - );--> statement-breakpoint - -UPDATE "training_records" AS "tr" -SET "user_id" = COALESCE( - ( - SELECT "u"."id" - FROM "users" AS "u" - INNER JOIN "employees" AS "e" ON LOWER("u"."email") = LOWER("e"."email") - WHERE "e"."id" = "tr"."employee_id" - LIMIT 1 - ), - CONCAT( - 'legacy-employee-', - "tr"."employee_id", - '-', - "tr"."organization_id" - ) -) -WHERE "tr"."user_id" IS NULL;--> statement-breakpoint - -ALTER TABLE "training_records" ALTER COLUMN "user_id" SET NOT NULL;--> statement-breakpoint -ALTER TABLE "training_records" ADD CONSTRAINT "training_records_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "training_records" DROP CONSTRAINT "training_records_employee_id_employees_id_fk";--> statement-breakpoint -ALTER TABLE "training_records" ADD CONSTRAINT "training_records_employee_id_employees_id_fk" FOREIGN KEY ("employee_id") REFERENCES "public"."employees"("id") ON DELETE set null ON UPDATE no action; diff --git a/drizzle/0004_free_text_training_courses.sql b/drizzle/0004_free_text_training_courses.sql deleted file mode 100644 index 68db7ea..0000000 --- a/drizzle/0004_free_text_training_courses.sql +++ /dev/null @@ -1,15 +0,0 @@ -ALTER TABLE "training_records" ADD COLUMN "course_name" text; ---> statement-breakpoint -UPDATE "training_records" AS "tr" -SET "course_name" = "c"."name" -FROM "courses" AS "c" -WHERE "tr"."course_id" = "c"."id" - AND "tr"."course_name" IS NULL; ---> statement-breakpoint -UPDATE "training_records" -SET "course_name" = 'External course' -WHERE "course_name" IS NULL; ---> statement-breakpoint -ALTER TABLE "training_records" ALTER COLUMN "course_name" SET NOT NULL; ---> statement-breakpoint -ALTER TABLE "training_records" ALTER COLUMN "course_id" DROP NOT NULL; diff --git a/drizzle/0005_training_record_employee_id_nullable.sql b/drizzle/0005_training_record_employee_id_nullable.sql deleted file mode 100644 index 41cda7d..0000000 --- a/drizzle/0005_training_record_employee_id_nullable.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "training_records" ALTER COLUMN "employee_id" DROP NOT NULL; diff --git a/drizzle/0006_training_record_employee_id_nullable_fix.sql b/drizzle/0006_training_record_employee_id_nullable_fix.sql deleted file mode 100644 index 41cda7d..0000000 --- a/drizzle/0006_training_record_employee_id_nullable_fix.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "training_records" ALTER COLUMN "employee_id" DROP NOT NULL; diff --git a/drizzle/0007_sticky_korath.sql b/drizzle/0007_sticky_korath.sql deleted file mode 100644 index ef3eff1..0000000 --- a/drizzle/0007_sticky_korath.sql +++ /dev/null @@ -1,102 +0,0 @@ -CREATE TYPE "public"."announcement_status" AS ENUM('draft', 'published', 'archived');--> statement-breakpoint -CREATE TYPE "public"."import_status" AS ENUM('processing', 'completed', 'failed');--> statement-breakpoint -CREATE TYPE "public"."notification_type" AS ENUM('approved', 'rejected', 'announcement', 'reminder');--> statement-breakpoint -CREATE TYPE "public"."training_category" AS ENUM('K', 'S', 'A');--> statement-breakpoint -CREATE TABLE "announcements" ( - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "announcements_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "organization_id" text NOT NULL, - "title" text NOT NULL, - "content" text NOT NULL, - "attachment_file_name" text, - "attachment_file_type" text, - "attachment_file_size" integer, - "attachment_storage_key" text, - "attachment_file_url" text, - "start_date" timestamp with time zone NOT NULL, - "end_date" timestamp with time zone, - "is_pin" boolean DEFAULT false NOT NULL, - "status" "announcement_status" DEFAULT 'draft' NOT NULL, - "created_by" text NOT NULL, - "updated_by" text, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "audit_logs" ( - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "audit_logs_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "organization_id" text, - "user_id" text, - "module_name" text NOT NULL, - "action" text NOT NULL, - "entity_name" text, - "entity_id" text, - "old_value" jsonb, - "new_value" jsonb, - "ip_address" text, - "user_agent" text, - "created_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "import_jobs" ( - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "import_jobs_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "organization_id" text NOT NULL, - "import_type" text NOT NULL, - "file_name" text NOT NULL, - "total_rows" integer DEFAULT 0 NOT NULL, - "success_rows" integer DEFAULT 0 NOT NULL, - "failed_rows" integer DEFAULT 0 NOT NULL, - "status" "import_status" DEFAULT 'processing' NOT NULL, - "error_message" text, - "created_by" text NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "notifications" ( - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "notifications_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "organization_id" text NOT NULL, - "user_id" text NOT NULL, - "title" text NOT NULL, - "message" text NOT NULL, - "type" "notification_type" NOT NULL, - "reference_type" text, - "reference_id" text, - "is_read" boolean DEFAULT false NOT NULL, - "read_at" timestamp with time zone, - "created_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "training_policies" ( - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "training_policies_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "organization_id" text NOT NULL, - "year" integer NOT NULL, - "total_hours" double precision DEFAULT 30 NOT NULL, - "k_hours" double precision DEFAULT 12 NOT NULL, - "s_hours" double precision DEFAULT 12 NOT NULL, - "a_hours" double precision DEFAULT 6 NOT NULL, - "is_active" boolean DEFAULT true NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -ALTER TABLE "users" ALTER COLUMN "password_hash" DROP NOT NULL;--> statement-breakpoint -ALTER TABLE "courses" ADD COLUMN "course_code" text;--> statement-breakpoint -ALTER TABLE "courses" ADD COLUMN "certificate_required" boolean DEFAULT true NOT NULL;--> statement-breakpoint -ALTER TABLE "courses" ADD COLUMN "training_cost" double precision;--> statement-breakpoint -ALTER TABLE "departments" ADD COLUMN "pending_master_review" boolean DEFAULT false NOT NULL;--> statement-breakpoint -ALTER TABLE "employees" ADD COLUMN "pending_master_review" boolean DEFAULT false NOT NULL;--> statement-breakpoint -ALTER TABLE "organizations" ADD COLUMN "pending_master_review" boolean DEFAULT false NOT NULL;--> statement-breakpoint -ALTER TABLE "positions" ADD COLUMN "pending_master_review" boolean DEFAULT false NOT NULL;--> statement-breakpoint -ALTER TABLE "training_records" ADD COLUMN "approved_hours" double precision;--> statement-breakpoint -ALTER TABLE "training_records" ADD COLUMN "category" "training_category";--> statement-breakpoint -ALTER TABLE "training_records" ADD COLUMN "reject_reason" text;--> statement-breakpoint -ALTER TABLE "announcements" ADD CONSTRAINT "announcements_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "announcements" ADD CONSTRAINT "announcements_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "announcements" ADD CONSTRAINT "announcements_updated_by_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "audit_logs" ADD CONSTRAINT "audit_logs_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "audit_logs" ADD CONSTRAINT "audit_logs_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "import_jobs" ADD CONSTRAINT "import_jobs_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "import_jobs" ADD CONSTRAINT "import_jobs_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "notifications" ADD CONSTRAINT "notifications_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "notifications" ADD CONSTRAINT "notifications_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "training_policies" ADD CONSTRAINT "training_policies_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -CREATE UNIQUE INDEX "training_policies_org_year_idx" ON "training_policies" USING btree ("organization_id","year"); \ No newline at end of file diff --git a/drizzle/0008_nosy_robin_chapel.sql b/drizzle/0008_nosy_robin_chapel.sql deleted file mode 100644 index dfc4732..0000000 --- a/drizzle/0008_nosy_robin_chapel.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE "users" ADD COLUMN "username" text;--> statement-breakpoint -CREATE UNIQUE INDEX "users_username_idx" ON "users" USING btree ("username"); \ No newline at end of file diff --git a/drizzle/0009_lean_hobgoblin.sql b/drizzle/0009_lean_hobgoblin.sql deleted file mode 100644 index 08a869f..0000000 --- a/drizzle/0009_lean_hobgoblin.sql +++ /dev/null @@ -1,51 +0,0 @@ -ALTER TABLE "employees" ADD COLUMN "prefix" text;--> statement-breakpoint -ALTER TABLE "employees" ADD COLUMN "first_name_th" text;--> statement-breakpoint -ALTER TABLE "employees" ADD COLUMN "last_name_th" text;--> statement-breakpoint -ALTER TABLE "employees" ADD COLUMN "first_name_en" text;--> statement-breakpoint -ALTER TABLE "employees" ADD COLUMN "last_name_en" text;--> statement-breakpoint -ALTER TABLE "employees" ADD COLUMN "display_name" text;--> statement-breakpoint -ALTER TABLE "employees" ADD COLUMN "phone" text;--> statement-breakpoint -ALTER TABLE "employees" ADD COLUMN "company_name" text;--> statement-breakpoint -ALTER TABLE "employees" ADD COLUMN "status" text DEFAULT 'active' NOT NULL;--> statement-breakpoint -ALTER TABLE "users" ADD COLUMN "provider" text DEFAULT 'credentials' NOT NULL;--> statement-breakpoint -ALTER TABLE "users" ADD COLUMN "provider_user_id" text;--> statement-breakpoint -ALTER TABLE "users" ADD COLUMN "employee_id" integer;--> statement-breakpoint -ALTER TABLE "users" ADD COLUMN "last_login_at" timestamp with time zone;--> statement-breakpoint -ALTER TABLE "employee_training_targets" ADD COLUMN "employee_id" integer;--> statement-breakpoint -ALTER TABLE "employee_training_targets" ADD CONSTRAINT "employee_training_targets_employee_id_employees_id_fk" FOREIGN KEY ("employee_id") REFERENCES "public"."employees"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "users" ADD CONSTRAINT "users_employee_id_employees_id_fk" FOREIGN KEY ("employee_id") REFERENCES "public"."employees"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -CREATE UNIQUE INDEX "users_provider_user_id_idx" ON "users" USING btree ("provider","provider_user_id");--> statement-breakpoint - -UPDATE "employees" -SET - "display_name" = COALESCE("display_name", "full_name"), - "company_name" = COALESCE("company_name", "company"), - "status" = CASE WHEN "is_active" = true THEN 'active' ELSE 'inactive' END;--> statement-breakpoint - -UPDATE "users" -SET "provider" = COALESCE("provider", 'credentials') -WHERE "provider" IS NULL;--> statement-breakpoint - -UPDATE "users" u -SET "employee_id" = e."id" -FROM "memberships" m -INNER JOIN "employees" e - ON e."organization_id" = m."organization_id" - AND e."employee_code" = u."employee_code" -WHERE m."user_id" = u."id" - AND u."employee_code" IS NOT NULL - AND (u."employee_id" IS NULL OR u."employee_id" <> e."id");--> statement-breakpoint - -UPDATE "training_records" tr -SET "employee_id" = u."employee_id" -FROM "users" u -WHERE tr."user_id" = u."id" - AND tr."employee_id" IS NULL - AND u."employee_id" IS NOT NULL;--> statement-breakpoint - -UPDATE "employee_training_targets" ett -SET "employee_id" = u."employee_id" -FROM "users" u -WHERE ett."user_id" = u."id" - AND ett."employee_id" IS NULL - AND u."employee_id" IS NOT NULL; diff --git a/drizzle/0010_romantic_marauders.sql b/drizzle/0010_romantic_marauders.sql deleted file mode 100644 index a50858f..0000000 --- a/drizzle/0010_romantic_marauders.sql +++ /dev/null @@ -1,58 +0,0 @@ -CREATE TABLE "user_employee_maps" ( - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "user_employee_maps_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "organization_id" text NOT NULL, - "user_id" text NOT NULL, - "employee_id" integer NOT NULL, - "provider" text, - "provider_user_id" text, - "source" text DEFAULT 'manual' NOT NULL, - "is_primary" boolean DEFAULT true NOT NULL, - "linked_at" timestamp with time zone DEFAULT now() NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -ALTER TABLE "training_records" DROP CONSTRAINT "training_records_user_id_users_id_fk"; ---> statement-breakpoint -ALTER TABLE "employee_training_targets" ALTER COLUMN "user_id" DROP NOT NULL;--> statement-breakpoint -ALTER TABLE "training_records" ALTER COLUMN "user_id" DROP NOT NULL;--> statement-breakpoint -ALTER TABLE "training_records" ADD COLUMN "submitted_by_user_id" text;--> statement-breakpoint -ALTER TABLE "training_records" ADD COLUMN "reviewed_by_user_id" text;--> statement-breakpoint -ALTER TABLE "user_employee_maps" ADD CONSTRAINT "user_employee_maps_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "user_employee_maps" ADD CONSTRAINT "user_employee_maps_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "user_employee_maps" ADD CONSTRAINT "user_employee_maps_employee_id_employees_id_fk" FOREIGN KEY ("employee_id") REFERENCES "public"."employees"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -CREATE UNIQUE INDEX "user_employee_maps_org_user_employee_idx" ON "user_employee_maps" USING btree ("organization_id","user_id","employee_id");--> statement-breakpoint -CREATE UNIQUE INDEX "employee_training_targets_org_employee_year_idx" ON "employee_training_targets" USING btree ("organization_id","employee_id","year");--> statement-breakpoint -ALTER TABLE "training_records" ADD CONSTRAINT "training_records_submitted_by_user_id_users_id_fk" FOREIGN KEY ("submitted_by_user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "training_records" ADD CONSTRAINT "training_records_reviewed_by_user_id_users_id_fk" FOREIGN KEY ("reviewed_by_user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "training_records" ADD CONSTRAINT "training_records_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint - -INSERT INTO "user_employee_maps" ( - "organization_id", - "user_id", - "employee_id", - "provider", - "provider_user_id", - "source", - "is_primary" -) -SELECT - m."organization_id", - u."id", - u."employee_id", - u."provider", - u."provider_user_id", - 'legacy_backfill', - true -FROM "users" u -INNER JOIN "memberships" m ON m."user_id" = u."id" -WHERE u."employee_id" IS NOT NULL -ON CONFLICT ("organization_id","user_id","employee_id") DO NOTHING;--> statement-breakpoint - -UPDATE "training_records" -SET "submitted_by_user_id" = COALESCE("submitted_by_user_id", "created_by") -WHERE "submitted_by_user_id" IS NULL;--> statement-breakpoint - -UPDATE "training_records" -SET "reviewed_by_user_id" = COALESCE("reviewed_by_user_id", "reviewed_by") -WHERE "reviewed_by_user_id" IS NULL AND "reviewed_by" IS NOT NULL; diff --git a/drizzle/0011_equal_cannonball.sql b/drizzle/0011_equal_cannonball.sql deleted file mode 100644 index e6d4c98..0000000 --- a/drizzle/0011_equal_cannonball.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE UNIQUE INDEX "employee_training_targets_org_employee_year_idx" ON "employee_training_targets" USING btree ("organization_id","employee_id","year"); \ No newline at end of file diff --git a/drizzle/0012_change_duration_minutes.sql b/drizzle/0012_change_duration_minutes.sql deleted file mode 100644 index b778a53..0000000 --- a/drizzle/0012_change_duration_minutes.sql +++ /dev/null @@ -1,47 +0,0 @@ -ALTER TABLE "training_records" - ADD COLUMN "submitted_minutes" integer, - ADD COLUMN "approved_minutes" integer; - -UPDATE "training_records" -SET - "submitted_minutes" = ROUND("hours" * 60), - "approved_minutes" = CASE - WHEN "approved_hours" IS NULL THEN NULL - ELSE ROUND("approved_hours" * 60) - END -WHERE "submitted_minutes" IS NULL - OR ("approved_hours" IS NOT NULL AND "approved_minutes" IS NULL); - -ALTER TABLE "training_policies" - ADD COLUMN "total_target_minutes" integer, - ADD COLUMN "k_target_minutes" integer, - ADD COLUMN "s_target_minutes" integer, - ADD COLUMN "a_target_minutes" integer; - -UPDATE "training_policies" -SET - "total_target_minutes" = ROUND("total_hours" * 60), - "k_target_minutes" = ROUND("k_hours" * 60), - "s_target_minutes" = ROUND("s_hours" * 60), - "a_target_minutes" = ROUND("a_hours" * 60) -WHERE "total_target_minutes" IS NULL - OR "k_target_minutes" IS NULL - OR "s_target_minutes" IS NULL - OR "a_target_minutes" IS NULL; - -ALTER TABLE "employee_training_targets" - ADD COLUMN "total_target_minutes" integer, - ADD COLUMN "k_target_minutes" integer, - ADD COLUMN "s_target_minutes" integer, - ADD COLUMN "a_target_minutes" integer; - -UPDATE "employee_training_targets" -SET - "total_target_minutes" = ROUND("total_hours" * 60), - "k_target_minutes" = ROUND("k_hours" * 60), - "s_target_minutes" = ROUND("s_hours" * 60), - "a_target_minutes" = ROUND("a_hours" * 60) -WHERE "total_target_minutes" IS NULL - OR "k_target_minutes" IS NULL - OR "s_target_minutes" IS NULL - OR "a_target_minutes" IS NULL; diff --git a/drizzle/0013_glamorous_mysterio.sql b/drizzle/0013_glamorous_mysterio.sql deleted file mode 100644 index bf47b18..0000000 --- a/drizzle/0013_glamorous_mysterio.sql +++ /dev/null @@ -1,80 +0,0 @@ -DO $$ -BEGIN - IF NOT EXISTS ( - SELECT 1 - FROM pg_type - WHERE typname = 'online_lesson_status' - ) THEN - CREATE TYPE "public"."online_lesson_status" AS ENUM('draft', 'published', 'archived'); - END IF; -END $$;--> statement-breakpoint - -CREATE TABLE IF NOT EXISTS "online_lessons" ( - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY, - "organization_id" text NOT NULL, - "title" text NOT NULL, - "description" text, - "category" text, - "video_url" text, - "video_file_name" text, - "video_file_type" text, - "video_file_size" integer, - "video_storage_key" text, - "video_file_url" text, - "attachment_file_name" text, - "attachment_file_type" text, - "attachment_file_size" integer, - "attachment_storage_key" text, - "attachment_file_url" text, - "thumbnail_file_name" text, - "thumbnail_file_type" text, - "thumbnail_file_size" integer, - "thumbnail_storage_key" text, - "thumbnail_url" text, - "status" "online_lesson_status" DEFAULT 'draft' NOT NULL, - "is_published" boolean DEFAULT false NOT NULL, - "published_at" timestamp with time zone, - "created_by" text NOT NULL, - "updated_by" text, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -);--> statement-breakpoint - -DO $$ -BEGIN - IF NOT EXISTS ( - SELECT 1 - FROM pg_constraint - WHERE conname = 'online_lessons_organization_id_organizations_id_fk' - ) THEN - ALTER TABLE "online_lessons" - ADD CONSTRAINT "online_lessons_organization_id_organizations_id_fk" - FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action; - END IF; -END $$;--> statement-breakpoint - -DO $$ -BEGIN - IF NOT EXISTS ( - SELECT 1 - FROM pg_constraint - WHERE conname = 'online_lessons_created_by_users_id_fk' - ) THEN - ALTER TABLE "online_lessons" - ADD CONSTRAINT "online_lessons_created_by_users_id_fk" - FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action; - END IF; -END $$;--> statement-breakpoint - -DO $$ -BEGIN - IF NOT EXISTS ( - SELECT 1 - FROM pg_constraint - WHERE conname = 'online_lessons_updated_by_users_id_fk' - ) THEN - ALTER TABLE "online_lessons" - ADD CONSTRAINT "online_lessons_updated_by_users_id_fk" - FOREIGN KEY ("updated_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action; - END IF; -END $$; diff --git a/drizzle/0014_sweet_nico_minoru.sql b/drizzle/0014_sweet_nico_minoru.sql deleted file mode 100644 index ef4b1ee..0000000 --- a/drizzle/0014_sweet_nico_minoru.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TYPE "public"."approval_status" ADD VALUE 'draft' BEFORE 'pending'; \ No newline at end of file diff --git a/drizzle/0015_permission_template_authorization.sql b/drizzle/0015_permission_template_authorization.sql deleted file mode 100644 index 459e16b..0000000 --- a/drizzle/0015_permission_template_authorization.sql +++ /dev/null @@ -1,131 +0,0 @@ -CREATE TYPE "public"."permission_override_effect" AS ENUM('allow', 'deny'); - -CREATE TABLE "permission_templates" ( - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "permission_templates_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "organization_id" text NOT NULL, - "code" text NOT NULL, - "name" text NOT NULL, - "description" text, - "is_system" boolean DEFAULT false NOT NULL, - "is_default" boolean DEFAULT false NOT NULL, - "is_active" boolean DEFAULT true NOT NULL, - "deleted_at" timestamp with time zone, - "created_by" text, - "updated_by" text, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); - -CREATE TABLE "permission_template_permissions" ( - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "permission_template_permissions_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "template_id" integer NOT NULL, - "permission" text NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL -); - -CREATE TABLE "user_permission_template_assignments" ( - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "user_permission_template_assignments_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "organization_id" text NOT NULL, - "user_id" text NOT NULL, - "template_id" integer NOT NULL, - "is_active" boolean DEFAULT true NOT NULL, - "assigned_by" text, - "assigned_at" timestamp with time zone DEFAULT now() NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); - -CREATE TABLE "user_permission_overrides" ( - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "user_permission_overrides_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "organization_id" text NOT NULL, - "user_id" text NOT NULL, - "permission" text NOT NULL, - "effect" "permission_override_effect" NOT NULL, - "reason" text, - "expires_at" timestamp with time zone, - "is_active" boolean DEFAULT true NOT NULL, - "created_by" text, - "revoked_by" text, - "revoked_at" timestamp with time zone, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); - -CREATE TABLE "permission_audit_logs" ( - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "permission_audit_logs_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "organization_id" text, - "actor_user_id" text, - "target_user_id" text, - "template_id" integer, - "assignment_id" integer, - "override_id" integer, - "action" text NOT NULL, - "reason" text, - "before" jsonb, - "after" jsonb, - "created_at" timestamp with time zone DEFAULT now() NOT NULL -); - -ALTER TABLE "permission_templates" - ADD CONSTRAINT "permission_templates_organization_id_organizations_id_fk" - FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action; -ALTER TABLE "permission_templates" - ADD CONSTRAINT "permission_templates_created_by_users_id_fk" - FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action; -ALTER TABLE "permission_templates" - ADD CONSTRAINT "permission_templates_updated_by_users_id_fk" - FOREIGN KEY ("updated_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action; - -ALTER TABLE "permission_template_permissions" - ADD CONSTRAINT "permission_template_permissions_template_id_permission_templates_id_fk" - FOREIGN KEY ("template_id") REFERENCES "public"."permission_templates"("id") ON DELETE cascade ON UPDATE no action; - -ALTER TABLE "user_permission_template_assignments" - ADD CONSTRAINT "user_permission_template_assignments_organization_id_organizations_id_fk" - FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action; -ALTER TABLE "user_permission_template_assignments" - ADD CONSTRAINT "user_permission_template_assignments_user_id_users_id_fk" - FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action; -ALTER TABLE "user_permission_template_assignments" - ADD CONSTRAINT "user_permission_template_assignments_template_id_permission_templates_id_fk" - FOREIGN KEY ("template_id") REFERENCES "public"."permission_templates"("id") ON DELETE restrict ON UPDATE no action; -ALTER TABLE "user_permission_template_assignments" - ADD CONSTRAINT "user_permission_template_assignments_assigned_by_users_id_fk" - FOREIGN KEY ("assigned_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action; - -ALTER TABLE "user_permission_overrides" - ADD CONSTRAINT "user_permission_overrides_organization_id_organizations_id_fk" - FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action; -ALTER TABLE "user_permission_overrides" - ADD CONSTRAINT "user_permission_overrides_user_id_users_id_fk" - FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action; -ALTER TABLE "user_permission_overrides" - ADD CONSTRAINT "user_permission_overrides_created_by_users_id_fk" - FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action; -ALTER TABLE "user_permission_overrides" - ADD CONSTRAINT "user_permission_overrides_revoked_by_users_id_fk" - FOREIGN KEY ("revoked_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action; - -ALTER TABLE "permission_audit_logs" - ADD CONSTRAINT "permission_audit_logs_organization_id_organizations_id_fk" - FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE set null ON UPDATE no action; -ALTER TABLE "permission_audit_logs" - ADD CONSTRAINT "permission_audit_logs_actor_user_id_users_id_fk" - FOREIGN KEY ("actor_user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action; -ALTER TABLE "permission_audit_logs" - ADD CONSTRAINT "permission_audit_logs_target_user_id_users_id_fk" - FOREIGN KEY ("target_user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action; -ALTER TABLE "permission_audit_logs" - ADD CONSTRAINT "permission_audit_logs_template_id_permission_templates_id_fk" - FOREIGN KEY ("template_id") REFERENCES "public"."permission_templates"("id") ON DELETE set null ON UPDATE no action; -ALTER TABLE "permission_audit_logs" - ADD CONSTRAINT "permission_audit_logs_assignment_id_user_permission_template_assignments_id_fk" - FOREIGN KEY ("assignment_id") REFERENCES "public"."user_permission_template_assignments"("id") ON DELETE set null ON UPDATE no action; -ALTER TABLE "permission_audit_logs" - ADD CONSTRAINT "permission_audit_logs_override_id_user_permission_overrides_id_fk" - FOREIGN KEY ("override_id") REFERENCES "public"."user_permission_overrides"("id") ON DELETE set null ON UPDATE no action; - -CREATE UNIQUE INDEX "permission_templates_org_code_idx" ON "permission_templates" USING btree ("organization_id", "code"); -CREATE UNIQUE INDEX "permission_templates_org_name_idx" ON "permission_templates" USING btree ("organization_id", "name"); -CREATE UNIQUE INDEX "permission_template_permissions_template_permission_idx" ON "permission_template_permissions" USING btree ("template_id", "permission"); -CREATE UNIQUE INDEX "user_permission_template_assignments_org_user_template_idx" ON "user_permission_template_assignments" USING btree ("organization_id", "user_id", "template_id"); diff --git a/drizzle/0016_curious_giant_man.sql b/drizzle/0016_curious_giant_man.sql deleted file mode 100644 index 13b3144..0000000 --- a/drizzle/0016_curious_giant_man.sql +++ /dev/null @@ -1,89 +0,0 @@ -CREATE TYPE "public"."permission_override_effect" AS ENUM('allow', 'deny');--> statement-breakpoint -CREATE TABLE "permission_audit_logs" ( - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "permission_audit_logs_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "organization_id" text, - "actor_user_id" text, - "target_user_id" text, - "template_id" integer, - "assignment_id" integer, - "override_id" integer, - "action" text NOT NULL, - "reason" text, - "before" jsonb, - "after" jsonb, - "created_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "permission_template_permissions" ( - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "permission_template_permissions_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "template_id" integer NOT NULL, - "permission" text NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "permission_templates" ( - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "permission_templates_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "organization_id" text NOT NULL, - "code" text NOT NULL, - "name" text NOT NULL, - "description" text, - "is_system" boolean DEFAULT false NOT NULL, - "is_default" boolean DEFAULT false NOT NULL, - "is_active" boolean DEFAULT true NOT NULL, - "deleted_at" timestamp with time zone, - "created_by" text, - "updated_by" text, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "user_permission_overrides" ( - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "user_permission_overrides_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "organization_id" text NOT NULL, - "user_id" text NOT NULL, - "permission" text NOT NULL, - "effect" "permission_override_effect" NOT NULL, - "reason" text, - "expires_at" timestamp with time zone, - "is_active" boolean DEFAULT true NOT NULL, - "created_by" text, - "revoked_by" text, - "revoked_at" timestamp with time zone, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "user_permission_template_assignments" ( - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "user_permission_template_assignments_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "organization_id" text NOT NULL, - "user_id" text NOT NULL, - "template_id" integer NOT NULL, - "is_active" boolean DEFAULT true NOT NULL, - "assigned_by" text, - "assigned_at" timestamp with time zone DEFAULT now() NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -ALTER TABLE "permission_audit_logs" ADD CONSTRAINT "permission_audit_logs_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "permission_audit_logs" ADD CONSTRAINT "permission_audit_logs_actor_user_id_users_id_fk" FOREIGN KEY ("actor_user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "permission_audit_logs" ADD CONSTRAINT "permission_audit_logs_target_user_id_users_id_fk" FOREIGN KEY ("target_user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "permission_audit_logs" ADD CONSTRAINT "permission_audit_logs_template_id_permission_templates_id_fk" FOREIGN KEY ("template_id") REFERENCES "public"."permission_templates"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "permission_audit_logs" ADD CONSTRAINT "permission_audit_logs_assignment_id_user_permission_template_assignments_id_fk" FOREIGN KEY ("assignment_id") REFERENCES "public"."user_permission_template_assignments"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "permission_audit_logs" ADD CONSTRAINT "permission_audit_logs_override_id_user_permission_overrides_id_fk" FOREIGN KEY ("override_id") REFERENCES "public"."user_permission_overrides"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "permission_template_permissions" ADD CONSTRAINT "permission_template_permissions_template_id_permission_templates_id_fk" FOREIGN KEY ("template_id") REFERENCES "public"."permission_templates"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "permission_templates" ADD CONSTRAINT "permission_templates_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "permission_templates" ADD CONSTRAINT "permission_templates_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "permission_templates" ADD CONSTRAINT "permission_templates_updated_by_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "user_permission_overrides" ADD CONSTRAINT "user_permission_overrides_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "user_permission_overrides" ADD CONSTRAINT "user_permission_overrides_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "user_permission_overrides" ADD CONSTRAINT "user_permission_overrides_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "user_permission_overrides" ADD CONSTRAINT "user_permission_overrides_revoked_by_users_id_fk" FOREIGN KEY ("revoked_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "user_permission_template_assignments" ADD CONSTRAINT "user_permission_template_assignments_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "user_permission_template_assignments" ADD CONSTRAINT "user_permission_template_assignments_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "user_permission_template_assignments" ADD CONSTRAINT "user_permission_template_assignments_template_id_permission_templates_id_fk" FOREIGN KEY ("template_id") REFERENCES "public"."permission_templates"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "user_permission_template_assignments" ADD CONSTRAINT "user_permission_template_assignments_assigned_by_users_id_fk" FOREIGN KEY ("assigned_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -CREATE UNIQUE INDEX "permission_template_permissions_template_permission_idx" ON "permission_template_permissions" USING btree ("template_id","permission");--> statement-breakpoint -CREATE UNIQUE INDEX "permission_templates_org_code_idx" ON "permission_templates" USING btree ("organization_id","code");--> statement-breakpoint -CREATE UNIQUE INDEX "permission_templates_org_name_idx" ON "permission_templates" USING btree ("organization_id","name");--> statement-breakpoint -CREATE UNIQUE INDEX "user_permission_template_assignments_org_user_template_idx" ON "user_permission_template_assignments" USING btree ("organization_id","user_id","template_id"); \ No newline at end of file diff --git a/drizzle/0017_flowery_moondragon.sql b/drizzle/0017_flowery_moondragon.sql deleted file mode 100644 index e425e4a..0000000 --- a/drizzle/0017_flowery_moondragon.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE "organizations" ADD COLUMN "is_active" boolean DEFAULT true NOT NULL;--> statement-breakpoint -ALTER TABLE "organizations" ADD COLUMN "deleted_at" timestamp with time zone;--> statement-breakpoint -ALTER TABLE "organizations" ADD COLUMN "deleted_by" text;--> statement-breakpoint -ALTER TABLE "organizations" ADD CONSTRAINT "organizations_deleted_by_users_id_fk" FOREIGN KEY ("deleted_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action; \ No newline at end of file diff --git a/drizzle/0018_organizations_soft_delete_repair.sql b/drizzle/0018_organizations_soft_delete_repair.sql deleted file mode 100644 index 49f8b06..0000000 --- a/drizzle/0018_organizations_soft_delete_repair.sql +++ /dev/null @@ -1,24 +0,0 @@ -ALTER TABLE "organizations" -ADD COLUMN IF NOT EXISTS "is_active" boolean DEFAULT true NOT NULL; ---> statement-breakpoint -ALTER TABLE "organizations" -ADD COLUMN IF NOT EXISTS "deleted_at" timestamp with time zone; ---> statement-breakpoint -ALTER TABLE "organizations" -ADD COLUMN IF NOT EXISTS "deleted_by" text; ---> statement-breakpoint -DO $$ -BEGIN - IF NOT EXISTS ( - SELECT 1 - FROM pg_constraint - WHERE conname = 'organizations_deleted_by_users_id_fk' - ) THEN - ALTER TABLE "organizations" - ADD CONSTRAINT "organizations_deleted_by_users_id_fk" - FOREIGN KEY ("deleted_by") - REFERENCES "public"."users"("id") - ON DELETE set null - ON UPDATE no action; - END IF; -END $$; diff --git a/drizzle/0019_content_approval_workflow.sql b/drizzle/0019_content_approval_workflow.sql deleted file mode 100644 index 8a11da0..0000000 --- a/drizzle/0019_content_approval_workflow.sql +++ /dev/null @@ -1,102 +0,0 @@ -ALTER TYPE "public"."announcement_status" ADD VALUE IF NOT EXISTS 'pending_review'; -ALTER TYPE "public"."announcement_status" ADD VALUE IF NOT EXISTS 'approved'; -ALTER TYPE "public"."announcement_status" ADD VALUE IF NOT EXISTS 'returned'; -ALTER TYPE "public"."announcement_status" ADD VALUE IF NOT EXISTS 'rejected'; - -ALTER TYPE "public"."online_lesson_status" ADD VALUE IF NOT EXISTS 'pending_review'; -ALTER TYPE "public"."online_lesson_status" ADD VALUE IF NOT EXISTS 'approved'; -ALTER TYPE "public"."online_lesson_status" ADD VALUE IF NOT EXISTS 'returned'; -ALTER TYPE "public"."online_lesson_status" ADD VALUE IF NOT EXISTS 'rejected'; - -ALTER TABLE "announcements" - ADD COLUMN IF NOT EXISTS "submitted_at" timestamp with time zone, - ADD COLUMN IF NOT EXISTS "submitted_by" text, - ADD COLUMN IF NOT EXISTS "reviewed_at" timestamp with time zone, - ADD COLUMN IF NOT EXISTS "reviewed_by" text, - ADD COLUMN IF NOT EXISTS "approved_at" timestamp with time zone, - ADD COLUMN IF NOT EXISTS "approved_by" text, - ADD COLUMN IF NOT EXISTS "published_at" timestamp with time zone, - ADD COLUMN IF NOT EXISTS "published_by" text, - ADD COLUMN IF NOT EXISTS "review_comment" text; - -ALTER TABLE "online_lessons" - ADD COLUMN IF NOT EXISTS "submitted_at" timestamp with time zone, - ADD COLUMN IF NOT EXISTS "submitted_by" text, - ADD COLUMN IF NOT EXISTS "reviewed_at" timestamp with time zone, - ADD COLUMN IF NOT EXISTS "reviewed_by" text, - ADD COLUMN IF NOT EXISTS "approved_at" timestamp with time zone, - ADD COLUMN IF NOT EXISTS "approved_by" text, - ADD COLUMN IF NOT EXISTS "published_by" text, - ADD COLUMN IF NOT EXISTS "review_comment" text; - -DO $$ -BEGIN - ALTER TABLE "announcements" - ADD CONSTRAINT "announcements_submitted_by_users_id_fk" - FOREIGN KEY ("submitted_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN NULL; -END $$; - -DO $$ -BEGIN - ALTER TABLE "announcements" - ADD CONSTRAINT "announcements_reviewed_by_users_id_fk" - FOREIGN KEY ("reviewed_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN NULL; -END $$; - -DO $$ -BEGIN - ALTER TABLE "announcements" - ADD CONSTRAINT "announcements_approved_by_users_id_fk" - FOREIGN KEY ("approved_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN NULL; -END $$; - -DO $$ -BEGIN - ALTER TABLE "announcements" - ADD CONSTRAINT "announcements_published_by_users_id_fk" - FOREIGN KEY ("published_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN NULL; -END $$; - -DO $$ -BEGIN - ALTER TABLE "online_lessons" - ADD CONSTRAINT "online_lessons_submitted_by_users_id_fk" - FOREIGN KEY ("submitted_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN NULL; -END $$; - -DO $$ -BEGIN - ALTER TABLE "online_lessons" - ADD CONSTRAINT "online_lessons_reviewed_by_users_id_fk" - FOREIGN KEY ("reviewed_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN NULL; -END $$; - -DO $$ -BEGIN - ALTER TABLE "online_lessons" - ADD CONSTRAINT "online_lessons_approved_by_users_id_fk" - FOREIGN KEY ("approved_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN NULL; -END $$; - -DO $$ -BEGIN - ALTER TABLE "online_lessons" - ADD CONSTRAINT "online_lessons_published_by_users_id_fk" - FOREIGN KEY ("published_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN NULL; -END $$; diff --git a/drizzle/meta/0000_snapshot.json b/drizzle/meta/0000_snapshot.json index ba15fbc..12cb86d 100644 --- a/drizzle/meta/0000_snapshot.json +++ b/drizzle/meta/0000_snapshot.json @@ -1,9 +1,1439 @@ { - "id": "ae7121c5-e461-44b8-8b25-7f5459f3ad7c", + "id": "fba9de63-59b8-49f6-bb9a-298bb71140e6", "prevId": "00000000-0000-0000-0000-000000000000", "version": "7", "dialect": "postgresql", "tables": { + "public.announcements": { + "name": "announcements", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "announcements_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "attachment_file_name": { + "name": "attachment_file_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "attachment_file_type": { + "name": "attachment_file_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "attachment_file_size": { + "name": "attachment_file_size", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "attachment_storage_key": { + "name": "attachment_storage_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "attachment_file_url": { + "name": "attachment_file_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "start_date": { + "name": "start_date", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "end_date": { + "name": "end_date", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "is_pin": { + "name": "is_pin", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "status": { + "name": "status", + "type": "announcement_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "submitted_at": { + "name": "submitted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "submitted_by": { + "name": "submitted_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "reviewed_by": { + "name": "reviewed_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "approved_at": { + "name": "approved_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "approved_by": { + "name": "approved_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "published_by": { + "name": "published_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "review_comment": { + "name": "review_comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "announcements_organization_id_organizations_id_fk": { + "name": "announcements_organization_id_organizations_id_fk", + "tableFrom": "announcements", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "announcements_submitted_by_users_id_fk": { + "name": "announcements_submitted_by_users_id_fk", + "tableFrom": "announcements", + "tableTo": "users", + "columnsFrom": [ + "submitted_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "announcements_reviewed_by_users_id_fk": { + "name": "announcements_reviewed_by_users_id_fk", + "tableFrom": "announcements", + "tableTo": "users", + "columnsFrom": [ + "reviewed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "announcements_approved_by_users_id_fk": { + "name": "announcements_approved_by_users_id_fk", + "tableFrom": "announcements", + "tableTo": "users", + "columnsFrom": [ + "approved_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "announcements_published_by_users_id_fk": { + "name": "announcements_published_by_users_id_fk", + "tableFrom": "announcements", + "tableTo": "users", + "columnsFrom": [ + "published_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "announcements_created_by_users_id_fk": { + "name": "announcements_created_by_users_id_fk", + "tableFrom": "announcements", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "announcements_updated_by_users_id_fk": { + "name": "announcements_updated_by_users_id_fk", + "tableFrom": "announcements", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.audit_logs": { + "name": "audit_logs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "audit_logs_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "module_name": { + "name": "module_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_name": { + "name": "entity_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "old_value": { + "name": "old_value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "new_value": { + "name": "new_value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "audit_logs_organization_id_organizations_id_fk": { + "name": "audit_logs_organization_id_organizations_id_fk", + "tableFrom": "audit_logs", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "audit_logs_user_id_users_id_fk": { + "name": "audit_logs_user_id_users_id_fk", + "tableFrom": "audit_logs", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.certificates": { + "name": "certificates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "certificates_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "training_record_id": { + "name": "training_record_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_type": { + "name": "file_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_size": { + "name": "file_size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "storage_key": { + "name": "storage_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_url": { + "name": "file_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "uploaded_by": { + "name": "uploaded_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "uploaded_at": { + "name": "uploaded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "certificates_organization_id_organizations_id_fk": { + "name": "certificates_organization_id_organizations_id_fk", + "tableFrom": "certificates", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "certificates_training_record_id_training_records_id_fk": { + "name": "certificates_training_record_id_training_records_id_fk", + "tableFrom": "certificates", + "tableTo": "training_records", + "columnsFrom": [ + "training_record_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "certificates_uploaded_by_users_id_fk": { + "name": "certificates_uploaded_by_users_id_fk", + "tableFrom": "certificates", + "tableTo": "users", + "columnsFrom": [ + "uploaded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.courses": { + "name": "courses", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "courses_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "course_code": { + "name": "course_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organizer": { + "name": "organizer", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "standard_hours": { + "name": "standard_hours", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "certificate_validity_months": { + "name": "certificate_validity_months", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_required": { + "name": "is_required", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "certificate_required": { + "name": "certificate_required", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "training_cost": { + "name": "training_cost", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "courses_org_name_idx": { + "name": "courses_org_name_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "courses_organization_id_organizations_id_fk": { + "name": "courses_organization_id_organizations_id_fk", + "tableFrom": "courses", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.departments": { + "name": "departments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "departments_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "pending_master_review": { + "name": "pending_master_review", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "departments_org_code_idx": { + "name": "departments_org_code_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "departments_org_name_idx": { + "name": "departments_org_name_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "departments_organization_id_organizations_id_fk": { + "name": "departments_organization_id_organizations_id_fk", + "tableFrom": "departments", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.employee_training_targets": { + "name": "employee_training_targets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "employee_training_targets_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "employee_id": { + "name": "employee_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "year": { + "name": "year", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "total_target_minutes": { + "name": "total_target_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_hours": { + "name": "total_hours", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "k_target_minutes": { + "name": "k_target_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "k_hours": { + "name": "k_hours", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "s_target_minutes": { + "name": "s_target_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "s_hours": { + "name": "s_hours", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "a_target_minutes": { + "name": "a_target_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "a_hours": { + "name": "a_hours", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employee_training_targets_org_user_year_idx": { + "name": "employee_training_targets_org_user_year_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "year", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "employee_training_targets_org_employee_year_idx": { + "name": "employee_training_targets_org_employee_year_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "year", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employee_training_targets_organization_id_organizations_id_fk": { + "name": "employee_training_targets_organization_id_organizations_id_fk", + "tableFrom": "employee_training_targets", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_training_targets_user_id_users_id_fk": { + "name": "employee_training_targets_user_id_users_id_fk", + "tableFrom": "employee_training_targets", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_training_targets_employee_id_employees_id_fk": { + "name": "employee_training_targets_employee_id_employees_id_fk", + "tableFrom": "employee_training_targets", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "employee_training_targets_created_by_users_id_fk": { + "name": "employee_training_targets_created_by_users_id_fk", + "tableFrom": "employee_training_targets", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "employee_training_targets_updated_by_users_id_fk": { + "name": "employee_training_targets_updated_by_users_id_fk", + "tableFrom": "employee_training_targets", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.employees": { + "name": "employees", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "employees_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "employee_code": { + "name": "employee_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "prefix": { + "name": "prefix", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "first_name_th": { + "name": "first_name_th", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_name_th": { + "name": "last_name_th", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "first_name_en": { + "name": "first_name_en", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_name_en": { + "name": "last_name_en", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "full_name": { + "name": "full_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "company_name": { + "name": "company_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "company": { + "name": "company", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "department_id": { + "name": "department_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "position_id": { + "name": "position_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "hired_at": { + "name": "hired_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "pending_master_review": { + "name": "pending_master_review", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employees_org_employee_code_idx": { + "name": "employees_org_employee_code_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "employee_code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employees_organization_id_organizations_id_fk": { + "name": "employees_organization_id_organizations_id_fk", + "tableFrom": "employees", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employees_department_id_departments_id_fk": { + "name": "employees_department_id_departments_id_fk", + "tableFrom": "employees", + "tableTo": "departments", + "columnsFrom": [ + "department_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "employees_position_id_positions_id_fk": { + "name": "employees_position_id_positions_id_fk", + "tableFrom": "employees", + "tableTo": "positions", + "columnsFrom": [ + "position_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.import_jobs": { + "name": "import_jobs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "import_jobs_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "import_type": { + "name": "import_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "total_rows": { + "name": "total_rows", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "success_rows": { + "name": "success_rows", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "failed_rows": { + "name": "failed_rows", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "status": { + "name": "status", + "type": "import_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'processing'" + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "import_jobs_organization_id_organizations_id_fk": { + "name": "import_jobs_organization_id_organizations_id_fk", + "tableFrom": "import_jobs", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "import_jobs_created_by_users_id_fk": { + "name": "import_jobs_created_by_users_id_fk", + "tableFrom": "import_jobs", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, "public.memberships": { "name": "memberships", "schema": "", @@ -28,7 +1458,8 @@ }, "role": { "name": "role", - "type": "text", + "type": "membership_role", + "typeSchema": "public", "primaryKey": false, "notNull": true, "default": "'owner'" @@ -55,8 +1486,514 @@ "default": "now()" } }, + "indexes": { + "memberships_user_org_idx": { + "name": "memberships_user_org_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "memberships_user_id_users_id_fk": { + "name": "memberships_user_id_users_id_fk", + "tableFrom": "memberships", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "memberships_organization_id_organizations_id_fk": { + "name": "memberships_organization_id_organizations_id_fk", + "tableFrom": "memberships", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notifications": { + "name": "notifications", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "notification_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "reference_type": { + "name": "reference_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reference_id": { + "name": "reference_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "read_at": { + "name": "read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, "indexes": {}, - "foreignKeys": {}, + "foreignKeys": { + "notifications_organization_id_organizations_id_fk": { + "name": "notifications_organization_id_organizations_id_fk", + "tableFrom": "notifications", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.online_lessons": { + "name": "online_lessons", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "online_lessons_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "video_url": { + "name": "video_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "video_file_name": { + "name": "video_file_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "video_file_type": { + "name": "video_file_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "video_file_size": { + "name": "video_file_size", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "video_storage_key": { + "name": "video_storage_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "video_file_url": { + "name": "video_file_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "attachment_file_name": { + "name": "attachment_file_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "attachment_file_type": { + "name": "attachment_file_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "attachment_file_size": { + "name": "attachment_file_size", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "attachment_storage_key": { + "name": "attachment_storage_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "attachment_file_url": { + "name": "attachment_file_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "thumbnail_file_name": { + "name": "thumbnail_file_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "thumbnail_file_type": { + "name": "thumbnail_file_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "thumbnail_file_size": { + "name": "thumbnail_file_size", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "thumbnail_storage_key": { + "name": "thumbnail_storage_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "thumbnail_url": { + "name": "thumbnail_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "online_lesson_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "submitted_at": { + "name": "submitted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "submitted_by": { + "name": "submitted_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "reviewed_by": { + "name": "reviewed_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "approved_at": { + "name": "approved_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "approved_by": { + "name": "approved_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_published": { + "name": "is_published", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "published_by": { + "name": "published_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "review_comment": { + "name": "review_comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "online_lessons_organization_id_organizations_id_fk": { + "name": "online_lessons_organization_id_organizations_id_fk", + "tableFrom": "online_lessons", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "online_lessons_submitted_by_users_id_fk": { + "name": "online_lessons_submitted_by_users_id_fk", + "tableFrom": "online_lessons", + "tableTo": "users", + "columnsFrom": [ + "submitted_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "online_lessons_reviewed_by_users_id_fk": { + "name": "online_lessons_reviewed_by_users_id_fk", + "tableFrom": "online_lessons", + "tableTo": "users", + "columnsFrom": [ + "reviewed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "online_lessons_approved_by_users_id_fk": { + "name": "online_lessons_approved_by_users_id_fk", + "tableFrom": "online_lessons", + "tableTo": "users", + "columnsFrom": [ + "approved_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "online_lessons_published_by_users_id_fk": { + "name": "online_lessons_published_by_users_id_fk", + "tableFrom": "online_lessons", + "tableTo": "users", + "columnsFrom": [ + "published_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "online_lessons_created_by_users_id_fk": { + "name": "online_lessons_created_by_users_id_fk", + "tableFrom": "online_lessons", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "online_lessons_updated_by_users_id_fk": { + "name": "online_lessons_updated_by_users_id_fk", + "tableFrom": "online_lessons", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, @@ -98,6 +2035,32 @@ "notNull": true, "default": "'free'" }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "deleted_by": { + "name": "deleted_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pending_master_review": { + "name": "pending_master_review", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, "created_by": { "name": "created_by", "type": "text", @@ -136,7 +2099,624 @@ "with": {} } }, - "foreignKeys": {}, + "foreignKeys": { + "organizations_deleted_by_users_id_fk": { + "name": "organizations_deleted_by_users_id_fk", + "tableFrom": "organizations", + "tableTo": "users", + "columnsFrom": [ + "deleted_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "organizations_created_by_users_id_fk": { + "name": "organizations_created_by_users_id_fk", + "tableFrom": "organizations", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.permission_audit_logs": { + "name": "permission_audit_logs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "permission_audit_logs_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actor_user_id": { + "name": "actor_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "target_user_id": { + "name": "target_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "template_id": { + "name": "template_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "assignment_id": { + "name": "assignment_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "override_id": { + "name": "override_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "before": { + "name": "before", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "after": { + "name": "after", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "permission_audit_logs_organization_id_organizations_id_fk": { + "name": "permission_audit_logs_organization_id_organizations_id_fk", + "tableFrom": "permission_audit_logs", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "permission_audit_logs_actor_user_id_users_id_fk": { + "name": "permission_audit_logs_actor_user_id_users_id_fk", + "tableFrom": "permission_audit_logs", + "tableTo": "users", + "columnsFrom": [ + "actor_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "permission_audit_logs_target_user_id_users_id_fk": { + "name": "permission_audit_logs_target_user_id_users_id_fk", + "tableFrom": "permission_audit_logs", + "tableTo": "users", + "columnsFrom": [ + "target_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "permission_audit_logs_template_id_permission_templates_id_fk": { + "name": "permission_audit_logs_template_id_permission_templates_id_fk", + "tableFrom": "permission_audit_logs", + "tableTo": "permission_templates", + "columnsFrom": [ + "template_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "permission_audit_logs_assignment_id_user_permission_template_assignments_id_fk": { + "name": "permission_audit_logs_assignment_id_user_permission_template_assignments_id_fk", + "tableFrom": "permission_audit_logs", + "tableTo": "user_permission_template_assignments", + "columnsFrom": [ + "assignment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "permission_audit_logs_override_id_user_permission_overrides_id_fk": { + "name": "permission_audit_logs_override_id_user_permission_overrides_id_fk", + "tableFrom": "permission_audit_logs", + "tableTo": "user_permission_overrides", + "columnsFrom": [ + "override_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.permission_template_permissions": { + "name": "permission_template_permissions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "permission_template_permissions_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "template_id": { + "name": "template_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "permission": { + "name": "permission", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "permission_template_permissions_template_permission_idx": { + "name": "permission_template_permissions_template_permission_idx", + "columns": [ + { + "expression": "template_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "permission", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "permission_template_permissions_template_id_permission_templates_id_fk": { + "name": "permission_template_permissions_template_id_permission_templates_id_fk", + "tableFrom": "permission_template_permissions", + "tableTo": "permission_templates", + "columnsFrom": [ + "template_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.permission_templates": { + "name": "permission_templates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "permission_templates_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_system": { + "name": "is_system", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "permission_templates_org_code_idx": { + "name": "permission_templates_org_code_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "permission_templates_org_name_idx": { + "name": "permission_templates_org_name_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "permission_templates_organization_id_organizations_id_fk": { + "name": "permission_templates_organization_id_organizations_id_fk", + "tableFrom": "permission_templates", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "permission_templates_created_by_users_id_fk": { + "name": "permission_templates_created_by_users_id_fk", + "tableFrom": "permission_templates", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "permission_templates_updated_by_users_id_fk": { + "name": "permission_templates_updated_by_users_id_fk", + "tableFrom": "permission_templates", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.positions": { + "name": "positions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "positions_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "pending_master_review": { + "name": "pending_master_review", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "positions_org_code_idx": { + "name": "positions_org_code_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "positions_org_name_idx": { + "name": "positions_org_name_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "positions_organization_id_organizations_id_fk": { + "name": "positions_organization_id_organizations_id_fk", + "tableFrom": "positions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, @@ -216,7 +2796,1082 @@ } }, "indexes": {}, - "foreignKeys": {}, + "foreignKeys": { + "products_organization_id_organizations_id_fk": { + "name": "products_organization_id_organizations_id_fk", + "tableFrom": "products", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.training_matrices": { + "name": "training_matrices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "training_matrices_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "department_id": { + "name": "department_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "position_id": { + "name": "position_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "course_id": { + "name": "course_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_required": { + "name": "is_required", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "renewal_period_months": { + "name": "renewal_period_months", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "training_matrices_organization_id_organizations_id_fk": { + "name": "training_matrices_organization_id_organizations_id_fk", + "tableFrom": "training_matrices", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "training_matrices_department_id_departments_id_fk": { + "name": "training_matrices_department_id_departments_id_fk", + "tableFrom": "training_matrices", + "tableTo": "departments", + "columnsFrom": [ + "department_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "training_matrices_position_id_positions_id_fk": { + "name": "training_matrices_position_id_positions_id_fk", + "tableFrom": "training_matrices", + "tableTo": "positions", + "columnsFrom": [ + "position_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "training_matrices_course_id_courses_id_fk": { + "name": "training_matrices_course_id_courses_id_fk", + "tableFrom": "training_matrices", + "tableTo": "courses", + "columnsFrom": [ + "course_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.training_policies": { + "name": "training_policies", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "training_policies_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "year": { + "name": "year", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "total_target_minutes": { + "name": "total_target_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_hours": { + "name": "total_hours", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": 30 + }, + "k_target_minutes": { + "name": "k_target_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "k_hours": { + "name": "k_hours", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": 12 + }, + "s_target_minutes": { + "name": "s_target_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "s_hours": { + "name": "s_hours", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": 12 + }, + "a_target_minutes": { + "name": "a_target_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "a_hours": { + "name": "a_hours", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": 6 + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "training_policies_org_year_idx": { + "name": "training_policies_org_year_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "year", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "training_policies_organization_id_organizations_id_fk": { + "name": "training_policies_organization_id_organizations_id_fk", + "tableFrom": "training_policies", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.training_records": { + "name": "training_records", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "training_records_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "employee_id": { + "name": "employee_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "course_id": { + "name": "course_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "course_name": { + "name": "course_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "training_date": { + "name": "training_date", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "training_type": { + "name": "training_type", + "type": "training_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "submitted_minutes": { + "name": "submitted_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "hours": { + "name": "hours", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "approved_minutes": { + "name": "approved_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "approved_hours": { + "name": "approved_hours", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "training_category", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "organizer": { + "name": "organizer", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "approval_status": { + "name": "approval_status", + "type": "approval_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "reviewer_note": { + "name": "reviewer_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reject_reason": { + "name": "reject_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "submitted_by_user_id": { + "name": "submitted_by_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reviewed_by_user_id": { + "name": "reviewed_by_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reviewed_by": { + "name": "reviewed_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "training_records_organization_id_organizations_id_fk": { + "name": "training_records_organization_id_organizations_id_fk", + "tableFrom": "training_records", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "training_records_user_id_users_id_fk": { + "name": "training_records_user_id_users_id_fk", + "tableFrom": "training_records", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "training_records_employee_id_employees_id_fk": { + "name": "training_records_employee_id_employees_id_fk", + "tableFrom": "training_records", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "training_records_course_id_courses_id_fk": { + "name": "training_records_course_id_courses_id_fk", + "tableFrom": "training_records", + "tableTo": "courses", + "columnsFrom": [ + "course_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "training_records_submitted_by_user_id_users_id_fk": { + "name": "training_records_submitted_by_user_id_users_id_fk", + "tableFrom": "training_records", + "tableTo": "users", + "columnsFrom": [ + "submitted_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "training_records_reviewed_by_user_id_users_id_fk": { + "name": "training_records_reviewed_by_user_id_users_id_fk", + "tableFrom": "training_records", + "tableTo": "users", + "columnsFrom": [ + "reviewed_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "training_records_reviewed_by_users_id_fk": { + "name": "training_records_reviewed_by_users_id_fk", + "tableFrom": "training_records", + "tableTo": "users", + "columnsFrom": [ + "reviewed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "training_records_created_by_users_id_fk": { + "name": "training_records_created_by_users_id_fk", + "tableFrom": "training_records", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_employee_maps": { + "name": "user_employee_maps", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_employee_maps_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider_user_id": { + "name": "provider_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'manual'" + }, + "is_primary": { + "name": "is_primary", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "linked_at": { + "name": "linked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "user_employee_maps_org_user_employee_idx": { + "name": "user_employee_maps_org_user_employee_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_employee_maps_organization_id_organizations_id_fk": { + "name": "user_employee_maps_organization_id_organizations_id_fk", + "tableFrom": "user_employee_maps", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_employee_maps_user_id_users_id_fk": { + "name": "user_employee_maps_user_id_users_id_fk", + "tableFrom": "user_employee_maps", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_employee_maps_employee_id_employees_id_fk": { + "name": "user_employee_maps_employee_id_employees_id_fk", + "tableFrom": "user_employee_maps", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_permission_overrides": { + "name": "user_permission_overrides", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_permission_overrides_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "permission": { + "name": "permission", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "effect": { + "name": "effect", + "type": "permission_override_effect", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "revoked_by": { + "name": "revoked_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_permission_overrides_organization_id_organizations_id_fk": { + "name": "user_permission_overrides_organization_id_organizations_id_fk", + "tableFrom": "user_permission_overrides", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_permission_overrides_user_id_users_id_fk": { + "name": "user_permission_overrides_user_id_users_id_fk", + "tableFrom": "user_permission_overrides", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_permission_overrides_created_by_users_id_fk": { + "name": "user_permission_overrides_created_by_users_id_fk", + "tableFrom": "user_permission_overrides", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "user_permission_overrides_revoked_by_users_id_fk": { + "name": "user_permission_overrides_revoked_by_users_id_fk", + "tableFrom": "user_permission_overrides", + "tableTo": "users", + "columnsFrom": [ + "revoked_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_permission_template_assignments": { + "name": "user_permission_template_assignments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_permission_template_assignments_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "template_id": { + "name": "template_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "assigned_by": { + "name": "assigned_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "user_permission_template_assignments_org_user_template_idx": { + "name": "user_permission_template_assignments_org_user_template_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "template_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_permission_template_assignments_organization_id_organizations_id_fk": { + "name": "user_permission_template_assignments_organization_id_organizations_id_fk", + "tableFrom": "user_permission_template_assignments", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_permission_template_assignments_user_id_users_id_fk": { + "name": "user_permission_template_assignments_user_id_users_id_fk", + "tableFrom": "user_permission_template_assignments", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_permission_template_assignments_template_id_permission_templates_id_fk": { + "name": "user_permission_template_assignments_template_id_permission_templates_id_fk", + "tableFrom": "user_permission_template_assignments", + "tableTo": "permission_templates", + "columnsFrom": [ + "template_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "user_permission_template_assignments_assigned_by_users_id_fk": { + "name": "user_permission_template_assignments_assigned_by_users_id_fk", + "tableFrom": "user_permission_template_assignments", + "tableTo": "users", + "columnsFrom": [ + "assigned_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, @@ -245,11 +3900,36 @@ "primaryKey": false, "notNull": true }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": false + }, "password_hash": { "name": "password_hash", "type": "text", "primaryKey": false, - "notNull": true + "notNull": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'credentials'" + }, + "provider_user_id": { + "name": "provider_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false }, "image": { "name": "image", @@ -257,12 +3937,69 @@ "primaryKey": false, "notNull": false }, + "system_role": { + "name": "system_role", + "type": "system_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'standard'" + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "employee_code": { + "name": "employee_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "employee_id": { + "name": "employee_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "department_id": { + "name": "department_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "position_id": { + "name": "position_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "company_name": { + "name": "company_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "hired_at": { + "name": "hired_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, "active_organization_id": { "name": "active_organization_id", "type": "text", "primaryKey": false, "notNull": false }, + "last_login_at": { + "name": "last_login_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, "created_at": { "name": "created_at", "type": "timestamp with time zone", @@ -293,9 +4030,59 @@ "concurrently": false, "method": "btree", "with": {} + }, + "users_username_idx": { + "name": "users_username_idx", + "columns": [ + { + "expression": "username", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_provider_user_id_idx": { + "name": "users_provider_user_id_idx", + "columns": [ + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "users_employee_id_employees_id_fk": { + "name": "users_employee_id_employees_id_fk", + "tableFrom": "users", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" } }, - "foreignKeys": {}, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, @@ -303,7 +4090,108 @@ "isRLSEnabled": false } }, - "enums": {}, + "enums": { + "public.announcement_status": { + "name": "announcement_status", + "schema": "public", + "values": [ + "draft", + "pending_review", + "approved", + "published", + "returned", + "rejected", + "archived" + ] + }, + "public.approval_status": { + "name": "approval_status", + "schema": "public", + "values": [ + "draft", + "pending", + "approved", + "rejected", + "needs_revision" + ] + }, + "public.import_status": { + "name": "import_status", + "schema": "public", + "values": [ + "processing", + "completed", + "failed" + ] + }, + "public.membership_role": { + "name": "membership_role", + "schema": "public", + "values": [ + "owner", + "admin", + "member" + ] + }, + "public.notification_type": { + "name": "notification_type", + "schema": "public", + "values": [ + "approved", + "rejected", + "announcement", + "reminder" + ] + }, + "public.online_lesson_status": { + "name": "online_lesson_status", + "schema": "public", + "values": [ + "draft", + "pending_review", + "approved", + "published", + "returned", + "rejected", + "archived" + ] + }, + "public.permission_override_effect": { + "name": "permission_override_effect", + "schema": "public", + "values": [ + "allow", + "deny" + ] + }, + "public.system_role": { + "name": "system_role", + "schema": "public", + "values": [ + "standard", + "super_admin" + ] + }, + "public.training_category": { + "name": "training_category", + "schema": "public", + "values": [ + "K", + "S", + "A" + ] + }, + "public.training_type": { + "name": "training_type", + "schema": "public", + "values": [ + "online", + "onsite", + "internal", + "external" + ] + } + }, "schemas": {}, "sequences": {}, "roles": {}, diff --git a/drizzle/meta/0001_snapshot.json b/drizzle/meta/0001_snapshot.json deleted file mode 100644 index 975e5e1..0000000 --- a/drizzle/meta/0001_snapshot.json +++ /dev/null @@ -1,1457 +0,0 @@ -{ - "id": "b3a805b9-ef0b-434e-9da4-a18695abcd89", - "prevId": "ae7121c5-e461-44b8-8b25-7f5459f3ad7c", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.certificates": { - "name": "certificates", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "certificates_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "training_record_id": { - "name": "training_record_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "storage_key": { - "name": "storage_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_url": { - "name": "file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "uploaded_by": { - "name": "uploaded_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "uploaded_at": { - "name": "uploaded_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "certificates_organization_id_organizations_id_fk": { - "name": "certificates_organization_id_organizations_id_fk", - "tableFrom": "certificates", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "certificates_training_record_id_training_records_id_fk": { - "name": "certificates_training_record_id_training_records_id_fk", - "tableFrom": "certificates", - "tableTo": "training_records", - "columnsFrom": [ - "training_record_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "certificates_uploaded_by_users_id_fk": { - "name": "certificates_uploaded_by_users_id_fk", - "tableFrom": "certificates", - "tableTo": "users", - "columnsFrom": [ - "uploaded_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.courses": { - "name": "courses", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "courses_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organizer": { - "name": "organizer", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "standard_hours": { - "name": "standard_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "certificate_validity_months": { - "name": "certificate_validity_months", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "courses_org_name_idx": { - "name": "courses_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "courses_organization_id_organizations_id_fk": { - "name": "courses_organization_id_organizations_id_fk", - "tableFrom": "courses", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.departments": { - "name": "departments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "departments_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "departments_org_code_idx": { - "name": "departments_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "departments_org_name_idx": { - "name": "departments_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "departments_organization_id_organizations_id_fk": { - "name": "departments_organization_id_organizations_id_fk", - "tableFrom": "departments", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.employees": { - "name": "employees", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "employees_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "employee_code": { - "name": "employee_code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "full_name": { - "name": "full_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "company": { - "name": "company", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "hired_at": { - "name": "hired_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "employees_org_employee_code_idx": { - "name": "employees_org_employee_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "employee_code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "employees_organization_id_organizations_id_fk": { - "name": "employees_organization_id_organizations_id_fk", - "tableFrom": "employees", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "employees_department_id_departments_id_fk": { - "name": "employees_department_id_departments_id_fk", - "tableFrom": "employees", - "tableTo": "departments", - "columnsFrom": [ - "department_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "employees_position_id_positions_id_fk": { - "name": "employees_position_id_positions_id_fk", - "tableFrom": "employees", - "tableTo": "positions", - "columnsFrom": [ - "position_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.memberships": { - "name": "memberships", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "membership_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'owner'" - }, - "permissions": { - "name": "permissions", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "memberships_user_org_idx": { - "name": "memberships_user_org_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "memberships_user_id_users_id_fk": { - "name": "memberships_user_id_users_id_fk", - "tableFrom": "memberships", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "memberships_organization_id_organizations_id_fk": { - "name": "memberships_organization_id_organizations_id_fk", - "tableFrom": "memberships", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.organizations": { - "name": "organizations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "slug": { - "name": "slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "image_url": { - "name": "image_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "plan": { - "name": "plan", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "organizations_slug_idx": { - "name": "organizations_slug_idx", - "columns": [ - { - "expression": "slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "organizations_created_by_users_id_fk": { - "name": "organizations_created_by_users_id_fk", - "tableFrom": "organizations", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.positions": { - "name": "positions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "positions_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "positions_org_code_idx": { - "name": "positions_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "positions_org_name_idx": { - "name": "positions_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "positions_organization_id_organizations_id_fk": { - "name": "positions_organization_id_organizations_id_fk", - "tableFrom": "positions", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.products": { - "name": "products", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "products_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "photo_url": { - "name": "photo_url", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "price": { - "name": "price", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "products_organization_id_organizations_id_fk": { - "name": "products_organization_id_organizations_id_fk", - "tableFrom": "products", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_matrices": { - "name": "training_matrices", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_matrices_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_id": { - "name": "course_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "renewal_period_months": { - "name": "renewal_period_months", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "training_matrices_organization_id_organizations_id_fk": { - "name": "training_matrices_organization_id_organizations_id_fk", - "tableFrom": "training_matrices", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_department_id_departments_id_fk": { - "name": "training_matrices_department_id_departments_id_fk", - "tableFrom": "training_matrices", - "tableTo": "departments", - "columnsFrom": [ - "department_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_position_id_positions_id_fk": { - "name": "training_matrices_position_id_positions_id_fk", - "tableFrom": "training_matrices", - "tableTo": "positions", - "columnsFrom": [ - "position_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_course_id_courses_id_fk": { - "name": "training_matrices_course_id_courses_id_fk", - "tableFrom": "training_matrices", - "tableTo": "courses", - "columnsFrom": [ - "course_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_records": { - "name": "training_records", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_records_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "course_id": { - "name": "course_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "training_date": { - "name": "training_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "training_type": { - "name": "training_type", - "type": "training_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "hours": { - "name": "hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "organizer": { - "name": "organizer", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approval_status": { - "name": "approval_status", - "type": "approval_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "reviewer_note": { - "name": "reviewer_note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_by": { - "name": "reviewed_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_at": { - "name": "reviewed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "training_records_organization_id_organizations_id_fk": { - "name": "training_records_organization_id_organizations_id_fk", - "tableFrom": "training_records", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_records_employee_id_employees_id_fk": { - "name": "training_records_employee_id_employees_id_fk", - "tableFrom": "training_records", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_records_course_id_courses_id_fk": { - "name": "training_records_course_id_courses_id_fk", - "tableFrom": "training_records", - "tableTo": "courses", - "columnsFrom": [ - "course_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "training_records_reviewed_by_users_id_fk": { - "name": "training_records_reviewed_by_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "reviewed_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_created_by_users_id_fk": { - "name": "training_records_created_by_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "password_hash": { - "name": "password_hash", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "image": { - "name": "image", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "active_organization_id": { - "name": "active_organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "users_email_idx": { - "name": "users_email_idx", - "columns": [ - { - "expression": "email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": { - "public.approval_status": { - "name": "approval_status", - "schema": "public", - "values": [ - "pending", - "approved", - "rejected", - "needs_revision" - ] - }, - "public.membership_role": { - "name": "membership_role", - "schema": "public", - "values": [ - "owner", - "admin", - "member" - ] - }, - "public.training_type": { - "name": "training_type", - "schema": "public", - "values": [ - "online", - "onsite", - "internal", - "external" - ] - } - }, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/0002_snapshot.json b/drizzle/meta/0002_snapshot.json deleted file mode 100644 index 8be0d35..0000000 --- a/drizzle/meta/0002_snapshot.json +++ /dev/null @@ -1,1486 +0,0 @@ -{ - "id": "20e3cd10-ef08-48e1-af75-82a93e60721e", - "prevId": "b3a805b9-ef0b-434e-9da4-a18695abcd89", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.certificates": { - "name": "certificates", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "certificates_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "training_record_id": { - "name": "training_record_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "storage_key": { - "name": "storage_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_url": { - "name": "file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "uploaded_by": { - "name": "uploaded_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "uploaded_at": { - "name": "uploaded_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "certificates_organization_id_organizations_id_fk": { - "name": "certificates_organization_id_organizations_id_fk", - "tableFrom": "certificates", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "certificates_training_record_id_training_records_id_fk": { - "name": "certificates_training_record_id_training_records_id_fk", - "tableFrom": "certificates", - "tableTo": "training_records", - "columnsFrom": [ - "training_record_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "certificates_uploaded_by_users_id_fk": { - "name": "certificates_uploaded_by_users_id_fk", - "tableFrom": "certificates", - "tableTo": "users", - "columnsFrom": [ - "uploaded_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.courses": { - "name": "courses", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "courses_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organizer": { - "name": "organizer", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "standard_hours": { - "name": "standard_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "certificate_validity_months": { - "name": "certificate_validity_months", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "courses_org_name_idx": { - "name": "courses_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "courses_organization_id_organizations_id_fk": { - "name": "courses_organization_id_organizations_id_fk", - "tableFrom": "courses", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.departments": { - "name": "departments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "departments_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "departments_org_code_idx": { - "name": "departments_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "departments_org_name_idx": { - "name": "departments_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "departments_organization_id_organizations_id_fk": { - "name": "departments_organization_id_organizations_id_fk", - "tableFrom": "departments", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.employees": { - "name": "employees", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "employees_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "employee_code": { - "name": "employee_code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "full_name": { - "name": "full_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "company": { - "name": "company", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "hired_at": { - "name": "hired_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "employees_org_employee_code_idx": { - "name": "employees_org_employee_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "employee_code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "employees_organization_id_organizations_id_fk": { - "name": "employees_organization_id_organizations_id_fk", - "tableFrom": "employees", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "employees_department_id_departments_id_fk": { - "name": "employees_department_id_departments_id_fk", - "tableFrom": "employees", - "tableTo": "departments", - "columnsFrom": [ - "department_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "employees_position_id_positions_id_fk": { - "name": "employees_position_id_positions_id_fk", - "tableFrom": "employees", - "tableTo": "positions", - "columnsFrom": [ - "position_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.memberships": { - "name": "memberships", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "membership_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'owner'" - }, - "permissions": { - "name": "permissions", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "memberships_user_org_idx": { - "name": "memberships_user_org_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "memberships_user_id_users_id_fk": { - "name": "memberships_user_id_users_id_fk", - "tableFrom": "memberships", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "memberships_organization_id_organizations_id_fk": { - "name": "memberships_organization_id_organizations_id_fk", - "tableFrom": "memberships", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.organizations": { - "name": "organizations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "slug": { - "name": "slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "image_url": { - "name": "image_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "plan": { - "name": "plan", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "organizations_slug_idx": { - "name": "organizations_slug_idx", - "columns": [ - { - "expression": "slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "organizations_created_by_users_id_fk": { - "name": "organizations_created_by_users_id_fk", - "tableFrom": "organizations", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.positions": { - "name": "positions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "positions_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "positions_org_code_idx": { - "name": "positions_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "positions_org_name_idx": { - "name": "positions_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "positions_organization_id_organizations_id_fk": { - "name": "positions_organization_id_organizations_id_fk", - "tableFrom": "positions", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.products": { - "name": "products", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "products_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "photo_url": { - "name": "photo_url", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "price": { - "name": "price", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "products_organization_id_organizations_id_fk": { - "name": "products_organization_id_organizations_id_fk", - "tableFrom": "products", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_matrices": { - "name": "training_matrices", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_matrices_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_id": { - "name": "course_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "renewal_period_months": { - "name": "renewal_period_months", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "training_matrices_organization_id_organizations_id_fk": { - "name": "training_matrices_organization_id_organizations_id_fk", - "tableFrom": "training_matrices", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_department_id_departments_id_fk": { - "name": "training_matrices_department_id_departments_id_fk", - "tableFrom": "training_matrices", - "tableTo": "departments", - "columnsFrom": [ - "department_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_position_id_positions_id_fk": { - "name": "training_matrices_position_id_positions_id_fk", - "tableFrom": "training_matrices", - "tableTo": "positions", - "columnsFrom": [ - "position_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_course_id_courses_id_fk": { - "name": "training_matrices_course_id_courses_id_fk", - "tableFrom": "training_matrices", - "tableTo": "courses", - "columnsFrom": [ - "course_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_records": { - "name": "training_records", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_records_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "course_id": { - "name": "course_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "training_date": { - "name": "training_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "training_type": { - "name": "training_type", - "type": "training_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "hours": { - "name": "hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "organizer": { - "name": "organizer", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approval_status": { - "name": "approval_status", - "type": "approval_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "reviewer_note": { - "name": "reviewer_note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_by": { - "name": "reviewed_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_at": { - "name": "reviewed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "training_records_organization_id_organizations_id_fk": { - "name": "training_records_organization_id_organizations_id_fk", - "tableFrom": "training_records", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_records_employee_id_employees_id_fk": { - "name": "training_records_employee_id_employees_id_fk", - "tableFrom": "training_records", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_records_course_id_courses_id_fk": { - "name": "training_records_course_id_courses_id_fk", - "tableFrom": "training_records", - "tableTo": "courses", - "columnsFrom": [ - "course_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "training_records_reviewed_by_users_id_fk": { - "name": "training_records_reviewed_by_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "reviewed_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_created_by_users_id_fk": { - "name": "training_records_created_by_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "password_hash": { - "name": "password_hash", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "image": { - "name": "image", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "system_role": { - "name": "system_role", - "type": "system_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'standard'" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "active_organization_id": { - "name": "active_organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "users_email_idx": { - "name": "users_email_idx", - "columns": [ - { - "expression": "email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": { - "public.approval_status": { - "name": "approval_status", - "schema": "public", - "values": [ - "pending", - "approved", - "rejected", - "needs_revision" - ] - }, - "public.membership_role": { - "name": "membership_role", - "schema": "public", - "values": [ - "owner", - "admin", - "member" - ] - }, - "public.system_role": { - "name": "system_role", - "schema": "public", - "values": [ - "standard", - "super_admin" - ] - }, - "public.training_type": { - "name": "training_type", - "schema": "public", - "values": [ - "online", - "onsite", - "internal", - "external" - ] - } - }, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/0005_snapshot.json b/drizzle/meta/0005_snapshot.json deleted file mode 100644 index 0bb022b..0000000 --- a/drizzle/meta/0005_snapshot.json +++ /dev/null @@ -1,1541 +0,0 @@ -{ - "id": "661a6537-07d3-4886-b162-803e5b2a1768", - "prevId": "20e3cd10-ef08-48e1-af75-82a93e60721e", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.certificates": { - "name": "certificates", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "certificates_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "training_record_id": { - "name": "training_record_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "storage_key": { - "name": "storage_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_url": { - "name": "file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "uploaded_by": { - "name": "uploaded_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "uploaded_at": { - "name": "uploaded_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "certificates_organization_id_organizations_id_fk": { - "name": "certificates_organization_id_organizations_id_fk", - "tableFrom": "certificates", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "certificates_training_record_id_training_records_id_fk": { - "name": "certificates_training_record_id_training_records_id_fk", - "tableFrom": "certificates", - "tableTo": "training_records", - "columnsFrom": [ - "training_record_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "certificates_uploaded_by_users_id_fk": { - "name": "certificates_uploaded_by_users_id_fk", - "tableFrom": "certificates", - "tableTo": "users", - "columnsFrom": [ - "uploaded_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.courses": { - "name": "courses", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "courses_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organizer": { - "name": "organizer", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "standard_hours": { - "name": "standard_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "certificate_validity_months": { - "name": "certificate_validity_months", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "courses_org_name_idx": { - "name": "courses_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "courses_organization_id_organizations_id_fk": { - "name": "courses_organization_id_organizations_id_fk", - "tableFrom": "courses", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.departments": { - "name": "departments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "departments_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "departments_org_code_idx": { - "name": "departments_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "departments_org_name_idx": { - "name": "departments_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "departments_organization_id_organizations_id_fk": { - "name": "departments_organization_id_organizations_id_fk", - "tableFrom": "departments", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.employees": { - "name": "employees", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "employees_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "employee_code": { - "name": "employee_code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "full_name": { - "name": "full_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "company": { - "name": "company", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "hired_at": { - "name": "hired_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "employees_org_employee_code_idx": { - "name": "employees_org_employee_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "employee_code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "employees_organization_id_organizations_id_fk": { - "name": "employees_organization_id_organizations_id_fk", - "tableFrom": "employees", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "employees_department_id_departments_id_fk": { - "name": "employees_department_id_departments_id_fk", - "tableFrom": "employees", - "tableTo": "departments", - "columnsFrom": [ - "department_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "employees_position_id_positions_id_fk": { - "name": "employees_position_id_positions_id_fk", - "tableFrom": "employees", - "tableTo": "positions", - "columnsFrom": [ - "position_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.memberships": { - "name": "memberships", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "membership_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'owner'" - }, - "permissions": { - "name": "permissions", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "memberships_user_org_idx": { - "name": "memberships_user_org_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "memberships_user_id_users_id_fk": { - "name": "memberships_user_id_users_id_fk", - "tableFrom": "memberships", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "memberships_organization_id_organizations_id_fk": { - "name": "memberships_organization_id_organizations_id_fk", - "tableFrom": "memberships", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.organizations": { - "name": "organizations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "slug": { - "name": "slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "image_url": { - "name": "image_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "plan": { - "name": "plan", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "organizations_slug_idx": { - "name": "organizations_slug_idx", - "columns": [ - { - "expression": "slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "organizations_created_by_users_id_fk": { - "name": "organizations_created_by_users_id_fk", - "tableFrom": "organizations", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.positions": { - "name": "positions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "positions_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "positions_org_code_idx": { - "name": "positions_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "positions_org_name_idx": { - "name": "positions_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "positions_organization_id_organizations_id_fk": { - "name": "positions_organization_id_organizations_id_fk", - "tableFrom": "positions", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.products": { - "name": "products", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "products_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "photo_url": { - "name": "photo_url", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "price": { - "name": "price", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "products_organization_id_organizations_id_fk": { - "name": "products_organization_id_organizations_id_fk", - "tableFrom": "products", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_matrices": { - "name": "training_matrices", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_matrices_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_id": { - "name": "course_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "renewal_period_months": { - "name": "renewal_period_months", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "training_matrices_organization_id_organizations_id_fk": { - "name": "training_matrices_organization_id_organizations_id_fk", - "tableFrom": "training_matrices", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_department_id_departments_id_fk": { - "name": "training_matrices_department_id_departments_id_fk", - "tableFrom": "training_matrices", - "tableTo": "departments", - "columnsFrom": [ - "department_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_position_id_positions_id_fk": { - "name": "training_matrices_position_id_positions_id_fk", - "tableFrom": "training_matrices", - "tableTo": "positions", - "columnsFrom": [ - "position_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_course_id_courses_id_fk": { - "name": "training_matrices_course_id_courses_id_fk", - "tableFrom": "training_matrices", - "tableTo": "courses", - "columnsFrom": [ - "course_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_records": { - "name": "training_records", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_records_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_id": { - "name": "course_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_name": { - "name": "course_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "training_date": { - "name": "training_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "training_type": { - "name": "training_type", - "type": "training_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "hours": { - "name": "hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "organizer": { - "name": "organizer", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approval_status": { - "name": "approval_status", - "type": "approval_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "reviewer_note": { - "name": "reviewer_note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_by": { - "name": "reviewed_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_at": { - "name": "reviewed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "training_records_organization_id_organizations_id_fk": { - "name": "training_records_organization_id_organizations_id_fk", - "tableFrom": "training_records", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_records_user_id_users_id_fk": { - "name": "training_records_user_id_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_records_employee_id_employees_id_fk": { - "name": "training_records_employee_id_employees_id_fk", - "tableFrom": "training_records", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_course_id_courses_id_fk": { - "name": "training_records_course_id_courses_id_fk", - "tableFrom": "training_records", - "tableTo": "courses", - "columnsFrom": [ - "course_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "training_records_reviewed_by_users_id_fk": { - "name": "training_records_reviewed_by_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "reviewed_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_created_by_users_id_fk": { - "name": "training_records_created_by_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "password_hash": { - "name": "password_hash", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "image": { - "name": "image", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "system_role": { - "name": "system_role", - "type": "system_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'standard'" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "employee_code": { - "name": "employee_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "company_name": { - "name": "company_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "hired_at": { - "name": "hired_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "active_organization_id": { - "name": "active_organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "users_email_idx": { - "name": "users_email_idx", - "columns": [ - { - "expression": "email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": { - "public.approval_status": { - "name": "approval_status", - "schema": "public", - "values": [ - "pending", - "approved", - "rejected", - "needs_revision" - ] - }, - "public.membership_role": { - "name": "membership_role", - "schema": "public", - "values": [ - "owner", - "admin", - "member" - ] - }, - "public.system_role": { - "name": "system_role", - "schema": "public", - "values": [ - "standard", - "super_admin" - ] - }, - "public.training_type": { - "name": "training_type", - "schema": "public", - "values": [ - "online", - "onsite", - "internal", - "external" - ] - } - }, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/0007_snapshot.json b/drizzle/meta/0007_snapshot.json deleted file mode 100644 index 1e94589..0000000 --- a/drizzle/meta/0007_snapshot.json +++ /dev/null @@ -1,2309 +0,0 @@ -{ - "id": "25975022-5d82-4318-9c37-884ece7cfea3", - "prevId": "661a6537-07d3-4886-b162-803e5b2a1768", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.announcements": { - "name": "announcements", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "announcements_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "attachment_file_name": { - "name": "attachment_file_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_type": { - "name": "attachment_file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_size": { - "name": "attachment_file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "attachment_storage_key": { - "name": "attachment_storage_key", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_url": { - "name": "attachment_file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "start_date": { - "name": "start_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "end_date": { - "name": "end_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "is_pin": { - "name": "is_pin", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "announcement_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'draft'" - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "announcements_organization_id_organizations_id_fk": { - "name": "announcements_organization_id_organizations_id_fk", - "tableFrom": "announcements", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "announcements_created_by_users_id_fk": { - "name": "announcements_created_by_users_id_fk", - "tableFrom": "announcements", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "announcements_updated_by_users_id_fk": { - "name": "announcements_updated_by_users_id_fk", - "tableFrom": "announcements", - "tableTo": "users", - "columnsFrom": [ - "updated_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.audit_logs": { - "name": "audit_logs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "audit_logs_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "module_name": { - "name": "module_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "action": { - "name": "action", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_name": { - "name": "entity_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "old_value": { - "name": "old_value", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "new_value": { - "name": "new_value", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "ip_address": { - "name": "ip_address", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_agent": { - "name": "user_agent", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "audit_logs_organization_id_organizations_id_fk": { - "name": "audit_logs_organization_id_organizations_id_fk", - "tableFrom": "audit_logs", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "audit_logs_user_id_users_id_fk": { - "name": "audit_logs_user_id_users_id_fk", - "tableFrom": "audit_logs", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.certificates": { - "name": "certificates", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "certificates_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "training_record_id": { - "name": "training_record_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "storage_key": { - "name": "storage_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_url": { - "name": "file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "uploaded_by": { - "name": "uploaded_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "uploaded_at": { - "name": "uploaded_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "certificates_organization_id_organizations_id_fk": { - "name": "certificates_organization_id_organizations_id_fk", - "tableFrom": "certificates", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "certificates_training_record_id_training_records_id_fk": { - "name": "certificates_training_record_id_training_records_id_fk", - "tableFrom": "certificates", - "tableTo": "training_records", - "columnsFrom": [ - "training_record_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "certificates_uploaded_by_users_id_fk": { - "name": "certificates_uploaded_by_users_id_fk", - "tableFrom": "certificates", - "tableTo": "users", - "columnsFrom": [ - "uploaded_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.courses": { - "name": "courses", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "courses_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "course_code": { - "name": "course_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organizer": { - "name": "organizer", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "standard_hours": { - "name": "standard_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "certificate_validity_months": { - "name": "certificate_validity_months", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "certificate_required": { - "name": "certificate_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "training_cost": { - "name": "training_cost", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "courses_org_name_idx": { - "name": "courses_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "courses_organization_id_organizations_id_fk": { - "name": "courses_organization_id_organizations_id_fk", - "tableFrom": "courses", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.departments": { - "name": "departments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "departments_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "departments_org_code_idx": { - "name": "departments_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "departments_org_name_idx": { - "name": "departments_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "departments_organization_id_organizations_id_fk": { - "name": "departments_organization_id_organizations_id_fk", - "tableFrom": "departments", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.employees": { - "name": "employees", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "employees_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "employee_code": { - "name": "employee_code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "full_name": { - "name": "full_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "company": { - "name": "company", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "hired_at": { - "name": "hired_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "employees_org_employee_code_idx": { - "name": "employees_org_employee_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "employee_code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "employees_organization_id_organizations_id_fk": { - "name": "employees_organization_id_organizations_id_fk", - "tableFrom": "employees", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "employees_department_id_departments_id_fk": { - "name": "employees_department_id_departments_id_fk", - "tableFrom": "employees", - "tableTo": "departments", - "columnsFrom": [ - "department_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "employees_position_id_positions_id_fk": { - "name": "employees_position_id_positions_id_fk", - "tableFrom": "employees", - "tableTo": "positions", - "columnsFrom": [ - "position_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.import_jobs": { - "name": "import_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "import_jobs_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "import_type": { - "name": "import_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "total_rows": { - "name": "total_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "success_rows": { - "name": "success_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "failed_rows": { - "name": "failed_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "import_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'processing'" - }, - "error_message": { - "name": "error_message", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "import_jobs_organization_id_organizations_id_fk": { - "name": "import_jobs_organization_id_organizations_id_fk", - "tableFrom": "import_jobs", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "import_jobs_created_by_users_id_fk": { - "name": "import_jobs_created_by_users_id_fk", - "tableFrom": "import_jobs", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.memberships": { - "name": "memberships", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "membership_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'owner'" - }, - "permissions": { - "name": "permissions", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "memberships_user_org_idx": { - "name": "memberships_user_org_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "memberships_user_id_users_id_fk": { - "name": "memberships_user_id_users_id_fk", - "tableFrom": "memberships", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "memberships_organization_id_organizations_id_fk": { - "name": "memberships_organization_id_organizations_id_fk", - "tableFrom": "memberships", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.notifications": { - "name": "notifications", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "notifications_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "message": { - "name": "message", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "type": { - "name": "type", - "type": "notification_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "reference_type": { - "name": "reference_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reference_id": { - "name": "reference_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_read": { - "name": "is_read", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "read_at": { - "name": "read_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "notifications_organization_id_organizations_id_fk": { - "name": "notifications_organization_id_organizations_id_fk", - "tableFrom": "notifications", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "notifications_user_id_users_id_fk": { - "name": "notifications_user_id_users_id_fk", - "tableFrom": "notifications", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.organizations": { - "name": "organizations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "slug": { - "name": "slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "image_url": { - "name": "image_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "plan": { - "name": "plan", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "organizations_slug_idx": { - "name": "organizations_slug_idx", - "columns": [ - { - "expression": "slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "organizations_created_by_users_id_fk": { - "name": "organizations_created_by_users_id_fk", - "tableFrom": "organizations", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.positions": { - "name": "positions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "positions_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "positions_org_code_idx": { - "name": "positions_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "positions_org_name_idx": { - "name": "positions_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "positions_organization_id_organizations_id_fk": { - "name": "positions_organization_id_organizations_id_fk", - "tableFrom": "positions", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.products": { - "name": "products", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "products_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "photo_url": { - "name": "photo_url", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "price": { - "name": "price", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "products_organization_id_organizations_id_fk": { - "name": "products_organization_id_organizations_id_fk", - "tableFrom": "products", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_matrices": { - "name": "training_matrices", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_matrices_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_id": { - "name": "course_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "renewal_period_months": { - "name": "renewal_period_months", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "training_matrices_organization_id_organizations_id_fk": { - "name": "training_matrices_organization_id_organizations_id_fk", - "tableFrom": "training_matrices", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_department_id_departments_id_fk": { - "name": "training_matrices_department_id_departments_id_fk", - "tableFrom": "training_matrices", - "tableTo": "departments", - "columnsFrom": [ - "department_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_position_id_positions_id_fk": { - "name": "training_matrices_position_id_positions_id_fk", - "tableFrom": "training_matrices", - "tableTo": "positions", - "columnsFrom": [ - "position_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_course_id_courses_id_fk": { - "name": "training_matrices_course_id_courses_id_fk", - "tableFrom": "training_matrices", - "tableTo": "courses", - "columnsFrom": [ - "course_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_policies": { - "name": "training_policies", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_policies_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "year": { - "name": "year", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "total_hours": { - "name": "total_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 30 - }, - "k_hours": { - "name": "k_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 12 - }, - "s_hours": { - "name": "s_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 12 - }, - "a_hours": { - "name": "a_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 6 - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "training_policies_org_year_idx": { - "name": "training_policies_org_year_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "year", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "training_policies_organization_id_organizations_id_fk": { - "name": "training_policies_organization_id_organizations_id_fk", - "tableFrom": "training_policies", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_records": { - "name": "training_records", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_records_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_id": { - "name": "course_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_name": { - "name": "course_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "training_date": { - "name": "training_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "training_type": { - "name": "training_type", - "type": "training_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "hours": { - "name": "hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "approved_hours": { - "name": "approved_hours", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "category": { - "name": "category", - "type": "training_category", - "typeSchema": "public", - "primaryKey": false, - "notNull": false - }, - "organizer": { - "name": "organizer", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approval_status": { - "name": "approval_status", - "type": "approval_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "reviewer_note": { - "name": "reviewer_note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reject_reason": { - "name": "reject_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_by": { - "name": "reviewed_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_at": { - "name": "reviewed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "training_records_organization_id_organizations_id_fk": { - "name": "training_records_organization_id_organizations_id_fk", - "tableFrom": "training_records", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_records_user_id_users_id_fk": { - "name": "training_records_user_id_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_records_employee_id_employees_id_fk": { - "name": "training_records_employee_id_employees_id_fk", - "tableFrom": "training_records", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_course_id_courses_id_fk": { - "name": "training_records_course_id_courses_id_fk", - "tableFrom": "training_records", - "tableTo": "courses", - "columnsFrom": [ - "course_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "training_records_reviewed_by_users_id_fk": { - "name": "training_records_reviewed_by_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "reviewed_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_created_by_users_id_fk": { - "name": "training_records_created_by_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "password_hash": { - "name": "password_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "image": { - "name": "image", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "system_role": { - "name": "system_role", - "type": "system_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'standard'" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "employee_code": { - "name": "employee_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "company_name": { - "name": "company_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "hired_at": { - "name": "hired_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "active_organization_id": { - "name": "active_organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "users_email_idx": { - "name": "users_email_idx", - "columns": [ - { - "expression": "email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": { - "public.announcement_status": { - "name": "announcement_status", - "schema": "public", - "values": [ - "draft", - "published", - "archived" - ] - }, - "public.approval_status": { - "name": "approval_status", - "schema": "public", - "values": [ - "pending", - "approved", - "rejected", - "needs_revision" - ] - }, - "public.import_status": { - "name": "import_status", - "schema": "public", - "values": [ - "processing", - "completed", - "failed" - ] - }, - "public.membership_role": { - "name": "membership_role", - "schema": "public", - "values": [ - "owner", - "admin", - "member" - ] - }, - "public.notification_type": { - "name": "notification_type", - "schema": "public", - "values": [ - "approved", - "rejected", - "announcement", - "reminder" - ] - }, - "public.system_role": { - "name": "system_role", - "schema": "public", - "values": [ - "standard", - "super_admin" - ] - }, - "public.training_category": { - "name": "training_category", - "schema": "public", - "values": [ - "K", - "S", - "A" - ] - }, - "public.training_type": { - "name": "training_type", - "schema": "public", - "values": [ - "online", - "onsite", - "internal", - "external" - ] - } - }, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/0008_snapshot.json b/drizzle/meta/0008_snapshot.json deleted file mode 100644 index 7d12d0c..0000000 --- a/drizzle/meta/0008_snapshot.json +++ /dev/null @@ -1,2330 +0,0 @@ -{ - "id": "37b1520a-6ef3-413e-9e8b-4984e57260e9", - "prevId": "25975022-5d82-4318-9c37-884ece7cfea3", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.announcements": { - "name": "announcements", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "announcements_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "attachment_file_name": { - "name": "attachment_file_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_type": { - "name": "attachment_file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_size": { - "name": "attachment_file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "attachment_storage_key": { - "name": "attachment_storage_key", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_url": { - "name": "attachment_file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "start_date": { - "name": "start_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "end_date": { - "name": "end_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "is_pin": { - "name": "is_pin", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "announcement_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'draft'" - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "announcements_organization_id_organizations_id_fk": { - "name": "announcements_organization_id_organizations_id_fk", - "tableFrom": "announcements", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "announcements_created_by_users_id_fk": { - "name": "announcements_created_by_users_id_fk", - "tableFrom": "announcements", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "announcements_updated_by_users_id_fk": { - "name": "announcements_updated_by_users_id_fk", - "tableFrom": "announcements", - "tableTo": "users", - "columnsFrom": [ - "updated_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.audit_logs": { - "name": "audit_logs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "audit_logs_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "module_name": { - "name": "module_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "action": { - "name": "action", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_name": { - "name": "entity_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "old_value": { - "name": "old_value", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "new_value": { - "name": "new_value", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "ip_address": { - "name": "ip_address", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_agent": { - "name": "user_agent", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "audit_logs_organization_id_organizations_id_fk": { - "name": "audit_logs_organization_id_organizations_id_fk", - "tableFrom": "audit_logs", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "audit_logs_user_id_users_id_fk": { - "name": "audit_logs_user_id_users_id_fk", - "tableFrom": "audit_logs", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.certificates": { - "name": "certificates", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "certificates_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "training_record_id": { - "name": "training_record_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "storage_key": { - "name": "storage_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_url": { - "name": "file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "uploaded_by": { - "name": "uploaded_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "uploaded_at": { - "name": "uploaded_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "certificates_organization_id_organizations_id_fk": { - "name": "certificates_organization_id_organizations_id_fk", - "tableFrom": "certificates", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "certificates_training_record_id_training_records_id_fk": { - "name": "certificates_training_record_id_training_records_id_fk", - "tableFrom": "certificates", - "tableTo": "training_records", - "columnsFrom": [ - "training_record_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "certificates_uploaded_by_users_id_fk": { - "name": "certificates_uploaded_by_users_id_fk", - "tableFrom": "certificates", - "tableTo": "users", - "columnsFrom": [ - "uploaded_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.courses": { - "name": "courses", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "courses_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "course_code": { - "name": "course_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organizer": { - "name": "organizer", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "standard_hours": { - "name": "standard_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "certificate_validity_months": { - "name": "certificate_validity_months", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "certificate_required": { - "name": "certificate_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "training_cost": { - "name": "training_cost", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "courses_org_name_idx": { - "name": "courses_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "courses_organization_id_organizations_id_fk": { - "name": "courses_organization_id_organizations_id_fk", - "tableFrom": "courses", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.departments": { - "name": "departments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "departments_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "departments_org_code_idx": { - "name": "departments_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "departments_org_name_idx": { - "name": "departments_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "departments_organization_id_organizations_id_fk": { - "name": "departments_organization_id_organizations_id_fk", - "tableFrom": "departments", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.employees": { - "name": "employees", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "employees_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "employee_code": { - "name": "employee_code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "full_name": { - "name": "full_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "company": { - "name": "company", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "hired_at": { - "name": "hired_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "employees_org_employee_code_idx": { - "name": "employees_org_employee_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "employee_code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "employees_organization_id_organizations_id_fk": { - "name": "employees_organization_id_organizations_id_fk", - "tableFrom": "employees", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "employees_department_id_departments_id_fk": { - "name": "employees_department_id_departments_id_fk", - "tableFrom": "employees", - "tableTo": "departments", - "columnsFrom": [ - "department_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "employees_position_id_positions_id_fk": { - "name": "employees_position_id_positions_id_fk", - "tableFrom": "employees", - "tableTo": "positions", - "columnsFrom": [ - "position_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.import_jobs": { - "name": "import_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "import_jobs_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "import_type": { - "name": "import_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "total_rows": { - "name": "total_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "success_rows": { - "name": "success_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "failed_rows": { - "name": "failed_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "import_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'processing'" - }, - "error_message": { - "name": "error_message", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "import_jobs_organization_id_organizations_id_fk": { - "name": "import_jobs_organization_id_organizations_id_fk", - "tableFrom": "import_jobs", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "import_jobs_created_by_users_id_fk": { - "name": "import_jobs_created_by_users_id_fk", - "tableFrom": "import_jobs", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.memberships": { - "name": "memberships", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "membership_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'owner'" - }, - "permissions": { - "name": "permissions", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "memberships_user_org_idx": { - "name": "memberships_user_org_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "memberships_user_id_users_id_fk": { - "name": "memberships_user_id_users_id_fk", - "tableFrom": "memberships", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "memberships_organization_id_organizations_id_fk": { - "name": "memberships_organization_id_organizations_id_fk", - "tableFrom": "memberships", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.notifications": { - "name": "notifications", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "notifications_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "message": { - "name": "message", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "type": { - "name": "type", - "type": "notification_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "reference_type": { - "name": "reference_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reference_id": { - "name": "reference_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_read": { - "name": "is_read", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "read_at": { - "name": "read_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "notifications_organization_id_organizations_id_fk": { - "name": "notifications_organization_id_organizations_id_fk", - "tableFrom": "notifications", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "notifications_user_id_users_id_fk": { - "name": "notifications_user_id_users_id_fk", - "tableFrom": "notifications", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.organizations": { - "name": "organizations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "slug": { - "name": "slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "image_url": { - "name": "image_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "plan": { - "name": "plan", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "organizations_slug_idx": { - "name": "organizations_slug_idx", - "columns": [ - { - "expression": "slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "organizations_created_by_users_id_fk": { - "name": "organizations_created_by_users_id_fk", - "tableFrom": "organizations", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.positions": { - "name": "positions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "positions_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "positions_org_code_idx": { - "name": "positions_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "positions_org_name_idx": { - "name": "positions_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "positions_organization_id_organizations_id_fk": { - "name": "positions_organization_id_organizations_id_fk", - "tableFrom": "positions", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.products": { - "name": "products", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "products_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "photo_url": { - "name": "photo_url", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "price": { - "name": "price", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "products_organization_id_organizations_id_fk": { - "name": "products_organization_id_organizations_id_fk", - "tableFrom": "products", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_matrices": { - "name": "training_matrices", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_matrices_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_id": { - "name": "course_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "renewal_period_months": { - "name": "renewal_period_months", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "training_matrices_organization_id_organizations_id_fk": { - "name": "training_matrices_organization_id_organizations_id_fk", - "tableFrom": "training_matrices", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_department_id_departments_id_fk": { - "name": "training_matrices_department_id_departments_id_fk", - "tableFrom": "training_matrices", - "tableTo": "departments", - "columnsFrom": [ - "department_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_position_id_positions_id_fk": { - "name": "training_matrices_position_id_positions_id_fk", - "tableFrom": "training_matrices", - "tableTo": "positions", - "columnsFrom": [ - "position_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_course_id_courses_id_fk": { - "name": "training_matrices_course_id_courses_id_fk", - "tableFrom": "training_matrices", - "tableTo": "courses", - "columnsFrom": [ - "course_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_policies": { - "name": "training_policies", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_policies_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "year": { - "name": "year", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "total_hours": { - "name": "total_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 30 - }, - "k_hours": { - "name": "k_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 12 - }, - "s_hours": { - "name": "s_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 12 - }, - "a_hours": { - "name": "a_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 6 - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "training_policies_org_year_idx": { - "name": "training_policies_org_year_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "year", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "training_policies_organization_id_organizations_id_fk": { - "name": "training_policies_organization_id_organizations_id_fk", - "tableFrom": "training_policies", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_records": { - "name": "training_records", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_records_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_id": { - "name": "course_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_name": { - "name": "course_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "training_date": { - "name": "training_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "training_type": { - "name": "training_type", - "type": "training_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "hours": { - "name": "hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "approved_hours": { - "name": "approved_hours", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "category": { - "name": "category", - "type": "training_category", - "typeSchema": "public", - "primaryKey": false, - "notNull": false - }, - "organizer": { - "name": "organizer", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approval_status": { - "name": "approval_status", - "type": "approval_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "reviewer_note": { - "name": "reviewer_note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reject_reason": { - "name": "reject_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_by": { - "name": "reviewed_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_at": { - "name": "reviewed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "training_records_organization_id_organizations_id_fk": { - "name": "training_records_organization_id_organizations_id_fk", - "tableFrom": "training_records", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_records_user_id_users_id_fk": { - "name": "training_records_user_id_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_records_employee_id_employees_id_fk": { - "name": "training_records_employee_id_employees_id_fk", - "tableFrom": "training_records", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_course_id_courses_id_fk": { - "name": "training_records_course_id_courses_id_fk", - "tableFrom": "training_records", - "tableTo": "courses", - "columnsFrom": [ - "course_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "training_records_reviewed_by_users_id_fk": { - "name": "training_records_reviewed_by_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "reviewed_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_created_by_users_id_fk": { - "name": "training_records_created_by_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "username": { - "name": "username", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "password_hash": { - "name": "password_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "image": { - "name": "image", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "system_role": { - "name": "system_role", - "type": "system_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'standard'" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "employee_code": { - "name": "employee_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "company_name": { - "name": "company_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "hired_at": { - "name": "hired_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "active_organization_id": { - "name": "active_organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "users_email_idx": { - "name": "users_email_idx", - "columns": [ - { - "expression": "email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_username_idx": { - "name": "users_username_idx", - "columns": [ - { - "expression": "username", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": { - "public.announcement_status": { - "name": "announcement_status", - "schema": "public", - "values": [ - "draft", - "published", - "archived" - ] - }, - "public.approval_status": { - "name": "approval_status", - "schema": "public", - "values": [ - "pending", - "approved", - "rejected", - "needs_revision" - ] - }, - "public.import_status": { - "name": "import_status", - "schema": "public", - "values": [ - "processing", - "completed", - "failed" - ] - }, - "public.membership_role": { - "name": "membership_role", - "schema": "public", - "values": [ - "owner", - "admin", - "member" - ] - }, - "public.notification_type": { - "name": "notification_type", - "schema": "public", - "values": [ - "approved", - "rejected", - "announcement", - "reminder" - ] - }, - "public.system_role": { - "name": "system_role", - "schema": "public", - "values": [ - "standard", - "super_admin" - ] - }, - "public.training_category": { - "name": "training_category", - "schema": "public", - "values": [ - "K", - "S", - "A" - ] - }, - "public.training_type": { - "name": "training_type", - "schema": "public", - "values": [ - "online", - "onsite", - "internal", - "external" - ] - } - }, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/0009_snapshot.json b/drizzle/meta/0009_snapshot.json deleted file mode 100644 index 758bf09..0000000 --- a/drizzle/meta/0009_snapshot.json +++ /dev/null @@ -1,2643 +0,0 @@ -{ - "id": "da715a3d-633d-4401-81a3-6a4756555d9c", - "prevId": "37b1520a-6ef3-413e-9e8b-4984e57260e9", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.announcements": { - "name": "announcements", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "announcements_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "attachment_file_name": { - "name": "attachment_file_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_type": { - "name": "attachment_file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_size": { - "name": "attachment_file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "attachment_storage_key": { - "name": "attachment_storage_key", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_url": { - "name": "attachment_file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "start_date": { - "name": "start_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "end_date": { - "name": "end_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "is_pin": { - "name": "is_pin", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "announcement_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'draft'" - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "announcements_organization_id_organizations_id_fk": { - "name": "announcements_organization_id_organizations_id_fk", - "tableFrom": "announcements", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "announcements_created_by_users_id_fk": { - "name": "announcements_created_by_users_id_fk", - "tableFrom": "announcements", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "announcements_updated_by_users_id_fk": { - "name": "announcements_updated_by_users_id_fk", - "tableFrom": "announcements", - "tableTo": "users", - "columnsFrom": [ - "updated_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.audit_logs": { - "name": "audit_logs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "audit_logs_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "module_name": { - "name": "module_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "action": { - "name": "action", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_name": { - "name": "entity_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "old_value": { - "name": "old_value", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "new_value": { - "name": "new_value", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "ip_address": { - "name": "ip_address", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_agent": { - "name": "user_agent", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "audit_logs_organization_id_organizations_id_fk": { - "name": "audit_logs_organization_id_organizations_id_fk", - "tableFrom": "audit_logs", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "audit_logs_user_id_users_id_fk": { - "name": "audit_logs_user_id_users_id_fk", - "tableFrom": "audit_logs", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.certificates": { - "name": "certificates", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "certificates_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "training_record_id": { - "name": "training_record_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "storage_key": { - "name": "storage_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_url": { - "name": "file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "uploaded_by": { - "name": "uploaded_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "uploaded_at": { - "name": "uploaded_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "certificates_organization_id_organizations_id_fk": { - "name": "certificates_organization_id_organizations_id_fk", - "tableFrom": "certificates", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "certificates_training_record_id_training_records_id_fk": { - "name": "certificates_training_record_id_training_records_id_fk", - "tableFrom": "certificates", - "tableTo": "training_records", - "columnsFrom": [ - "training_record_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "certificates_uploaded_by_users_id_fk": { - "name": "certificates_uploaded_by_users_id_fk", - "tableFrom": "certificates", - "tableTo": "users", - "columnsFrom": [ - "uploaded_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.courses": { - "name": "courses", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "courses_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "course_code": { - "name": "course_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organizer": { - "name": "organizer", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "standard_hours": { - "name": "standard_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "certificate_validity_months": { - "name": "certificate_validity_months", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "certificate_required": { - "name": "certificate_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "training_cost": { - "name": "training_cost", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "courses_org_name_idx": { - "name": "courses_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "courses_organization_id_organizations_id_fk": { - "name": "courses_organization_id_organizations_id_fk", - "tableFrom": "courses", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.departments": { - "name": "departments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "departments_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "departments_org_code_idx": { - "name": "departments_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "departments_org_name_idx": { - "name": "departments_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "departments_organization_id_organizations_id_fk": { - "name": "departments_organization_id_organizations_id_fk", - "tableFrom": "departments", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.employee_training_targets": { - "name": "employee_training_targets", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "employee_training_targets_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "year": { - "name": "year", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "total_hours": { - "name": "total_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "k_hours": { - "name": "k_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "s_hours": { - "name": "s_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "a_hours": { - "name": "a_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "employee_training_targets_org_user_year_idx": { - "name": "employee_training_targets_org_user_year_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "year", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "employee_training_targets_organization_id_organizations_id_fk": { - "name": "employee_training_targets_organization_id_organizations_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "employee_training_targets_user_id_users_id_fk": { - "name": "employee_training_targets_user_id_users_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "employee_training_targets_employee_id_employees_id_fk": { - "name": "employee_training_targets_employee_id_employees_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "employee_training_targets_created_by_users_id_fk": { - "name": "employee_training_targets_created_by_users_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "employee_training_targets_updated_by_users_id_fk": { - "name": "employee_training_targets_updated_by_users_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "users", - "columnsFrom": [ - "updated_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.employees": { - "name": "employees", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "employees_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "employee_code": { - "name": "employee_code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "prefix": { - "name": "prefix", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_name_th": { - "name": "first_name_th", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "last_name_th": { - "name": "last_name_th", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_name_en": { - "name": "first_name_en", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "last_name_en": { - "name": "last_name_en", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "full_name": { - "name": "full_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "company_name": { - "name": "company_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "company": { - "name": "company", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "hired_at": { - "name": "hired_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'active'" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "employees_org_employee_code_idx": { - "name": "employees_org_employee_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "employee_code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "employees_organization_id_organizations_id_fk": { - "name": "employees_organization_id_organizations_id_fk", - "tableFrom": "employees", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "employees_department_id_departments_id_fk": { - "name": "employees_department_id_departments_id_fk", - "tableFrom": "employees", - "tableTo": "departments", - "columnsFrom": [ - "department_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "employees_position_id_positions_id_fk": { - "name": "employees_position_id_positions_id_fk", - "tableFrom": "employees", - "tableTo": "positions", - "columnsFrom": [ - "position_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.import_jobs": { - "name": "import_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "import_jobs_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "import_type": { - "name": "import_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "total_rows": { - "name": "total_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "success_rows": { - "name": "success_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "failed_rows": { - "name": "failed_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "import_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'processing'" - }, - "error_message": { - "name": "error_message", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "import_jobs_organization_id_organizations_id_fk": { - "name": "import_jobs_organization_id_organizations_id_fk", - "tableFrom": "import_jobs", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "import_jobs_created_by_users_id_fk": { - "name": "import_jobs_created_by_users_id_fk", - "tableFrom": "import_jobs", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.memberships": { - "name": "memberships", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "membership_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'owner'" - }, - "permissions": { - "name": "permissions", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "memberships_user_org_idx": { - "name": "memberships_user_org_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "memberships_user_id_users_id_fk": { - "name": "memberships_user_id_users_id_fk", - "tableFrom": "memberships", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "memberships_organization_id_organizations_id_fk": { - "name": "memberships_organization_id_organizations_id_fk", - "tableFrom": "memberships", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.notifications": { - "name": "notifications", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "notifications_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "message": { - "name": "message", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "type": { - "name": "type", - "type": "notification_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "reference_type": { - "name": "reference_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reference_id": { - "name": "reference_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_read": { - "name": "is_read", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "read_at": { - "name": "read_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "notifications_organization_id_organizations_id_fk": { - "name": "notifications_organization_id_organizations_id_fk", - "tableFrom": "notifications", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "notifications_user_id_users_id_fk": { - "name": "notifications_user_id_users_id_fk", - "tableFrom": "notifications", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.organizations": { - "name": "organizations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "slug": { - "name": "slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "image_url": { - "name": "image_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "plan": { - "name": "plan", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "organizations_slug_idx": { - "name": "organizations_slug_idx", - "columns": [ - { - "expression": "slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "organizations_created_by_users_id_fk": { - "name": "organizations_created_by_users_id_fk", - "tableFrom": "organizations", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.positions": { - "name": "positions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "positions_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "positions_org_code_idx": { - "name": "positions_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "positions_org_name_idx": { - "name": "positions_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "positions_organization_id_organizations_id_fk": { - "name": "positions_organization_id_organizations_id_fk", - "tableFrom": "positions", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.products": { - "name": "products", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "products_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "photo_url": { - "name": "photo_url", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "price": { - "name": "price", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "products_organization_id_organizations_id_fk": { - "name": "products_organization_id_organizations_id_fk", - "tableFrom": "products", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_matrices": { - "name": "training_matrices", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_matrices_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_id": { - "name": "course_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "renewal_period_months": { - "name": "renewal_period_months", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "training_matrices_organization_id_organizations_id_fk": { - "name": "training_matrices_organization_id_organizations_id_fk", - "tableFrom": "training_matrices", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_department_id_departments_id_fk": { - "name": "training_matrices_department_id_departments_id_fk", - "tableFrom": "training_matrices", - "tableTo": "departments", - "columnsFrom": [ - "department_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_position_id_positions_id_fk": { - "name": "training_matrices_position_id_positions_id_fk", - "tableFrom": "training_matrices", - "tableTo": "positions", - "columnsFrom": [ - "position_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_course_id_courses_id_fk": { - "name": "training_matrices_course_id_courses_id_fk", - "tableFrom": "training_matrices", - "tableTo": "courses", - "columnsFrom": [ - "course_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_policies": { - "name": "training_policies", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_policies_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "year": { - "name": "year", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "total_hours": { - "name": "total_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 30 - }, - "k_hours": { - "name": "k_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 12 - }, - "s_hours": { - "name": "s_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 12 - }, - "a_hours": { - "name": "a_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 6 - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "training_policies_org_year_idx": { - "name": "training_policies_org_year_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "year", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "training_policies_organization_id_organizations_id_fk": { - "name": "training_policies_organization_id_organizations_id_fk", - "tableFrom": "training_policies", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_records": { - "name": "training_records", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_records_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_id": { - "name": "course_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_name": { - "name": "course_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "training_date": { - "name": "training_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "training_type": { - "name": "training_type", - "type": "training_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "hours": { - "name": "hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "approved_hours": { - "name": "approved_hours", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "category": { - "name": "category", - "type": "training_category", - "typeSchema": "public", - "primaryKey": false, - "notNull": false - }, - "organizer": { - "name": "organizer", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approval_status": { - "name": "approval_status", - "type": "approval_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "reviewer_note": { - "name": "reviewer_note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reject_reason": { - "name": "reject_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_by": { - "name": "reviewed_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_at": { - "name": "reviewed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "training_records_organization_id_organizations_id_fk": { - "name": "training_records_organization_id_organizations_id_fk", - "tableFrom": "training_records", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_records_user_id_users_id_fk": { - "name": "training_records_user_id_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_records_employee_id_employees_id_fk": { - "name": "training_records_employee_id_employees_id_fk", - "tableFrom": "training_records", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_course_id_courses_id_fk": { - "name": "training_records_course_id_courses_id_fk", - "tableFrom": "training_records", - "tableTo": "courses", - "columnsFrom": [ - "course_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "training_records_reviewed_by_users_id_fk": { - "name": "training_records_reviewed_by_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "reviewed_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_created_by_users_id_fk": { - "name": "training_records_created_by_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "username": { - "name": "username", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "password_hash": { - "name": "password_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'credentials'" - }, - "provider_user_id": { - "name": "provider_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "image": { - "name": "image", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "system_role": { - "name": "system_role", - "type": "system_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'standard'" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "employee_code": { - "name": "employee_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "company_name": { - "name": "company_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "hired_at": { - "name": "hired_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "active_organization_id": { - "name": "active_organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "last_login_at": { - "name": "last_login_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "users_email_idx": { - "name": "users_email_idx", - "columns": [ - { - "expression": "email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_username_idx": { - "name": "users_username_idx", - "columns": [ - { - "expression": "username", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_provider_user_id_idx": { - "name": "users_provider_user_id_idx", - "columns": [ - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider_user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "users_employee_id_employees_id_fk": { - "name": "users_employee_id_employees_id_fk", - "tableFrom": "users", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": { - "public.announcement_status": { - "name": "announcement_status", - "schema": "public", - "values": [ - "draft", - "published", - "archived" - ] - }, - "public.approval_status": { - "name": "approval_status", - "schema": "public", - "values": [ - "pending", - "approved", - "rejected", - "needs_revision" - ] - }, - "public.import_status": { - "name": "import_status", - "schema": "public", - "values": [ - "processing", - "completed", - "failed" - ] - }, - "public.membership_role": { - "name": "membership_role", - "schema": "public", - "values": [ - "owner", - "admin", - "member" - ] - }, - "public.notification_type": { - "name": "notification_type", - "schema": "public", - "values": [ - "approved", - "rejected", - "announcement", - "reminder" - ] - }, - "public.system_role": { - "name": "system_role", - "schema": "public", - "values": [ - "standard", - "super_admin" - ] - }, - "public.training_category": { - "name": "training_category", - "schema": "public", - "values": [ - "K", - "S", - "A" - ] - }, - "public.training_type": { - "name": "training_type", - "schema": "public", - "values": [ - "online", - "onsite", - "internal", - "external" - ] - } - }, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/0010_snapshot.json b/drizzle/meta/0010_snapshot.json deleted file mode 100644 index 868329f..0000000 --- a/drizzle/meta/0010_snapshot.json +++ /dev/null @@ -1,2844 +0,0 @@ -{ - "id": "31643a32-cb46-44de-8312-e5c1be9a44ef", - "prevId": "da715a3d-633d-4401-81a3-6a4756555d9c", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.announcements": { - "name": "announcements", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "announcements_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "attachment_file_name": { - "name": "attachment_file_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_type": { - "name": "attachment_file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_size": { - "name": "attachment_file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "attachment_storage_key": { - "name": "attachment_storage_key", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_url": { - "name": "attachment_file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "start_date": { - "name": "start_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "end_date": { - "name": "end_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "is_pin": { - "name": "is_pin", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "announcement_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'draft'" - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "announcements_organization_id_organizations_id_fk": { - "name": "announcements_organization_id_organizations_id_fk", - "tableFrom": "announcements", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "announcements_created_by_users_id_fk": { - "name": "announcements_created_by_users_id_fk", - "tableFrom": "announcements", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "announcements_updated_by_users_id_fk": { - "name": "announcements_updated_by_users_id_fk", - "tableFrom": "announcements", - "tableTo": "users", - "columnsFrom": [ - "updated_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.audit_logs": { - "name": "audit_logs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "audit_logs_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "module_name": { - "name": "module_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "action": { - "name": "action", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_name": { - "name": "entity_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "old_value": { - "name": "old_value", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "new_value": { - "name": "new_value", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "ip_address": { - "name": "ip_address", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_agent": { - "name": "user_agent", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "audit_logs_organization_id_organizations_id_fk": { - "name": "audit_logs_organization_id_organizations_id_fk", - "tableFrom": "audit_logs", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "audit_logs_user_id_users_id_fk": { - "name": "audit_logs_user_id_users_id_fk", - "tableFrom": "audit_logs", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.certificates": { - "name": "certificates", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "certificates_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "training_record_id": { - "name": "training_record_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "storage_key": { - "name": "storage_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_url": { - "name": "file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "uploaded_by": { - "name": "uploaded_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "uploaded_at": { - "name": "uploaded_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "certificates_organization_id_organizations_id_fk": { - "name": "certificates_organization_id_organizations_id_fk", - "tableFrom": "certificates", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "certificates_training_record_id_training_records_id_fk": { - "name": "certificates_training_record_id_training_records_id_fk", - "tableFrom": "certificates", - "tableTo": "training_records", - "columnsFrom": [ - "training_record_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "certificates_uploaded_by_users_id_fk": { - "name": "certificates_uploaded_by_users_id_fk", - "tableFrom": "certificates", - "tableTo": "users", - "columnsFrom": [ - "uploaded_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.courses": { - "name": "courses", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "courses_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "course_code": { - "name": "course_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organizer": { - "name": "organizer", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "standard_hours": { - "name": "standard_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "certificate_validity_months": { - "name": "certificate_validity_months", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "certificate_required": { - "name": "certificate_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "training_cost": { - "name": "training_cost", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "courses_org_name_idx": { - "name": "courses_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "courses_organization_id_organizations_id_fk": { - "name": "courses_organization_id_organizations_id_fk", - "tableFrom": "courses", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.departments": { - "name": "departments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "departments_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "departments_org_code_idx": { - "name": "departments_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "departments_org_name_idx": { - "name": "departments_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "departments_organization_id_organizations_id_fk": { - "name": "departments_organization_id_organizations_id_fk", - "tableFrom": "departments", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.employee_training_targets": { - "name": "employee_training_targets", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "employee_training_targets_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "year": { - "name": "year", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "total_hours": { - "name": "total_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "k_hours": { - "name": "k_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "s_hours": { - "name": "s_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "a_hours": { - "name": "a_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "employee_training_targets_org_user_year_idx": { - "name": "employee_training_targets_org_user_year_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "year", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "employee_training_targets_organization_id_organizations_id_fk": { - "name": "employee_training_targets_organization_id_organizations_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "employee_training_targets_user_id_users_id_fk": { - "name": "employee_training_targets_user_id_users_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "employee_training_targets_employee_id_employees_id_fk": { - "name": "employee_training_targets_employee_id_employees_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "employee_training_targets_created_by_users_id_fk": { - "name": "employee_training_targets_created_by_users_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "employee_training_targets_updated_by_users_id_fk": { - "name": "employee_training_targets_updated_by_users_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "users", - "columnsFrom": [ - "updated_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.employees": { - "name": "employees", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "employees_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "employee_code": { - "name": "employee_code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "prefix": { - "name": "prefix", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_name_th": { - "name": "first_name_th", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "last_name_th": { - "name": "last_name_th", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_name_en": { - "name": "first_name_en", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "last_name_en": { - "name": "last_name_en", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "full_name": { - "name": "full_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "company_name": { - "name": "company_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "company": { - "name": "company", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "hired_at": { - "name": "hired_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'active'" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "employees_org_employee_code_idx": { - "name": "employees_org_employee_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "employee_code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "employees_organization_id_organizations_id_fk": { - "name": "employees_organization_id_organizations_id_fk", - "tableFrom": "employees", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "employees_department_id_departments_id_fk": { - "name": "employees_department_id_departments_id_fk", - "tableFrom": "employees", - "tableTo": "departments", - "columnsFrom": [ - "department_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "employees_position_id_positions_id_fk": { - "name": "employees_position_id_positions_id_fk", - "tableFrom": "employees", - "tableTo": "positions", - "columnsFrom": [ - "position_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.import_jobs": { - "name": "import_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "import_jobs_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "import_type": { - "name": "import_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "total_rows": { - "name": "total_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "success_rows": { - "name": "success_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "failed_rows": { - "name": "failed_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "import_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'processing'" - }, - "error_message": { - "name": "error_message", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "import_jobs_organization_id_organizations_id_fk": { - "name": "import_jobs_organization_id_organizations_id_fk", - "tableFrom": "import_jobs", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "import_jobs_created_by_users_id_fk": { - "name": "import_jobs_created_by_users_id_fk", - "tableFrom": "import_jobs", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.memberships": { - "name": "memberships", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "membership_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'owner'" - }, - "permissions": { - "name": "permissions", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "memberships_user_org_idx": { - "name": "memberships_user_org_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "memberships_user_id_users_id_fk": { - "name": "memberships_user_id_users_id_fk", - "tableFrom": "memberships", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "memberships_organization_id_organizations_id_fk": { - "name": "memberships_organization_id_organizations_id_fk", - "tableFrom": "memberships", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.notifications": { - "name": "notifications", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "notifications_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "message": { - "name": "message", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "type": { - "name": "type", - "type": "notification_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "reference_type": { - "name": "reference_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reference_id": { - "name": "reference_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_read": { - "name": "is_read", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "read_at": { - "name": "read_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "notifications_organization_id_organizations_id_fk": { - "name": "notifications_organization_id_organizations_id_fk", - "tableFrom": "notifications", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "notifications_user_id_users_id_fk": { - "name": "notifications_user_id_users_id_fk", - "tableFrom": "notifications", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.organizations": { - "name": "organizations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "slug": { - "name": "slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "image_url": { - "name": "image_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "plan": { - "name": "plan", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "organizations_slug_idx": { - "name": "organizations_slug_idx", - "columns": [ - { - "expression": "slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "organizations_created_by_users_id_fk": { - "name": "organizations_created_by_users_id_fk", - "tableFrom": "organizations", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.positions": { - "name": "positions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "positions_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "positions_org_code_idx": { - "name": "positions_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "positions_org_name_idx": { - "name": "positions_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "positions_organization_id_organizations_id_fk": { - "name": "positions_organization_id_organizations_id_fk", - "tableFrom": "positions", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.products": { - "name": "products", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "products_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "photo_url": { - "name": "photo_url", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "price": { - "name": "price", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "products_organization_id_organizations_id_fk": { - "name": "products_organization_id_organizations_id_fk", - "tableFrom": "products", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_matrices": { - "name": "training_matrices", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_matrices_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_id": { - "name": "course_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "renewal_period_months": { - "name": "renewal_period_months", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "training_matrices_organization_id_organizations_id_fk": { - "name": "training_matrices_organization_id_organizations_id_fk", - "tableFrom": "training_matrices", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_department_id_departments_id_fk": { - "name": "training_matrices_department_id_departments_id_fk", - "tableFrom": "training_matrices", - "tableTo": "departments", - "columnsFrom": [ - "department_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_position_id_positions_id_fk": { - "name": "training_matrices_position_id_positions_id_fk", - "tableFrom": "training_matrices", - "tableTo": "positions", - "columnsFrom": [ - "position_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_course_id_courses_id_fk": { - "name": "training_matrices_course_id_courses_id_fk", - "tableFrom": "training_matrices", - "tableTo": "courses", - "columnsFrom": [ - "course_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_policies": { - "name": "training_policies", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_policies_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "year": { - "name": "year", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "total_hours": { - "name": "total_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 30 - }, - "k_hours": { - "name": "k_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 12 - }, - "s_hours": { - "name": "s_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 12 - }, - "a_hours": { - "name": "a_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 6 - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "training_policies_org_year_idx": { - "name": "training_policies_org_year_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "year", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "training_policies_organization_id_organizations_id_fk": { - "name": "training_policies_organization_id_organizations_id_fk", - "tableFrom": "training_policies", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_records": { - "name": "training_records", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_records_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_id": { - "name": "course_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_name": { - "name": "course_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "training_date": { - "name": "training_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "training_type": { - "name": "training_type", - "type": "training_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "hours": { - "name": "hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "approved_hours": { - "name": "approved_hours", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "category": { - "name": "category", - "type": "training_category", - "typeSchema": "public", - "primaryKey": false, - "notNull": false - }, - "organizer": { - "name": "organizer", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approval_status": { - "name": "approval_status", - "type": "approval_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "reviewer_note": { - "name": "reviewer_note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reject_reason": { - "name": "reject_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "submitted_by_user_id": { - "name": "submitted_by_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_by_user_id": { - "name": "reviewed_by_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_by": { - "name": "reviewed_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_at": { - "name": "reviewed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "training_records_organization_id_organizations_id_fk": { - "name": "training_records_organization_id_organizations_id_fk", - "tableFrom": "training_records", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_records_user_id_users_id_fk": { - "name": "training_records_user_id_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_employee_id_employees_id_fk": { - "name": "training_records_employee_id_employees_id_fk", - "tableFrom": "training_records", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_course_id_courses_id_fk": { - "name": "training_records_course_id_courses_id_fk", - "tableFrom": "training_records", - "tableTo": "courses", - "columnsFrom": [ - "course_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "training_records_submitted_by_user_id_users_id_fk": { - "name": "training_records_submitted_by_user_id_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "submitted_by_user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_reviewed_by_user_id_users_id_fk": { - "name": "training_records_reviewed_by_user_id_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "reviewed_by_user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_reviewed_by_users_id_fk": { - "name": "training_records_reviewed_by_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "reviewed_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_created_by_users_id_fk": { - "name": "training_records_created_by_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.user_employee_maps": { - "name": "user_employee_maps", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "user_employee_maps_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "provider_user_id": { - "name": "provider_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'manual'" - }, - "is_primary": { - "name": "is_primary", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "linked_at": { - "name": "linked_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "user_employee_maps_org_user_employee_idx": { - "name": "user_employee_maps_org_user_employee_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "employee_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "user_employee_maps_organization_id_organizations_id_fk": { - "name": "user_employee_maps_organization_id_organizations_id_fk", - "tableFrom": "user_employee_maps", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "user_employee_maps_user_id_users_id_fk": { - "name": "user_employee_maps_user_id_users_id_fk", - "tableFrom": "user_employee_maps", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "user_employee_maps_employee_id_employees_id_fk": { - "name": "user_employee_maps_employee_id_employees_id_fk", - "tableFrom": "user_employee_maps", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "username": { - "name": "username", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "password_hash": { - "name": "password_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'credentials'" - }, - "provider_user_id": { - "name": "provider_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "image": { - "name": "image", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "system_role": { - "name": "system_role", - "type": "system_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'standard'" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "employee_code": { - "name": "employee_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "company_name": { - "name": "company_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "hired_at": { - "name": "hired_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "active_organization_id": { - "name": "active_organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "last_login_at": { - "name": "last_login_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "users_email_idx": { - "name": "users_email_idx", - "columns": [ - { - "expression": "email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_username_idx": { - "name": "users_username_idx", - "columns": [ - { - "expression": "username", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_provider_user_id_idx": { - "name": "users_provider_user_id_idx", - "columns": [ - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider_user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "users_employee_id_employees_id_fk": { - "name": "users_employee_id_employees_id_fk", - "tableFrom": "users", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": { - "public.announcement_status": { - "name": "announcement_status", - "schema": "public", - "values": [ - "draft", - "published", - "archived" - ] - }, - "public.approval_status": { - "name": "approval_status", - "schema": "public", - "values": [ - "pending", - "approved", - "rejected", - "needs_revision" - ] - }, - "public.import_status": { - "name": "import_status", - "schema": "public", - "values": [ - "processing", - "completed", - "failed" - ] - }, - "public.membership_role": { - "name": "membership_role", - "schema": "public", - "values": [ - "owner", - "admin", - "member" - ] - }, - "public.notification_type": { - "name": "notification_type", - "schema": "public", - "values": [ - "approved", - "rejected", - "announcement", - "reminder" - ] - }, - "public.system_role": { - "name": "system_role", - "schema": "public", - "values": [ - "standard", - "super_admin" - ] - }, - "public.training_category": { - "name": "training_category", - "schema": "public", - "values": [ - "K", - "S", - "A" - ] - }, - "public.training_type": { - "name": "training_type", - "schema": "public", - "values": [ - "online", - "onsite", - "internal", - "external" - ] - } - }, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/0011_snapshot.json b/drizzle/meta/0011_snapshot.json deleted file mode 100644 index dafb730..0000000 --- a/drizzle/meta/0011_snapshot.json +++ /dev/null @@ -1,2871 +0,0 @@ -{ - "id": "2343c109-8a83-48ac-80d2-5104cec36f04", - "prevId": "31643a32-cb46-44de-8312-e5c1be9a44ef", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.announcements": { - "name": "announcements", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "announcements_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "attachment_file_name": { - "name": "attachment_file_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_type": { - "name": "attachment_file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_size": { - "name": "attachment_file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "attachment_storage_key": { - "name": "attachment_storage_key", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_url": { - "name": "attachment_file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "start_date": { - "name": "start_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "end_date": { - "name": "end_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "is_pin": { - "name": "is_pin", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "announcement_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'draft'" - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "announcements_organization_id_organizations_id_fk": { - "name": "announcements_organization_id_organizations_id_fk", - "tableFrom": "announcements", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "announcements_created_by_users_id_fk": { - "name": "announcements_created_by_users_id_fk", - "tableFrom": "announcements", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "announcements_updated_by_users_id_fk": { - "name": "announcements_updated_by_users_id_fk", - "tableFrom": "announcements", - "tableTo": "users", - "columnsFrom": [ - "updated_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.audit_logs": { - "name": "audit_logs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "audit_logs_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "module_name": { - "name": "module_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "action": { - "name": "action", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_name": { - "name": "entity_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "old_value": { - "name": "old_value", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "new_value": { - "name": "new_value", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "ip_address": { - "name": "ip_address", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_agent": { - "name": "user_agent", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "audit_logs_organization_id_organizations_id_fk": { - "name": "audit_logs_organization_id_organizations_id_fk", - "tableFrom": "audit_logs", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "audit_logs_user_id_users_id_fk": { - "name": "audit_logs_user_id_users_id_fk", - "tableFrom": "audit_logs", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.certificates": { - "name": "certificates", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "certificates_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "training_record_id": { - "name": "training_record_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "storage_key": { - "name": "storage_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_url": { - "name": "file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "uploaded_by": { - "name": "uploaded_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "uploaded_at": { - "name": "uploaded_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "certificates_organization_id_organizations_id_fk": { - "name": "certificates_organization_id_organizations_id_fk", - "tableFrom": "certificates", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "certificates_training_record_id_training_records_id_fk": { - "name": "certificates_training_record_id_training_records_id_fk", - "tableFrom": "certificates", - "tableTo": "training_records", - "columnsFrom": [ - "training_record_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "certificates_uploaded_by_users_id_fk": { - "name": "certificates_uploaded_by_users_id_fk", - "tableFrom": "certificates", - "tableTo": "users", - "columnsFrom": [ - "uploaded_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.courses": { - "name": "courses", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "courses_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "course_code": { - "name": "course_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organizer": { - "name": "organizer", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "standard_hours": { - "name": "standard_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "certificate_validity_months": { - "name": "certificate_validity_months", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "certificate_required": { - "name": "certificate_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "training_cost": { - "name": "training_cost", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "courses_org_name_idx": { - "name": "courses_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "courses_organization_id_organizations_id_fk": { - "name": "courses_organization_id_organizations_id_fk", - "tableFrom": "courses", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.departments": { - "name": "departments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "departments_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "departments_org_code_idx": { - "name": "departments_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "departments_org_name_idx": { - "name": "departments_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "departments_organization_id_organizations_id_fk": { - "name": "departments_organization_id_organizations_id_fk", - "tableFrom": "departments", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.employee_training_targets": { - "name": "employee_training_targets", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "employee_training_targets_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "year": { - "name": "year", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "total_hours": { - "name": "total_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "k_hours": { - "name": "k_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "s_hours": { - "name": "s_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "a_hours": { - "name": "a_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "employee_training_targets_org_user_year_idx": { - "name": "employee_training_targets_org_user_year_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "year", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "employee_training_targets_org_employee_year_idx": { - "name": "employee_training_targets_org_employee_year_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "employee_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "year", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "employee_training_targets_organization_id_organizations_id_fk": { - "name": "employee_training_targets_organization_id_organizations_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "employee_training_targets_user_id_users_id_fk": { - "name": "employee_training_targets_user_id_users_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "employee_training_targets_employee_id_employees_id_fk": { - "name": "employee_training_targets_employee_id_employees_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "employee_training_targets_created_by_users_id_fk": { - "name": "employee_training_targets_created_by_users_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "employee_training_targets_updated_by_users_id_fk": { - "name": "employee_training_targets_updated_by_users_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "users", - "columnsFrom": [ - "updated_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.employees": { - "name": "employees", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "employees_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "employee_code": { - "name": "employee_code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "prefix": { - "name": "prefix", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_name_th": { - "name": "first_name_th", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "last_name_th": { - "name": "last_name_th", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_name_en": { - "name": "first_name_en", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "last_name_en": { - "name": "last_name_en", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "full_name": { - "name": "full_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "company_name": { - "name": "company_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "company": { - "name": "company", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "hired_at": { - "name": "hired_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'active'" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "employees_org_employee_code_idx": { - "name": "employees_org_employee_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "employee_code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "employees_organization_id_organizations_id_fk": { - "name": "employees_organization_id_organizations_id_fk", - "tableFrom": "employees", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "employees_department_id_departments_id_fk": { - "name": "employees_department_id_departments_id_fk", - "tableFrom": "employees", - "tableTo": "departments", - "columnsFrom": [ - "department_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "employees_position_id_positions_id_fk": { - "name": "employees_position_id_positions_id_fk", - "tableFrom": "employees", - "tableTo": "positions", - "columnsFrom": [ - "position_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.import_jobs": { - "name": "import_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "import_jobs_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "import_type": { - "name": "import_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "total_rows": { - "name": "total_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "success_rows": { - "name": "success_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "failed_rows": { - "name": "failed_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "import_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'processing'" - }, - "error_message": { - "name": "error_message", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "import_jobs_organization_id_organizations_id_fk": { - "name": "import_jobs_organization_id_organizations_id_fk", - "tableFrom": "import_jobs", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "import_jobs_created_by_users_id_fk": { - "name": "import_jobs_created_by_users_id_fk", - "tableFrom": "import_jobs", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.memberships": { - "name": "memberships", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "membership_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'owner'" - }, - "permissions": { - "name": "permissions", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "memberships_user_org_idx": { - "name": "memberships_user_org_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "memberships_user_id_users_id_fk": { - "name": "memberships_user_id_users_id_fk", - "tableFrom": "memberships", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "memberships_organization_id_organizations_id_fk": { - "name": "memberships_organization_id_organizations_id_fk", - "tableFrom": "memberships", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.notifications": { - "name": "notifications", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "notifications_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "message": { - "name": "message", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "type": { - "name": "type", - "type": "notification_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "reference_type": { - "name": "reference_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reference_id": { - "name": "reference_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_read": { - "name": "is_read", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "read_at": { - "name": "read_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "notifications_organization_id_organizations_id_fk": { - "name": "notifications_organization_id_organizations_id_fk", - "tableFrom": "notifications", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "notifications_user_id_users_id_fk": { - "name": "notifications_user_id_users_id_fk", - "tableFrom": "notifications", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.organizations": { - "name": "organizations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "slug": { - "name": "slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "image_url": { - "name": "image_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "plan": { - "name": "plan", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "organizations_slug_idx": { - "name": "organizations_slug_idx", - "columns": [ - { - "expression": "slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "organizations_created_by_users_id_fk": { - "name": "organizations_created_by_users_id_fk", - "tableFrom": "organizations", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.positions": { - "name": "positions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "positions_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "positions_org_code_idx": { - "name": "positions_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "positions_org_name_idx": { - "name": "positions_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "positions_organization_id_organizations_id_fk": { - "name": "positions_organization_id_organizations_id_fk", - "tableFrom": "positions", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.products": { - "name": "products", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "products_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "photo_url": { - "name": "photo_url", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "price": { - "name": "price", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "products_organization_id_organizations_id_fk": { - "name": "products_organization_id_organizations_id_fk", - "tableFrom": "products", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_matrices": { - "name": "training_matrices", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_matrices_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_id": { - "name": "course_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "renewal_period_months": { - "name": "renewal_period_months", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "training_matrices_organization_id_organizations_id_fk": { - "name": "training_matrices_organization_id_organizations_id_fk", - "tableFrom": "training_matrices", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_department_id_departments_id_fk": { - "name": "training_matrices_department_id_departments_id_fk", - "tableFrom": "training_matrices", - "tableTo": "departments", - "columnsFrom": [ - "department_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_position_id_positions_id_fk": { - "name": "training_matrices_position_id_positions_id_fk", - "tableFrom": "training_matrices", - "tableTo": "positions", - "columnsFrom": [ - "position_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_course_id_courses_id_fk": { - "name": "training_matrices_course_id_courses_id_fk", - "tableFrom": "training_matrices", - "tableTo": "courses", - "columnsFrom": [ - "course_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_policies": { - "name": "training_policies", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_policies_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "year": { - "name": "year", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "total_hours": { - "name": "total_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 30 - }, - "k_hours": { - "name": "k_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 12 - }, - "s_hours": { - "name": "s_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 12 - }, - "a_hours": { - "name": "a_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 6 - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "training_policies_org_year_idx": { - "name": "training_policies_org_year_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "year", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "training_policies_organization_id_organizations_id_fk": { - "name": "training_policies_organization_id_organizations_id_fk", - "tableFrom": "training_policies", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_records": { - "name": "training_records", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_records_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_id": { - "name": "course_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_name": { - "name": "course_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "training_date": { - "name": "training_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "training_type": { - "name": "training_type", - "type": "training_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "hours": { - "name": "hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "approved_hours": { - "name": "approved_hours", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "category": { - "name": "category", - "type": "training_category", - "typeSchema": "public", - "primaryKey": false, - "notNull": false - }, - "organizer": { - "name": "organizer", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approval_status": { - "name": "approval_status", - "type": "approval_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "reviewer_note": { - "name": "reviewer_note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reject_reason": { - "name": "reject_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "submitted_by_user_id": { - "name": "submitted_by_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_by_user_id": { - "name": "reviewed_by_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_by": { - "name": "reviewed_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_at": { - "name": "reviewed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "training_records_organization_id_organizations_id_fk": { - "name": "training_records_organization_id_organizations_id_fk", - "tableFrom": "training_records", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_records_user_id_users_id_fk": { - "name": "training_records_user_id_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_employee_id_employees_id_fk": { - "name": "training_records_employee_id_employees_id_fk", - "tableFrom": "training_records", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_course_id_courses_id_fk": { - "name": "training_records_course_id_courses_id_fk", - "tableFrom": "training_records", - "tableTo": "courses", - "columnsFrom": [ - "course_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "training_records_submitted_by_user_id_users_id_fk": { - "name": "training_records_submitted_by_user_id_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "submitted_by_user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_reviewed_by_user_id_users_id_fk": { - "name": "training_records_reviewed_by_user_id_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "reviewed_by_user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_reviewed_by_users_id_fk": { - "name": "training_records_reviewed_by_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "reviewed_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_created_by_users_id_fk": { - "name": "training_records_created_by_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.user_employee_maps": { - "name": "user_employee_maps", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "user_employee_maps_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "provider_user_id": { - "name": "provider_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'manual'" - }, - "is_primary": { - "name": "is_primary", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "linked_at": { - "name": "linked_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "user_employee_maps_org_user_employee_idx": { - "name": "user_employee_maps_org_user_employee_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "employee_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "user_employee_maps_organization_id_organizations_id_fk": { - "name": "user_employee_maps_organization_id_organizations_id_fk", - "tableFrom": "user_employee_maps", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "user_employee_maps_user_id_users_id_fk": { - "name": "user_employee_maps_user_id_users_id_fk", - "tableFrom": "user_employee_maps", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "user_employee_maps_employee_id_employees_id_fk": { - "name": "user_employee_maps_employee_id_employees_id_fk", - "tableFrom": "user_employee_maps", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "username": { - "name": "username", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "password_hash": { - "name": "password_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'credentials'" - }, - "provider_user_id": { - "name": "provider_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "image": { - "name": "image", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "system_role": { - "name": "system_role", - "type": "system_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'standard'" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "employee_code": { - "name": "employee_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "company_name": { - "name": "company_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "hired_at": { - "name": "hired_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "active_organization_id": { - "name": "active_organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "last_login_at": { - "name": "last_login_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "users_email_idx": { - "name": "users_email_idx", - "columns": [ - { - "expression": "email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_username_idx": { - "name": "users_username_idx", - "columns": [ - { - "expression": "username", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_provider_user_id_idx": { - "name": "users_provider_user_id_idx", - "columns": [ - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider_user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "users_employee_id_employees_id_fk": { - "name": "users_employee_id_employees_id_fk", - "tableFrom": "users", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": { - "public.announcement_status": { - "name": "announcement_status", - "schema": "public", - "values": [ - "draft", - "published", - "archived" - ] - }, - "public.approval_status": { - "name": "approval_status", - "schema": "public", - "values": [ - "pending", - "approved", - "rejected", - "needs_revision" - ] - }, - "public.import_status": { - "name": "import_status", - "schema": "public", - "values": [ - "processing", - "completed", - "failed" - ] - }, - "public.membership_role": { - "name": "membership_role", - "schema": "public", - "values": [ - "owner", - "admin", - "member" - ] - }, - "public.notification_type": { - "name": "notification_type", - "schema": "public", - "values": [ - "approved", - "rejected", - "announcement", - "reminder" - ] - }, - "public.system_role": { - "name": "system_role", - "schema": "public", - "values": [ - "standard", - "super_admin" - ] - }, - "public.training_category": { - "name": "training_category", - "schema": "public", - "values": [ - "K", - "S", - "A" - ] - }, - "public.training_type": { - "name": "training_type", - "schema": "public", - "values": [ - "online", - "onsite", - "internal", - "external" - ] - } - }, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/0013_snapshot.json b/drizzle/meta/0013_snapshot.json deleted file mode 100644 index 59154f3..0000000 --- a/drizzle/meta/0013_snapshot.json +++ /dev/null @@ -1,3177 +0,0 @@ -{ - "id": "ed68b3e5-6e71-4e57-97ef-877335f91046", - "prevId": "2343c109-8a83-48ac-80d2-5104cec36f04", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.announcements": { - "name": "announcements", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "announcements_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "attachment_file_name": { - "name": "attachment_file_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_type": { - "name": "attachment_file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_size": { - "name": "attachment_file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "attachment_storage_key": { - "name": "attachment_storage_key", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_url": { - "name": "attachment_file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "start_date": { - "name": "start_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "end_date": { - "name": "end_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "is_pin": { - "name": "is_pin", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "announcement_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'draft'" - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "announcements_organization_id_organizations_id_fk": { - "name": "announcements_organization_id_organizations_id_fk", - "tableFrom": "announcements", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "announcements_created_by_users_id_fk": { - "name": "announcements_created_by_users_id_fk", - "tableFrom": "announcements", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "announcements_updated_by_users_id_fk": { - "name": "announcements_updated_by_users_id_fk", - "tableFrom": "announcements", - "tableTo": "users", - "columnsFrom": [ - "updated_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.audit_logs": { - "name": "audit_logs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "audit_logs_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "module_name": { - "name": "module_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "action": { - "name": "action", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_name": { - "name": "entity_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "old_value": { - "name": "old_value", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "new_value": { - "name": "new_value", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "ip_address": { - "name": "ip_address", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_agent": { - "name": "user_agent", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "audit_logs_organization_id_organizations_id_fk": { - "name": "audit_logs_organization_id_organizations_id_fk", - "tableFrom": "audit_logs", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "audit_logs_user_id_users_id_fk": { - "name": "audit_logs_user_id_users_id_fk", - "tableFrom": "audit_logs", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.certificates": { - "name": "certificates", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "certificates_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "training_record_id": { - "name": "training_record_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "storage_key": { - "name": "storage_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_url": { - "name": "file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "uploaded_by": { - "name": "uploaded_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "uploaded_at": { - "name": "uploaded_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "certificates_organization_id_organizations_id_fk": { - "name": "certificates_organization_id_organizations_id_fk", - "tableFrom": "certificates", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "certificates_training_record_id_training_records_id_fk": { - "name": "certificates_training_record_id_training_records_id_fk", - "tableFrom": "certificates", - "tableTo": "training_records", - "columnsFrom": [ - "training_record_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "certificates_uploaded_by_users_id_fk": { - "name": "certificates_uploaded_by_users_id_fk", - "tableFrom": "certificates", - "tableTo": "users", - "columnsFrom": [ - "uploaded_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.courses": { - "name": "courses", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "courses_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "course_code": { - "name": "course_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organizer": { - "name": "organizer", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "standard_hours": { - "name": "standard_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "certificate_validity_months": { - "name": "certificate_validity_months", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "certificate_required": { - "name": "certificate_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "training_cost": { - "name": "training_cost", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "courses_org_name_idx": { - "name": "courses_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "courses_organization_id_organizations_id_fk": { - "name": "courses_organization_id_organizations_id_fk", - "tableFrom": "courses", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.departments": { - "name": "departments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "departments_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "departments_org_code_idx": { - "name": "departments_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "departments_org_name_idx": { - "name": "departments_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "departments_organization_id_organizations_id_fk": { - "name": "departments_organization_id_organizations_id_fk", - "tableFrom": "departments", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.employee_training_targets": { - "name": "employee_training_targets", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "employee_training_targets_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "year": { - "name": "year", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "total_target_minutes": { - "name": "total_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "total_hours": { - "name": "total_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "k_target_minutes": { - "name": "k_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "k_hours": { - "name": "k_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "s_target_minutes": { - "name": "s_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "s_hours": { - "name": "s_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "a_target_minutes": { - "name": "a_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "a_hours": { - "name": "a_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "employee_training_targets_org_user_year_idx": { - "name": "employee_training_targets_org_user_year_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "year", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "employee_training_targets_org_employee_year_idx": { - "name": "employee_training_targets_org_employee_year_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "employee_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "year", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "employee_training_targets_organization_id_organizations_id_fk": { - "name": "employee_training_targets_organization_id_organizations_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "employee_training_targets_user_id_users_id_fk": { - "name": "employee_training_targets_user_id_users_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "employee_training_targets_employee_id_employees_id_fk": { - "name": "employee_training_targets_employee_id_employees_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "employee_training_targets_created_by_users_id_fk": { - "name": "employee_training_targets_created_by_users_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "employee_training_targets_updated_by_users_id_fk": { - "name": "employee_training_targets_updated_by_users_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "users", - "columnsFrom": [ - "updated_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.employees": { - "name": "employees", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "employees_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "employee_code": { - "name": "employee_code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "prefix": { - "name": "prefix", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_name_th": { - "name": "first_name_th", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "last_name_th": { - "name": "last_name_th", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_name_en": { - "name": "first_name_en", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "last_name_en": { - "name": "last_name_en", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "full_name": { - "name": "full_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "company_name": { - "name": "company_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "company": { - "name": "company", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "hired_at": { - "name": "hired_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'active'" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "employees_org_employee_code_idx": { - "name": "employees_org_employee_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "employee_code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "employees_organization_id_organizations_id_fk": { - "name": "employees_organization_id_organizations_id_fk", - "tableFrom": "employees", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "employees_department_id_departments_id_fk": { - "name": "employees_department_id_departments_id_fk", - "tableFrom": "employees", - "tableTo": "departments", - "columnsFrom": [ - "department_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "employees_position_id_positions_id_fk": { - "name": "employees_position_id_positions_id_fk", - "tableFrom": "employees", - "tableTo": "positions", - "columnsFrom": [ - "position_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.import_jobs": { - "name": "import_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "import_jobs_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "import_type": { - "name": "import_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "total_rows": { - "name": "total_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "success_rows": { - "name": "success_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "failed_rows": { - "name": "failed_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "import_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'processing'" - }, - "error_message": { - "name": "error_message", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "import_jobs_organization_id_organizations_id_fk": { - "name": "import_jobs_organization_id_organizations_id_fk", - "tableFrom": "import_jobs", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "import_jobs_created_by_users_id_fk": { - "name": "import_jobs_created_by_users_id_fk", - "tableFrom": "import_jobs", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.memberships": { - "name": "memberships", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "membership_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'owner'" - }, - "permissions": { - "name": "permissions", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "memberships_user_org_idx": { - "name": "memberships_user_org_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "memberships_user_id_users_id_fk": { - "name": "memberships_user_id_users_id_fk", - "tableFrom": "memberships", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "memberships_organization_id_organizations_id_fk": { - "name": "memberships_organization_id_organizations_id_fk", - "tableFrom": "memberships", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.notifications": { - "name": "notifications", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "notifications_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "message": { - "name": "message", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "type": { - "name": "type", - "type": "notification_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "reference_type": { - "name": "reference_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reference_id": { - "name": "reference_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_read": { - "name": "is_read", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "read_at": { - "name": "read_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "notifications_organization_id_organizations_id_fk": { - "name": "notifications_organization_id_organizations_id_fk", - "tableFrom": "notifications", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "notifications_user_id_users_id_fk": { - "name": "notifications_user_id_users_id_fk", - "tableFrom": "notifications", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.online_lessons": { - "name": "online_lessons", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "online_lessons_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "video_url": { - "name": "video_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "video_file_name": { - "name": "video_file_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "video_file_type": { - "name": "video_file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "video_file_size": { - "name": "video_file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "video_storage_key": { - "name": "video_storage_key", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "video_file_url": { - "name": "video_file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_name": { - "name": "attachment_file_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_type": { - "name": "attachment_file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_size": { - "name": "attachment_file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "attachment_storage_key": { - "name": "attachment_storage_key", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_url": { - "name": "attachment_file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "thumbnail_file_name": { - "name": "thumbnail_file_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "thumbnail_file_type": { - "name": "thumbnail_file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "thumbnail_file_size": { - "name": "thumbnail_file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "thumbnail_storage_key": { - "name": "thumbnail_storage_key", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "thumbnail_url": { - "name": "thumbnail_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "online_lesson_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'draft'" - }, - "is_published": { - "name": "is_published", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "published_at": { - "name": "published_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "online_lessons_organization_id_organizations_id_fk": { - "name": "online_lessons_organization_id_organizations_id_fk", - "tableFrom": "online_lessons", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "online_lessons_created_by_users_id_fk": { - "name": "online_lessons_created_by_users_id_fk", - "tableFrom": "online_lessons", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "online_lessons_updated_by_users_id_fk": { - "name": "online_lessons_updated_by_users_id_fk", - "tableFrom": "online_lessons", - "tableTo": "users", - "columnsFrom": [ - "updated_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.organizations": { - "name": "organizations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "slug": { - "name": "slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "image_url": { - "name": "image_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "plan": { - "name": "plan", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "organizations_slug_idx": { - "name": "organizations_slug_idx", - "columns": [ - { - "expression": "slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "organizations_created_by_users_id_fk": { - "name": "organizations_created_by_users_id_fk", - "tableFrom": "organizations", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.positions": { - "name": "positions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "positions_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "positions_org_code_idx": { - "name": "positions_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "positions_org_name_idx": { - "name": "positions_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "positions_organization_id_organizations_id_fk": { - "name": "positions_organization_id_organizations_id_fk", - "tableFrom": "positions", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.products": { - "name": "products", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "products_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "photo_url": { - "name": "photo_url", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "price": { - "name": "price", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "products_organization_id_organizations_id_fk": { - "name": "products_organization_id_organizations_id_fk", - "tableFrom": "products", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_matrices": { - "name": "training_matrices", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_matrices_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_id": { - "name": "course_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "renewal_period_months": { - "name": "renewal_period_months", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "training_matrices_organization_id_organizations_id_fk": { - "name": "training_matrices_organization_id_organizations_id_fk", - "tableFrom": "training_matrices", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_department_id_departments_id_fk": { - "name": "training_matrices_department_id_departments_id_fk", - "tableFrom": "training_matrices", - "tableTo": "departments", - "columnsFrom": [ - "department_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_position_id_positions_id_fk": { - "name": "training_matrices_position_id_positions_id_fk", - "tableFrom": "training_matrices", - "tableTo": "positions", - "columnsFrom": [ - "position_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_course_id_courses_id_fk": { - "name": "training_matrices_course_id_courses_id_fk", - "tableFrom": "training_matrices", - "tableTo": "courses", - "columnsFrom": [ - "course_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_policies": { - "name": "training_policies", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_policies_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "year": { - "name": "year", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "total_target_minutes": { - "name": "total_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "total_hours": { - "name": "total_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 30 - }, - "k_target_minutes": { - "name": "k_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "k_hours": { - "name": "k_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 12 - }, - "s_target_minutes": { - "name": "s_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "s_hours": { - "name": "s_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 12 - }, - "a_target_minutes": { - "name": "a_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "a_hours": { - "name": "a_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 6 - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "training_policies_org_year_idx": { - "name": "training_policies_org_year_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "year", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "training_policies_organization_id_organizations_id_fk": { - "name": "training_policies_organization_id_organizations_id_fk", - "tableFrom": "training_policies", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_records": { - "name": "training_records", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_records_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_id": { - "name": "course_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_name": { - "name": "course_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "training_date": { - "name": "training_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "training_type": { - "name": "training_type", - "type": "training_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "submitted_minutes": { - "name": "submitted_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "hours": { - "name": "hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "approved_minutes": { - "name": "approved_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "approved_hours": { - "name": "approved_hours", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "category": { - "name": "category", - "type": "training_category", - "typeSchema": "public", - "primaryKey": false, - "notNull": false - }, - "organizer": { - "name": "organizer", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approval_status": { - "name": "approval_status", - "type": "approval_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "reviewer_note": { - "name": "reviewer_note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reject_reason": { - "name": "reject_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "submitted_by_user_id": { - "name": "submitted_by_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_by_user_id": { - "name": "reviewed_by_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_by": { - "name": "reviewed_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_at": { - "name": "reviewed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "training_records_organization_id_organizations_id_fk": { - "name": "training_records_organization_id_organizations_id_fk", - "tableFrom": "training_records", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_records_user_id_users_id_fk": { - "name": "training_records_user_id_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_employee_id_employees_id_fk": { - "name": "training_records_employee_id_employees_id_fk", - "tableFrom": "training_records", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_course_id_courses_id_fk": { - "name": "training_records_course_id_courses_id_fk", - "tableFrom": "training_records", - "tableTo": "courses", - "columnsFrom": [ - "course_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "training_records_submitted_by_user_id_users_id_fk": { - "name": "training_records_submitted_by_user_id_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "submitted_by_user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_reviewed_by_user_id_users_id_fk": { - "name": "training_records_reviewed_by_user_id_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "reviewed_by_user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_reviewed_by_users_id_fk": { - "name": "training_records_reviewed_by_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "reviewed_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_created_by_users_id_fk": { - "name": "training_records_created_by_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.user_employee_maps": { - "name": "user_employee_maps", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "user_employee_maps_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "provider_user_id": { - "name": "provider_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'manual'" - }, - "is_primary": { - "name": "is_primary", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "linked_at": { - "name": "linked_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "user_employee_maps_org_user_employee_idx": { - "name": "user_employee_maps_org_user_employee_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "employee_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "user_employee_maps_organization_id_organizations_id_fk": { - "name": "user_employee_maps_organization_id_organizations_id_fk", - "tableFrom": "user_employee_maps", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "user_employee_maps_user_id_users_id_fk": { - "name": "user_employee_maps_user_id_users_id_fk", - "tableFrom": "user_employee_maps", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "user_employee_maps_employee_id_employees_id_fk": { - "name": "user_employee_maps_employee_id_employees_id_fk", - "tableFrom": "user_employee_maps", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "username": { - "name": "username", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "password_hash": { - "name": "password_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'credentials'" - }, - "provider_user_id": { - "name": "provider_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "image": { - "name": "image", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "system_role": { - "name": "system_role", - "type": "system_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'standard'" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "employee_code": { - "name": "employee_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "company_name": { - "name": "company_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "hired_at": { - "name": "hired_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "active_organization_id": { - "name": "active_organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "last_login_at": { - "name": "last_login_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "users_email_idx": { - "name": "users_email_idx", - "columns": [ - { - "expression": "email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_username_idx": { - "name": "users_username_idx", - "columns": [ - { - "expression": "username", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_provider_user_id_idx": { - "name": "users_provider_user_id_idx", - "columns": [ - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider_user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "users_employee_id_employees_id_fk": { - "name": "users_employee_id_employees_id_fk", - "tableFrom": "users", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": { - "public.announcement_status": { - "name": "announcement_status", - "schema": "public", - "values": [ - "draft", - "published", - "archived" - ] - }, - "public.approval_status": { - "name": "approval_status", - "schema": "public", - "values": [ - "pending", - "approved", - "rejected", - "needs_revision" - ] - }, - "public.import_status": { - "name": "import_status", - "schema": "public", - "values": [ - "processing", - "completed", - "failed" - ] - }, - "public.membership_role": { - "name": "membership_role", - "schema": "public", - "values": [ - "owner", - "admin", - "member" - ] - }, - "public.notification_type": { - "name": "notification_type", - "schema": "public", - "values": [ - "approved", - "rejected", - "announcement", - "reminder" - ] - }, - "public.online_lesson_status": { - "name": "online_lesson_status", - "schema": "public", - "values": [ - "draft", - "published", - "archived" - ] - }, - "public.system_role": { - "name": "system_role", - "schema": "public", - "values": [ - "standard", - "super_admin" - ] - }, - "public.training_category": { - "name": "training_category", - "schema": "public", - "values": [ - "K", - "S", - "A" - ] - }, - "public.training_type": { - "name": "training_type", - "schema": "public", - "values": [ - "online", - "onsite", - "internal", - "external" - ] - } - }, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/0014_snapshot.json b/drizzle/meta/0014_snapshot.json deleted file mode 100644 index 6358855..0000000 --- a/drizzle/meta/0014_snapshot.json +++ /dev/null @@ -1,3178 +0,0 @@ -{ - "id": "d162a79a-5f77-4c17-9434-cf74e29bae65", - "prevId": "ed68b3e5-6e71-4e57-97ef-877335f91046", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.announcements": { - "name": "announcements", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "announcements_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "attachment_file_name": { - "name": "attachment_file_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_type": { - "name": "attachment_file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_size": { - "name": "attachment_file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "attachment_storage_key": { - "name": "attachment_storage_key", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_url": { - "name": "attachment_file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "start_date": { - "name": "start_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "end_date": { - "name": "end_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "is_pin": { - "name": "is_pin", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "announcement_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'draft'" - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "announcements_organization_id_organizations_id_fk": { - "name": "announcements_organization_id_organizations_id_fk", - "tableFrom": "announcements", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "announcements_created_by_users_id_fk": { - "name": "announcements_created_by_users_id_fk", - "tableFrom": "announcements", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "announcements_updated_by_users_id_fk": { - "name": "announcements_updated_by_users_id_fk", - "tableFrom": "announcements", - "tableTo": "users", - "columnsFrom": [ - "updated_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.audit_logs": { - "name": "audit_logs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "audit_logs_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "module_name": { - "name": "module_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "action": { - "name": "action", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_name": { - "name": "entity_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "old_value": { - "name": "old_value", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "new_value": { - "name": "new_value", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "ip_address": { - "name": "ip_address", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_agent": { - "name": "user_agent", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "audit_logs_organization_id_organizations_id_fk": { - "name": "audit_logs_organization_id_organizations_id_fk", - "tableFrom": "audit_logs", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "audit_logs_user_id_users_id_fk": { - "name": "audit_logs_user_id_users_id_fk", - "tableFrom": "audit_logs", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.certificates": { - "name": "certificates", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "certificates_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "training_record_id": { - "name": "training_record_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "storage_key": { - "name": "storage_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_url": { - "name": "file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "uploaded_by": { - "name": "uploaded_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "uploaded_at": { - "name": "uploaded_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "certificates_organization_id_organizations_id_fk": { - "name": "certificates_organization_id_organizations_id_fk", - "tableFrom": "certificates", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "certificates_training_record_id_training_records_id_fk": { - "name": "certificates_training_record_id_training_records_id_fk", - "tableFrom": "certificates", - "tableTo": "training_records", - "columnsFrom": [ - "training_record_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "certificates_uploaded_by_users_id_fk": { - "name": "certificates_uploaded_by_users_id_fk", - "tableFrom": "certificates", - "tableTo": "users", - "columnsFrom": [ - "uploaded_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.courses": { - "name": "courses", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "courses_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "course_code": { - "name": "course_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organizer": { - "name": "organizer", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "standard_hours": { - "name": "standard_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "certificate_validity_months": { - "name": "certificate_validity_months", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "certificate_required": { - "name": "certificate_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "training_cost": { - "name": "training_cost", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "courses_org_name_idx": { - "name": "courses_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "courses_organization_id_organizations_id_fk": { - "name": "courses_organization_id_organizations_id_fk", - "tableFrom": "courses", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.departments": { - "name": "departments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "departments_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "departments_org_code_idx": { - "name": "departments_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "departments_org_name_idx": { - "name": "departments_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "departments_organization_id_organizations_id_fk": { - "name": "departments_organization_id_organizations_id_fk", - "tableFrom": "departments", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.employee_training_targets": { - "name": "employee_training_targets", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "employee_training_targets_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "year": { - "name": "year", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "total_target_minutes": { - "name": "total_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "total_hours": { - "name": "total_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "k_target_minutes": { - "name": "k_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "k_hours": { - "name": "k_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "s_target_minutes": { - "name": "s_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "s_hours": { - "name": "s_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "a_target_minutes": { - "name": "a_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "a_hours": { - "name": "a_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "employee_training_targets_org_user_year_idx": { - "name": "employee_training_targets_org_user_year_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "year", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "employee_training_targets_org_employee_year_idx": { - "name": "employee_training_targets_org_employee_year_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "employee_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "year", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "employee_training_targets_organization_id_organizations_id_fk": { - "name": "employee_training_targets_organization_id_organizations_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "employee_training_targets_user_id_users_id_fk": { - "name": "employee_training_targets_user_id_users_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "employee_training_targets_employee_id_employees_id_fk": { - "name": "employee_training_targets_employee_id_employees_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "employee_training_targets_created_by_users_id_fk": { - "name": "employee_training_targets_created_by_users_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "employee_training_targets_updated_by_users_id_fk": { - "name": "employee_training_targets_updated_by_users_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "users", - "columnsFrom": [ - "updated_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.employees": { - "name": "employees", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "employees_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "employee_code": { - "name": "employee_code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "prefix": { - "name": "prefix", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_name_th": { - "name": "first_name_th", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "last_name_th": { - "name": "last_name_th", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_name_en": { - "name": "first_name_en", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "last_name_en": { - "name": "last_name_en", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "full_name": { - "name": "full_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "company_name": { - "name": "company_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "company": { - "name": "company", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "hired_at": { - "name": "hired_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'active'" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "employees_org_employee_code_idx": { - "name": "employees_org_employee_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "employee_code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "employees_organization_id_organizations_id_fk": { - "name": "employees_organization_id_organizations_id_fk", - "tableFrom": "employees", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "employees_department_id_departments_id_fk": { - "name": "employees_department_id_departments_id_fk", - "tableFrom": "employees", - "tableTo": "departments", - "columnsFrom": [ - "department_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "employees_position_id_positions_id_fk": { - "name": "employees_position_id_positions_id_fk", - "tableFrom": "employees", - "tableTo": "positions", - "columnsFrom": [ - "position_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.import_jobs": { - "name": "import_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "import_jobs_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "import_type": { - "name": "import_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "total_rows": { - "name": "total_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "success_rows": { - "name": "success_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "failed_rows": { - "name": "failed_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "import_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'processing'" - }, - "error_message": { - "name": "error_message", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "import_jobs_organization_id_organizations_id_fk": { - "name": "import_jobs_organization_id_organizations_id_fk", - "tableFrom": "import_jobs", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "import_jobs_created_by_users_id_fk": { - "name": "import_jobs_created_by_users_id_fk", - "tableFrom": "import_jobs", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.memberships": { - "name": "memberships", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "membership_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'owner'" - }, - "permissions": { - "name": "permissions", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "memberships_user_org_idx": { - "name": "memberships_user_org_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "memberships_user_id_users_id_fk": { - "name": "memberships_user_id_users_id_fk", - "tableFrom": "memberships", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "memberships_organization_id_organizations_id_fk": { - "name": "memberships_organization_id_organizations_id_fk", - "tableFrom": "memberships", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.notifications": { - "name": "notifications", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "notifications_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "message": { - "name": "message", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "type": { - "name": "type", - "type": "notification_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "reference_type": { - "name": "reference_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reference_id": { - "name": "reference_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_read": { - "name": "is_read", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "read_at": { - "name": "read_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "notifications_organization_id_organizations_id_fk": { - "name": "notifications_organization_id_organizations_id_fk", - "tableFrom": "notifications", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "notifications_user_id_users_id_fk": { - "name": "notifications_user_id_users_id_fk", - "tableFrom": "notifications", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.online_lessons": { - "name": "online_lessons", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "online_lessons_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "video_url": { - "name": "video_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "video_file_name": { - "name": "video_file_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "video_file_type": { - "name": "video_file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "video_file_size": { - "name": "video_file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "video_storage_key": { - "name": "video_storage_key", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "video_file_url": { - "name": "video_file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_name": { - "name": "attachment_file_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_type": { - "name": "attachment_file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_size": { - "name": "attachment_file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "attachment_storage_key": { - "name": "attachment_storage_key", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_url": { - "name": "attachment_file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "thumbnail_file_name": { - "name": "thumbnail_file_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "thumbnail_file_type": { - "name": "thumbnail_file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "thumbnail_file_size": { - "name": "thumbnail_file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "thumbnail_storage_key": { - "name": "thumbnail_storage_key", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "thumbnail_url": { - "name": "thumbnail_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "online_lesson_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'draft'" - }, - "is_published": { - "name": "is_published", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "published_at": { - "name": "published_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "online_lessons_organization_id_organizations_id_fk": { - "name": "online_lessons_organization_id_organizations_id_fk", - "tableFrom": "online_lessons", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "online_lessons_created_by_users_id_fk": { - "name": "online_lessons_created_by_users_id_fk", - "tableFrom": "online_lessons", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "online_lessons_updated_by_users_id_fk": { - "name": "online_lessons_updated_by_users_id_fk", - "tableFrom": "online_lessons", - "tableTo": "users", - "columnsFrom": [ - "updated_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.organizations": { - "name": "organizations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "slug": { - "name": "slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "image_url": { - "name": "image_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "plan": { - "name": "plan", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "organizations_slug_idx": { - "name": "organizations_slug_idx", - "columns": [ - { - "expression": "slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "organizations_created_by_users_id_fk": { - "name": "organizations_created_by_users_id_fk", - "tableFrom": "organizations", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.positions": { - "name": "positions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "positions_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "positions_org_code_idx": { - "name": "positions_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "positions_org_name_idx": { - "name": "positions_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "positions_organization_id_organizations_id_fk": { - "name": "positions_organization_id_organizations_id_fk", - "tableFrom": "positions", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.products": { - "name": "products", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "products_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "photo_url": { - "name": "photo_url", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "price": { - "name": "price", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "products_organization_id_organizations_id_fk": { - "name": "products_organization_id_organizations_id_fk", - "tableFrom": "products", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_matrices": { - "name": "training_matrices", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_matrices_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_id": { - "name": "course_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "renewal_period_months": { - "name": "renewal_period_months", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "training_matrices_organization_id_organizations_id_fk": { - "name": "training_matrices_organization_id_organizations_id_fk", - "tableFrom": "training_matrices", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_department_id_departments_id_fk": { - "name": "training_matrices_department_id_departments_id_fk", - "tableFrom": "training_matrices", - "tableTo": "departments", - "columnsFrom": [ - "department_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_position_id_positions_id_fk": { - "name": "training_matrices_position_id_positions_id_fk", - "tableFrom": "training_matrices", - "tableTo": "positions", - "columnsFrom": [ - "position_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_course_id_courses_id_fk": { - "name": "training_matrices_course_id_courses_id_fk", - "tableFrom": "training_matrices", - "tableTo": "courses", - "columnsFrom": [ - "course_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_policies": { - "name": "training_policies", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_policies_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "year": { - "name": "year", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "total_target_minutes": { - "name": "total_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "total_hours": { - "name": "total_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 30 - }, - "k_target_minutes": { - "name": "k_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "k_hours": { - "name": "k_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 12 - }, - "s_target_minutes": { - "name": "s_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "s_hours": { - "name": "s_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 12 - }, - "a_target_minutes": { - "name": "a_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "a_hours": { - "name": "a_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 6 - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "training_policies_org_year_idx": { - "name": "training_policies_org_year_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "year", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "training_policies_organization_id_organizations_id_fk": { - "name": "training_policies_organization_id_organizations_id_fk", - "tableFrom": "training_policies", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_records": { - "name": "training_records", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_records_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_id": { - "name": "course_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_name": { - "name": "course_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "training_date": { - "name": "training_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "training_type": { - "name": "training_type", - "type": "training_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "submitted_minutes": { - "name": "submitted_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "hours": { - "name": "hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "approved_minutes": { - "name": "approved_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "approved_hours": { - "name": "approved_hours", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "category": { - "name": "category", - "type": "training_category", - "typeSchema": "public", - "primaryKey": false, - "notNull": false - }, - "organizer": { - "name": "organizer", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approval_status": { - "name": "approval_status", - "type": "approval_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "reviewer_note": { - "name": "reviewer_note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reject_reason": { - "name": "reject_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "submitted_by_user_id": { - "name": "submitted_by_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_by_user_id": { - "name": "reviewed_by_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_by": { - "name": "reviewed_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_at": { - "name": "reviewed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "training_records_organization_id_organizations_id_fk": { - "name": "training_records_organization_id_organizations_id_fk", - "tableFrom": "training_records", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_records_user_id_users_id_fk": { - "name": "training_records_user_id_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_employee_id_employees_id_fk": { - "name": "training_records_employee_id_employees_id_fk", - "tableFrom": "training_records", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_course_id_courses_id_fk": { - "name": "training_records_course_id_courses_id_fk", - "tableFrom": "training_records", - "tableTo": "courses", - "columnsFrom": [ - "course_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "training_records_submitted_by_user_id_users_id_fk": { - "name": "training_records_submitted_by_user_id_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "submitted_by_user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_reviewed_by_user_id_users_id_fk": { - "name": "training_records_reviewed_by_user_id_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "reviewed_by_user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_reviewed_by_users_id_fk": { - "name": "training_records_reviewed_by_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "reviewed_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_created_by_users_id_fk": { - "name": "training_records_created_by_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.user_employee_maps": { - "name": "user_employee_maps", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "user_employee_maps_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "provider_user_id": { - "name": "provider_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'manual'" - }, - "is_primary": { - "name": "is_primary", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "linked_at": { - "name": "linked_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "user_employee_maps_org_user_employee_idx": { - "name": "user_employee_maps_org_user_employee_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "employee_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "user_employee_maps_organization_id_organizations_id_fk": { - "name": "user_employee_maps_organization_id_organizations_id_fk", - "tableFrom": "user_employee_maps", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "user_employee_maps_user_id_users_id_fk": { - "name": "user_employee_maps_user_id_users_id_fk", - "tableFrom": "user_employee_maps", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "user_employee_maps_employee_id_employees_id_fk": { - "name": "user_employee_maps_employee_id_employees_id_fk", - "tableFrom": "user_employee_maps", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "username": { - "name": "username", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "password_hash": { - "name": "password_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'credentials'" - }, - "provider_user_id": { - "name": "provider_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "image": { - "name": "image", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "system_role": { - "name": "system_role", - "type": "system_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'standard'" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "employee_code": { - "name": "employee_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "company_name": { - "name": "company_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "hired_at": { - "name": "hired_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "active_organization_id": { - "name": "active_organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "last_login_at": { - "name": "last_login_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "users_email_idx": { - "name": "users_email_idx", - "columns": [ - { - "expression": "email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_username_idx": { - "name": "users_username_idx", - "columns": [ - { - "expression": "username", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_provider_user_id_idx": { - "name": "users_provider_user_id_idx", - "columns": [ - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider_user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "users_employee_id_employees_id_fk": { - "name": "users_employee_id_employees_id_fk", - "tableFrom": "users", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": { - "public.announcement_status": { - "name": "announcement_status", - "schema": "public", - "values": [ - "draft", - "published", - "archived" - ] - }, - "public.approval_status": { - "name": "approval_status", - "schema": "public", - "values": [ - "draft", - "pending", - "approved", - "rejected", - "needs_revision" - ] - }, - "public.import_status": { - "name": "import_status", - "schema": "public", - "values": [ - "processing", - "completed", - "failed" - ] - }, - "public.membership_role": { - "name": "membership_role", - "schema": "public", - "values": [ - "owner", - "admin", - "member" - ] - }, - "public.notification_type": { - "name": "notification_type", - "schema": "public", - "values": [ - "approved", - "rejected", - "announcement", - "reminder" - ] - }, - "public.online_lesson_status": { - "name": "online_lesson_status", - "schema": "public", - "values": [ - "draft", - "published", - "archived" - ] - }, - "public.system_role": { - "name": "system_role", - "schema": "public", - "values": [ - "standard", - "super_admin" - ] - }, - "public.training_category": { - "name": "training_category", - "schema": "public", - "values": [ - "K", - "S", - "A" - ] - }, - "public.training_type": { - "name": "training_type", - "schema": "public", - "values": [ - "online", - "onsite", - "internal", - "external" - ] - } - }, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/0016_snapshot.json b/drizzle/meta/0016_snapshot.json deleted file mode 100644 index 3ee1f2e..0000000 --- a/drizzle/meta/0016_snapshot.json +++ /dev/null @@ -1,3959 +0,0 @@ -{ - "id": "18410cc5-1d6f-4ae7-8e23-2b4f5a203b11", - "prevId": "d162a79a-5f77-4c17-9434-cf74e29bae65", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.announcements": { - "name": "announcements", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "announcements_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "attachment_file_name": { - "name": "attachment_file_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_type": { - "name": "attachment_file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_size": { - "name": "attachment_file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "attachment_storage_key": { - "name": "attachment_storage_key", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_url": { - "name": "attachment_file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "start_date": { - "name": "start_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "end_date": { - "name": "end_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "is_pin": { - "name": "is_pin", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "announcement_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'draft'" - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "announcements_organization_id_organizations_id_fk": { - "name": "announcements_organization_id_organizations_id_fk", - "tableFrom": "announcements", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "announcements_created_by_users_id_fk": { - "name": "announcements_created_by_users_id_fk", - "tableFrom": "announcements", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "announcements_updated_by_users_id_fk": { - "name": "announcements_updated_by_users_id_fk", - "tableFrom": "announcements", - "tableTo": "users", - "columnsFrom": [ - "updated_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.audit_logs": { - "name": "audit_logs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "audit_logs_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "module_name": { - "name": "module_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "action": { - "name": "action", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_name": { - "name": "entity_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "old_value": { - "name": "old_value", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "new_value": { - "name": "new_value", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "ip_address": { - "name": "ip_address", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_agent": { - "name": "user_agent", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "audit_logs_organization_id_organizations_id_fk": { - "name": "audit_logs_organization_id_organizations_id_fk", - "tableFrom": "audit_logs", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "audit_logs_user_id_users_id_fk": { - "name": "audit_logs_user_id_users_id_fk", - "tableFrom": "audit_logs", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.certificates": { - "name": "certificates", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "certificates_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "training_record_id": { - "name": "training_record_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "storage_key": { - "name": "storage_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_url": { - "name": "file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "uploaded_by": { - "name": "uploaded_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "uploaded_at": { - "name": "uploaded_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "certificates_organization_id_organizations_id_fk": { - "name": "certificates_organization_id_organizations_id_fk", - "tableFrom": "certificates", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "certificates_training_record_id_training_records_id_fk": { - "name": "certificates_training_record_id_training_records_id_fk", - "tableFrom": "certificates", - "tableTo": "training_records", - "columnsFrom": [ - "training_record_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "certificates_uploaded_by_users_id_fk": { - "name": "certificates_uploaded_by_users_id_fk", - "tableFrom": "certificates", - "tableTo": "users", - "columnsFrom": [ - "uploaded_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.courses": { - "name": "courses", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "courses_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "course_code": { - "name": "course_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organizer": { - "name": "organizer", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "standard_hours": { - "name": "standard_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "certificate_validity_months": { - "name": "certificate_validity_months", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "certificate_required": { - "name": "certificate_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "training_cost": { - "name": "training_cost", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "courses_org_name_idx": { - "name": "courses_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "courses_organization_id_organizations_id_fk": { - "name": "courses_organization_id_organizations_id_fk", - "tableFrom": "courses", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.departments": { - "name": "departments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "departments_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "departments_org_code_idx": { - "name": "departments_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "departments_org_name_idx": { - "name": "departments_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "departments_organization_id_organizations_id_fk": { - "name": "departments_organization_id_organizations_id_fk", - "tableFrom": "departments", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.employee_training_targets": { - "name": "employee_training_targets", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "employee_training_targets_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "year": { - "name": "year", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "total_target_minutes": { - "name": "total_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "total_hours": { - "name": "total_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "k_target_minutes": { - "name": "k_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "k_hours": { - "name": "k_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "s_target_minutes": { - "name": "s_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "s_hours": { - "name": "s_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "a_target_minutes": { - "name": "a_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "a_hours": { - "name": "a_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "employee_training_targets_org_user_year_idx": { - "name": "employee_training_targets_org_user_year_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "year", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "employee_training_targets_org_employee_year_idx": { - "name": "employee_training_targets_org_employee_year_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "employee_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "year", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "employee_training_targets_organization_id_organizations_id_fk": { - "name": "employee_training_targets_organization_id_organizations_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "employee_training_targets_user_id_users_id_fk": { - "name": "employee_training_targets_user_id_users_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "employee_training_targets_employee_id_employees_id_fk": { - "name": "employee_training_targets_employee_id_employees_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "employee_training_targets_created_by_users_id_fk": { - "name": "employee_training_targets_created_by_users_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "employee_training_targets_updated_by_users_id_fk": { - "name": "employee_training_targets_updated_by_users_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "users", - "columnsFrom": [ - "updated_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.employees": { - "name": "employees", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "employees_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "employee_code": { - "name": "employee_code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "prefix": { - "name": "prefix", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_name_th": { - "name": "first_name_th", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "last_name_th": { - "name": "last_name_th", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_name_en": { - "name": "first_name_en", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "last_name_en": { - "name": "last_name_en", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "full_name": { - "name": "full_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "company_name": { - "name": "company_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "company": { - "name": "company", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "hired_at": { - "name": "hired_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'active'" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "employees_org_employee_code_idx": { - "name": "employees_org_employee_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "employee_code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "employees_organization_id_organizations_id_fk": { - "name": "employees_organization_id_organizations_id_fk", - "tableFrom": "employees", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "employees_department_id_departments_id_fk": { - "name": "employees_department_id_departments_id_fk", - "tableFrom": "employees", - "tableTo": "departments", - "columnsFrom": [ - "department_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "employees_position_id_positions_id_fk": { - "name": "employees_position_id_positions_id_fk", - "tableFrom": "employees", - "tableTo": "positions", - "columnsFrom": [ - "position_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.import_jobs": { - "name": "import_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "import_jobs_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "import_type": { - "name": "import_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "total_rows": { - "name": "total_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "success_rows": { - "name": "success_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "failed_rows": { - "name": "failed_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "import_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'processing'" - }, - "error_message": { - "name": "error_message", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "import_jobs_organization_id_organizations_id_fk": { - "name": "import_jobs_organization_id_organizations_id_fk", - "tableFrom": "import_jobs", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "import_jobs_created_by_users_id_fk": { - "name": "import_jobs_created_by_users_id_fk", - "tableFrom": "import_jobs", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.memberships": { - "name": "memberships", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "membership_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'owner'" - }, - "permissions": { - "name": "permissions", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "memberships_user_org_idx": { - "name": "memberships_user_org_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "memberships_user_id_users_id_fk": { - "name": "memberships_user_id_users_id_fk", - "tableFrom": "memberships", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "memberships_organization_id_organizations_id_fk": { - "name": "memberships_organization_id_organizations_id_fk", - "tableFrom": "memberships", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.notifications": { - "name": "notifications", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "notifications_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "message": { - "name": "message", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "type": { - "name": "type", - "type": "notification_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "reference_type": { - "name": "reference_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reference_id": { - "name": "reference_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_read": { - "name": "is_read", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "read_at": { - "name": "read_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "notifications_organization_id_organizations_id_fk": { - "name": "notifications_organization_id_organizations_id_fk", - "tableFrom": "notifications", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "notifications_user_id_users_id_fk": { - "name": "notifications_user_id_users_id_fk", - "tableFrom": "notifications", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.online_lessons": { - "name": "online_lessons", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "online_lessons_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "video_url": { - "name": "video_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "video_file_name": { - "name": "video_file_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "video_file_type": { - "name": "video_file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "video_file_size": { - "name": "video_file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "video_storage_key": { - "name": "video_storage_key", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "video_file_url": { - "name": "video_file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_name": { - "name": "attachment_file_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_type": { - "name": "attachment_file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_size": { - "name": "attachment_file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "attachment_storage_key": { - "name": "attachment_storage_key", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_url": { - "name": "attachment_file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "thumbnail_file_name": { - "name": "thumbnail_file_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "thumbnail_file_type": { - "name": "thumbnail_file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "thumbnail_file_size": { - "name": "thumbnail_file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "thumbnail_storage_key": { - "name": "thumbnail_storage_key", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "thumbnail_url": { - "name": "thumbnail_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "online_lesson_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'draft'" - }, - "is_published": { - "name": "is_published", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "published_at": { - "name": "published_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "online_lessons_organization_id_organizations_id_fk": { - "name": "online_lessons_organization_id_organizations_id_fk", - "tableFrom": "online_lessons", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "online_lessons_created_by_users_id_fk": { - "name": "online_lessons_created_by_users_id_fk", - "tableFrom": "online_lessons", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "online_lessons_updated_by_users_id_fk": { - "name": "online_lessons_updated_by_users_id_fk", - "tableFrom": "online_lessons", - "tableTo": "users", - "columnsFrom": [ - "updated_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.organizations": { - "name": "organizations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "slug": { - "name": "slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "image_url": { - "name": "image_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "plan": { - "name": "plan", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "organizations_slug_idx": { - "name": "organizations_slug_idx", - "columns": [ - { - "expression": "slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "organizations_created_by_users_id_fk": { - "name": "organizations_created_by_users_id_fk", - "tableFrom": "organizations", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.permission_audit_logs": { - "name": "permission_audit_logs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "permission_audit_logs_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "actor_user_id": { - "name": "actor_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "target_user_id": { - "name": "target_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "template_id": { - "name": "template_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "assignment_id": { - "name": "assignment_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "override_id": { - "name": "override_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "action": { - "name": "action", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "reason": { - "name": "reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "before": { - "name": "before", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "after": { - "name": "after", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "permission_audit_logs_organization_id_organizations_id_fk": { - "name": "permission_audit_logs_organization_id_organizations_id_fk", - "tableFrom": "permission_audit_logs", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "permission_audit_logs_actor_user_id_users_id_fk": { - "name": "permission_audit_logs_actor_user_id_users_id_fk", - "tableFrom": "permission_audit_logs", - "tableTo": "users", - "columnsFrom": [ - "actor_user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "permission_audit_logs_target_user_id_users_id_fk": { - "name": "permission_audit_logs_target_user_id_users_id_fk", - "tableFrom": "permission_audit_logs", - "tableTo": "users", - "columnsFrom": [ - "target_user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "permission_audit_logs_template_id_permission_templates_id_fk": { - "name": "permission_audit_logs_template_id_permission_templates_id_fk", - "tableFrom": "permission_audit_logs", - "tableTo": "permission_templates", - "columnsFrom": [ - "template_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "permission_audit_logs_assignment_id_user_permission_template_assignments_id_fk": { - "name": "permission_audit_logs_assignment_id_user_permission_template_assignments_id_fk", - "tableFrom": "permission_audit_logs", - "tableTo": "user_permission_template_assignments", - "columnsFrom": [ - "assignment_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "permission_audit_logs_override_id_user_permission_overrides_id_fk": { - "name": "permission_audit_logs_override_id_user_permission_overrides_id_fk", - "tableFrom": "permission_audit_logs", - "tableTo": "user_permission_overrides", - "columnsFrom": [ - "override_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.permission_template_permissions": { - "name": "permission_template_permissions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "permission_template_permissions_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "template_id": { - "name": "template_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "permission": { - "name": "permission", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "permission_template_permissions_template_permission_idx": { - "name": "permission_template_permissions_template_permission_idx", - "columns": [ - { - "expression": "template_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "permission", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "permission_template_permissions_template_id_permission_templates_id_fk": { - "name": "permission_template_permissions_template_id_permission_templates_id_fk", - "tableFrom": "permission_template_permissions", - "tableTo": "permission_templates", - "columnsFrom": [ - "template_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.permission_templates": { - "name": "permission_templates", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "permission_templates_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_system": { - "name": "is_system", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "permission_templates_org_code_idx": { - "name": "permission_templates_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "permission_templates_org_name_idx": { - "name": "permission_templates_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "permission_templates_organization_id_organizations_id_fk": { - "name": "permission_templates_organization_id_organizations_id_fk", - "tableFrom": "permission_templates", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "permission_templates_created_by_users_id_fk": { - "name": "permission_templates_created_by_users_id_fk", - "tableFrom": "permission_templates", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "permission_templates_updated_by_users_id_fk": { - "name": "permission_templates_updated_by_users_id_fk", - "tableFrom": "permission_templates", - "tableTo": "users", - "columnsFrom": [ - "updated_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.positions": { - "name": "positions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "positions_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "positions_org_code_idx": { - "name": "positions_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "positions_org_name_idx": { - "name": "positions_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "positions_organization_id_organizations_id_fk": { - "name": "positions_organization_id_organizations_id_fk", - "tableFrom": "positions", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.products": { - "name": "products", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "products_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "photo_url": { - "name": "photo_url", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "price": { - "name": "price", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "products_organization_id_organizations_id_fk": { - "name": "products_organization_id_organizations_id_fk", - "tableFrom": "products", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_matrices": { - "name": "training_matrices", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_matrices_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_id": { - "name": "course_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "renewal_period_months": { - "name": "renewal_period_months", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "training_matrices_organization_id_organizations_id_fk": { - "name": "training_matrices_organization_id_organizations_id_fk", - "tableFrom": "training_matrices", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_department_id_departments_id_fk": { - "name": "training_matrices_department_id_departments_id_fk", - "tableFrom": "training_matrices", - "tableTo": "departments", - "columnsFrom": [ - "department_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_position_id_positions_id_fk": { - "name": "training_matrices_position_id_positions_id_fk", - "tableFrom": "training_matrices", - "tableTo": "positions", - "columnsFrom": [ - "position_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_course_id_courses_id_fk": { - "name": "training_matrices_course_id_courses_id_fk", - "tableFrom": "training_matrices", - "tableTo": "courses", - "columnsFrom": [ - "course_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_policies": { - "name": "training_policies", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_policies_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "year": { - "name": "year", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "total_target_minutes": { - "name": "total_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "total_hours": { - "name": "total_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 30 - }, - "k_target_minutes": { - "name": "k_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "k_hours": { - "name": "k_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 12 - }, - "s_target_minutes": { - "name": "s_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "s_hours": { - "name": "s_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 12 - }, - "a_target_minutes": { - "name": "a_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "a_hours": { - "name": "a_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 6 - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "training_policies_org_year_idx": { - "name": "training_policies_org_year_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "year", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "training_policies_organization_id_organizations_id_fk": { - "name": "training_policies_organization_id_organizations_id_fk", - "tableFrom": "training_policies", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_records": { - "name": "training_records", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_records_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_id": { - "name": "course_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_name": { - "name": "course_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "training_date": { - "name": "training_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "training_type": { - "name": "training_type", - "type": "training_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "submitted_minutes": { - "name": "submitted_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "hours": { - "name": "hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "approved_minutes": { - "name": "approved_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "approved_hours": { - "name": "approved_hours", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "category": { - "name": "category", - "type": "training_category", - "typeSchema": "public", - "primaryKey": false, - "notNull": false - }, - "organizer": { - "name": "organizer", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approval_status": { - "name": "approval_status", - "type": "approval_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "reviewer_note": { - "name": "reviewer_note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reject_reason": { - "name": "reject_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "submitted_by_user_id": { - "name": "submitted_by_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_by_user_id": { - "name": "reviewed_by_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_by": { - "name": "reviewed_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_at": { - "name": "reviewed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "training_records_organization_id_organizations_id_fk": { - "name": "training_records_organization_id_organizations_id_fk", - "tableFrom": "training_records", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_records_user_id_users_id_fk": { - "name": "training_records_user_id_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_employee_id_employees_id_fk": { - "name": "training_records_employee_id_employees_id_fk", - "tableFrom": "training_records", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_course_id_courses_id_fk": { - "name": "training_records_course_id_courses_id_fk", - "tableFrom": "training_records", - "tableTo": "courses", - "columnsFrom": [ - "course_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "training_records_submitted_by_user_id_users_id_fk": { - "name": "training_records_submitted_by_user_id_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "submitted_by_user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_reviewed_by_user_id_users_id_fk": { - "name": "training_records_reviewed_by_user_id_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "reviewed_by_user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_reviewed_by_users_id_fk": { - "name": "training_records_reviewed_by_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "reviewed_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_created_by_users_id_fk": { - "name": "training_records_created_by_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.user_employee_maps": { - "name": "user_employee_maps", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "user_employee_maps_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "provider_user_id": { - "name": "provider_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'manual'" - }, - "is_primary": { - "name": "is_primary", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "linked_at": { - "name": "linked_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "user_employee_maps_org_user_employee_idx": { - "name": "user_employee_maps_org_user_employee_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "employee_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "user_employee_maps_organization_id_organizations_id_fk": { - "name": "user_employee_maps_organization_id_organizations_id_fk", - "tableFrom": "user_employee_maps", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "user_employee_maps_user_id_users_id_fk": { - "name": "user_employee_maps_user_id_users_id_fk", - "tableFrom": "user_employee_maps", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "user_employee_maps_employee_id_employees_id_fk": { - "name": "user_employee_maps_employee_id_employees_id_fk", - "tableFrom": "user_employee_maps", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.user_permission_overrides": { - "name": "user_permission_overrides", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "user_permission_overrides_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "permission": { - "name": "permission", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "effect": { - "name": "effect", - "type": "permission_override_effect", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "reason": { - "name": "reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "revoked_by": { - "name": "revoked_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "revoked_at": { - "name": "revoked_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "user_permission_overrides_organization_id_organizations_id_fk": { - "name": "user_permission_overrides_organization_id_organizations_id_fk", - "tableFrom": "user_permission_overrides", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "user_permission_overrides_user_id_users_id_fk": { - "name": "user_permission_overrides_user_id_users_id_fk", - "tableFrom": "user_permission_overrides", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "user_permission_overrides_created_by_users_id_fk": { - "name": "user_permission_overrides_created_by_users_id_fk", - "tableFrom": "user_permission_overrides", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "user_permission_overrides_revoked_by_users_id_fk": { - "name": "user_permission_overrides_revoked_by_users_id_fk", - "tableFrom": "user_permission_overrides", - "tableTo": "users", - "columnsFrom": [ - "revoked_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.user_permission_template_assignments": { - "name": "user_permission_template_assignments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "user_permission_template_assignments_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "template_id": { - "name": "template_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "assigned_by": { - "name": "assigned_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assigned_at": { - "name": "assigned_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "user_permission_template_assignments_org_user_template_idx": { - "name": "user_permission_template_assignments_org_user_template_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "template_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "user_permission_template_assignments_organization_id_organizations_id_fk": { - "name": "user_permission_template_assignments_organization_id_organizations_id_fk", - "tableFrom": "user_permission_template_assignments", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "user_permission_template_assignments_user_id_users_id_fk": { - "name": "user_permission_template_assignments_user_id_users_id_fk", - "tableFrom": "user_permission_template_assignments", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "user_permission_template_assignments_template_id_permission_templates_id_fk": { - "name": "user_permission_template_assignments_template_id_permission_templates_id_fk", - "tableFrom": "user_permission_template_assignments", - "tableTo": "permission_templates", - "columnsFrom": [ - "template_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "user_permission_template_assignments_assigned_by_users_id_fk": { - "name": "user_permission_template_assignments_assigned_by_users_id_fk", - "tableFrom": "user_permission_template_assignments", - "tableTo": "users", - "columnsFrom": [ - "assigned_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "username": { - "name": "username", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "password_hash": { - "name": "password_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'credentials'" - }, - "provider_user_id": { - "name": "provider_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "image": { - "name": "image", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "system_role": { - "name": "system_role", - "type": "system_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'standard'" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "employee_code": { - "name": "employee_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "company_name": { - "name": "company_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "hired_at": { - "name": "hired_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "active_organization_id": { - "name": "active_organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "last_login_at": { - "name": "last_login_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "users_email_idx": { - "name": "users_email_idx", - "columns": [ - { - "expression": "email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_username_idx": { - "name": "users_username_idx", - "columns": [ - { - "expression": "username", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_provider_user_id_idx": { - "name": "users_provider_user_id_idx", - "columns": [ - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider_user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "users_employee_id_employees_id_fk": { - "name": "users_employee_id_employees_id_fk", - "tableFrom": "users", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": { - "public.announcement_status": { - "name": "announcement_status", - "schema": "public", - "values": [ - "draft", - "published", - "archived" - ] - }, - "public.approval_status": { - "name": "approval_status", - "schema": "public", - "values": [ - "draft", - "pending", - "approved", - "rejected", - "needs_revision" - ] - }, - "public.import_status": { - "name": "import_status", - "schema": "public", - "values": [ - "processing", - "completed", - "failed" - ] - }, - "public.membership_role": { - "name": "membership_role", - "schema": "public", - "values": [ - "owner", - "admin", - "member" - ] - }, - "public.notification_type": { - "name": "notification_type", - "schema": "public", - "values": [ - "approved", - "rejected", - "announcement", - "reminder" - ] - }, - "public.online_lesson_status": { - "name": "online_lesson_status", - "schema": "public", - "values": [ - "draft", - "published", - "archived" - ] - }, - "public.permission_override_effect": { - "name": "permission_override_effect", - "schema": "public", - "values": [ - "allow", - "deny" - ] - }, - "public.system_role": { - "name": "system_role", - "schema": "public", - "values": [ - "standard", - "super_admin" - ] - }, - "public.training_category": { - "name": "training_category", - "schema": "public", - "values": [ - "K", - "S", - "A" - ] - }, - "public.training_type": { - "name": "training_type", - "schema": "public", - "values": [ - "online", - "onsite", - "internal", - "external" - ] - } - }, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/0017_snapshot.json b/drizzle/meta/0017_snapshot.json deleted file mode 100644 index 6370210..0000000 --- a/drizzle/meta/0017_snapshot.json +++ /dev/null @@ -1,3991 +0,0 @@ -{ - "id": "c05966c1-9460-44f6-ae39-2b0b7238b3a4", - "prevId": "18410cc5-1d6f-4ae7-8e23-2b4f5a203b11", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.announcements": { - "name": "announcements", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "announcements_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "attachment_file_name": { - "name": "attachment_file_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_type": { - "name": "attachment_file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_size": { - "name": "attachment_file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "attachment_storage_key": { - "name": "attachment_storage_key", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_url": { - "name": "attachment_file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "start_date": { - "name": "start_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "end_date": { - "name": "end_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "is_pin": { - "name": "is_pin", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "announcement_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'draft'" - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "announcements_organization_id_organizations_id_fk": { - "name": "announcements_organization_id_organizations_id_fk", - "tableFrom": "announcements", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "announcements_created_by_users_id_fk": { - "name": "announcements_created_by_users_id_fk", - "tableFrom": "announcements", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "announcements_updated_by_users_id_fk": { - "name": "announcements_updated_by_users_id_fk", - "tableFrom": "announcements", - "tableTo": "users", - "columnsFrom": [ - "updated_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.audit_logs": { - "name": "audit_logs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "audit_logs_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "module_name": { - "name": "module_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "action": { - "name": "action", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_name": { - "name": "entity_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "old_value": { - "name": "old_value", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "new_value": { - "name": "new_value", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "ip_address": { - "name": "ip_address", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_agent": { - "name": "user_agent", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "audit_logs_organization_id_organizations_id_fk": { - "name": "audit_logs_organization_id_organizations_id_fk", - "tableFrom": "audit_logs", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "audit_logs_user_id_users_id_fk": { - "name": "audit_logs_user_id_users_id_fk", - "tableFrom": "audit_logs", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.certificates": { - "name": "certificates", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "certificates_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "training_record_id": { - "name": "training_record_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "storage_key": { - "name": "storage_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_url": { - "name": "file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "uploaded_by": { - "name": "uploaded_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "uploaded_at": { - "name": "uploaded_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "certificates_organization_id_organizations_id_fk": { - "name": "certificates_organization_id_organizations_id_fk", - "tableFrom": "certificates", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "certificates_training_record_id_training_records_id_fk": { - "name": "certificates_training_record_id_training_records_id_fk", - "tableFrom": "certificates", - "tableTo": "training_records", - "columnsFrom": [ - "training_record_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "certificates_uploaded_by_users_id_fk": { - "name": "certificates_uploaded_by_users_id_fk", - "tableFrom": "certificates", - "tableTo": "users", - "columnsFrom": [ - "uploaded_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.courses": { - "name": "courses", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "courses_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "course_code": { - "name": "course_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organizer": { - "name": "organizer", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "standard_hours": { - "name": "standard_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "certificate_validity_months": { - "name": "certificate_validity_months", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "certificate_required": { - "name": "certificate_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "training_cost": { - "name": "training_cost", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "courses_org_name_idx": { - "name": "courses_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "courses_organization_id_organizations_id_fk": { - "name": "courses_organization_id_organizations_id_fk", - "tableFrom": "courses", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.departments": { - "name": "departments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "departments_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "departments_org_code_idx": { - "name": "departments_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "departments_org_name_idx": { - "name": "departments_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "departments_organization_id_organizations_id_fk": { - "name": "departments_organization_id_organizations_id_fk", - "tableFrom": "departments", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.employee_training_targets": { - "name": "employee_training_targets", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "employee_training_targets_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "year": { - "name": "year", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "total_target_minutes": { - "name": "total_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "total_hours": { - "name": "total_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "k_target_minutes": { - "name": "k_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "k_hours": { - "name": "k_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "s_target_minutes": { - "name": "s_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "s_hours": { - "name": "s_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "a_target_minutes": { - "name": "a_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "a_hours": { - "name": "a_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "employee_training_targets_org_user_year_idx": { - "name": "employee_training_targets_org_user_year_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "year", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "employee_training_targets_org_employee_year_idx": { - "name": "employee_training_targets_org_employee_year_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "employee_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "year", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "employee_training_targets_organization_id_organizations_id_fk": { - "name": "employee_training_targets_organization_id_organizations_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "employee_training_targets_user_id_users_id_fk": { - "name": "employee_training_targets_user_id_users_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "employee_training_targets_employee_id_employees_id_fk": { - "name": "employee_training_targets_employee_id_employees_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "employee_training_targets_created_by_users_id_fk": { - "name": "employee_training_targets_created_by_users_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "employee_training_targets_updated_by_users_id_fk": { - "name": "employee_training_targets_updated_by_users_id_fk", - "tableFrom": "employee_training_targets", - "tableTo": "users", - "columnsFrom": [ - "updated_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.employees": { - "name": "employees", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "employees_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "employee_code": { - "name": "employee_code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "prefix": { - "name": "prefix", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_name_th": { - "name": "first_name_th", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "last_name_th": { - "name": "last_name_th", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_name_en": { - "name": "first_name_en", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "last_name_en": { - "name": "last_name_en", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "full_name": { - "name": "full_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "company_name": { - "name": "company_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "company": { - "name": "company", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "hired_at": { - "name": "hired_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'active'" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "employees_org_employee_code_idx": { - "name": "employees_org_employee_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "employee_code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "employees_organization_id_organizations_id_fk": { - "name": "employees_organization_id_organizations_id_fk", - "tableFrom": "employees", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "employees_department_id_departments_id_fk": { - "name": "employees_department_id_departments_id_fk", - "tableFrom": "employees", - "tableTo": "departments", - "columnsFrom": [ - "department_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "employees_position_id_positions_id_fk": { - "name": "employees_position_id_positions_id_fk", - "tableFrom": "employees", - "tableTo": "positions", - "columnsFrom": [ - "position_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.import_jobs": { - "name": "import_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "import_jobs_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "import_type": { - "name": "import_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "total_rows": { - "name": "total_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "success_rows": { - "name": "success_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "failed_rows": { - "name": "failed_rows", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "import_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'processing'" - }, - "error_message": { - "name": "error_message", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "import_jobs_organization_id_organizations_id_fk": { - "name": "import_jobs_organization_id_organizations_id_fk", - "tableFrom": "import_jobs", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "import_jobs_created_by_users_id_fk": { - "name": "import_jobs_created_by_users_id_fk", - "tableFrom": "import_jobs", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.memberships": { - "name": "memberships", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "membership_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'owner'" - }, - "permissions": { - "name": "permissions", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "memberships_user_org_idx": { - "name": "memberships_user_org_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "memberships_user_id_users_id_fk": { - "name": "memberships_user_id_users_id_fk", - "tableFrom": "memberships", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "memberships_organization_id_organizations_id_fk": { - "name": "memberships_organization_id_organizations_id_fk", - "tableFrom": "memberships", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.notifications": { - "name": "notifications", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "notifications_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "message": { - "name": "message", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "type": { - "name": "type", - "type": "notification_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "reference_type": { - "name": "reference_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reference_id": { - "name": "reference_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_read": { - "name": "is_read", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "read_at": { - "name": "read_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "notifications_organization_id_organizations_id_fk": { - "name": "notifications_organization_id_organizations_id_fk", - "tableFrom": "notifications", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "notifications_user_id_users_id_fk": { - "name": "notifications_user_id_users_id_fk", - "tableFrom": "notifications", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.online_lessons": { - "name": "online_lessons", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "online_lessons_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "video_url": { - "name": "video_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "video_file_name": { - "name": "video_file_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "video_file_type": { - "name": "video_file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "video_file_size": { - "name": "video_file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "video_storage_key": { - "name": "video_storage_key", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "video_file_url": { - "name": "video_file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_name": { - "name": "attachment_file_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_type": { - "name": "attachment_file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_size": { - "name": "attachment_file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "attachment_storage_key": { - "name": "attachment_storage_key", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachment_file_url": { - "name": "attachment_file_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "thumbnail_file_name": { - "name": "thumbnail_file_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "thumbnail_file_type": { - "name": "thumbnail_file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "thumbnail_file_size": { - "name": "thumbnail_file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "thumbnail_storage_key": { - "name": "thumbnail_storage_key", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "thumbnail_url": { - "name": "thumbnail_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "online_lesson_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'draft'" - }, - "is_published": { - "name": "is_published", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "published_at": { - "name": "published_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "online_lessons_organization_id_organizations_id_fk": { - "name": "online_lessons_organization_id_organizations_id_fk", - "tableFrom": "online_lessons", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "online_lessons_created_by_users_id_fk": { - "name": "online_lessons_created_by_users_id_fk", - "tableFrom": "online_lessons", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "online_lessons_updated_by_users_id_fk": { - "name": "online_lessons_updated_by_users_id_fk", - "tableFrom": "online_lessons", - "tableTo": "users", - "columnsFrom": [ - "updated_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.organizations": { - "name": "organizations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "slug": { - "name": "slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "image_url": { - "name": "image_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "plan": { - "name": "plan", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deleted_by": { - "name": "deleted_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "organizations_slug_idx": { - "name": "organizations_slug_idx", - "columns": [ - { - "expression": "slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "organizations_deleted_by_users_id_fk": { - "name": "organizations_deleted_by_users_id_fk", - "tableFrom": "organizations", - "tableTo": "users", - "columnsFrom": [ - "deleted_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "organizations_created_by_users_id_fk": { - "name": "organizations_created_by_users_id_fk", - "tableFrom": "organizations", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.permission_audit_logs": { - "name": "permission_audit_logs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "permission_audit_logs_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "actor_user_id": { - "name": "actor_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "target_user_id": { - "name": "target_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "template_id": { - "name": "template_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "assignment_id": { - "name": "assignment_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "override_id": { - "name": "override_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "action": { - "name": "action", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "reason": { - "name": "reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "before": { - "name": "before", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "after": { - "name": "after", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "permission_audit_logs_organization_id_organizations_id_fk": { - "name": "permission_audit_logs_organization_id_organizations_id_fk", - "tableFrom": "permission_audit_logs", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "permission_audit_logs_actor_user_id_users_id_fk": { - "name": "permission_audit_logs_actor_user_id_users_id_fk", - "tableFrom": "permission_audit_logs", - "tableTo": "users", - "columnsFrom": [ - "actor_user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "permission_audit_logs_target_user_id_users_id_fk": { - "name": "permission_audit_logs_target_user_id_users_id_fk", - "tableFrom": "permission_audit_logs", - "tableTo": "users", - "columnsFrom": [ - "target_user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "permission_audit_logs_template_id_permission_templates_id_fk": { - "name": "permission_audit_logs_template_id_permission_templates_id_fk", - "tableFrom": "permission_audit_logs", - "tableTo": "permission_templates", - "columnsFrom": [ - "template_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "permission_audit_logs_assignment_id_user_permission_template_assignments_id_fk": { - "name": "permission_audit_logs_assignment_id_user_permission_template_assignments_id_fk", - "tableFrom": "permission_audit_logs", - "tableTo": "user_permission_template_assignments", - "columnsFrom": [ - "assignment_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "permission_audit_logs_override_id_user_permission_overrides_id_fk": { - "name": "permission_audit_logs_override_id_user_permission_overrides_id_fk", - "tableFrom": "permission_audit_logs", - "tableTo": "user_permission_overrides", - "columnsFrom": [ - "override_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.permission_template_permissions": { - "name": "permission_template_permissions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "permission_template_permissions_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "template_id": { - "name": "template_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "permission": { - "name": "permission", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "permission_template_permissions_template_permission_idx": { - "name": "permission_template_permissions_template_permission_idx", - "columns": [ - { - "expression": "template_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "permission", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "permission_template_permissions_template_id_permission_templates_id_fk": { - "name": "permission_template_permissions_template_id_permission_templates_id_fk", - "tableFrom": "permission_template_permissions", - "tableTo": "permission_templates", - "columnsFrom": [ - "template_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.permission_templates": { - "name": "permission_templates", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "permission_templates_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_system": { - "name": "is_system", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "permission_templates_org_code_idx": { - "name": "permission_templates_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "permission_templates_org_name_idx": { - "name": "permission_templates_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "permission_templates_organization_id_organizations_id_fk": { - "name": "permission_templates_organization_id_organizations_id_fk", - "tableFrom": "permission_templates", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "permission_templates_created_by_users_id_fk": { - "name": "permission_templates_created_by_users_id_fk", - "tableFrom": "permission_templates", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "permission_templates_updated_by_users_id_fk": { - "name": "permission_templates_updated_by_users_id_fk", - "tableFrom": "permission_templates", - "tableTo": "users", - "columnsFrom": [ - "updated_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.positions": { - "name": "positions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "positions_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pending_master_review": { - "name": "pending_master_review", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "positions_org_code_idx": { - "name": "positions_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "positions_org_name_idx": { - "name": "positions_org_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "positions_organization_id_organizations_id_fk": { - "name": "positions_organization_id_organizations_id_fk", - "tableFrom": "positions", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.products": { - "name": "products", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "products_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "photo_url": { - "name": "photo_url", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "price": { - "name": "price", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "products_organization_id_organizations_id_fk": { - "name": "products_organization_id_organizations_id_fk", - "tableFrom": "products", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_matrices": { - "name": "training_matrices", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_matrices_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_id": { - "name": "course_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "renewal_period_months": { - "name": "renewal_period_months", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "training_matrices_organization_id_organizations_id_fk": { - "name": "training_matrices_organization_id_organizations_id_fk", - "tableFrom": "training_matrices", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_department_id_departments_id_fk": { - "name": "training_matrices_department_id_departments_id_fk", - "tableFrom": "training_matrices", - "tableTo": "departments", - "columnsFrom": [ - "department_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_position_id_positions_id_fk": { - "name": "training_matrices_position_id_positions_id_fk", - "tableFrom": "training_matrices", - "tableTo": "positions", - "columnsFrom": [ - "position_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_matrices_course_id_courses_id_fk": { - "name": "training_matrices_course_id_courses_id_fk", - "tableFrom": "training_matrices", - "tableTo": "courses", - "columnsFrom": [ - "course_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_policies": { - "name": "training_policies", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_policies_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "year": { - "name": "year", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "total_target_minutes": { - "name": "total_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "total_hours": { - "name": "total_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 30 - }, - "k_target_minutes": { - "name": "k_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "k_hours": { - "name": "k_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 12 - }, - "s_target_minutes": { - "name": "s_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "s_hours": { - "name": "s_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 12 - }, - "a_target_minutes": { - "name": "a_target_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "a_hours": { - "name": "a_hours", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 6 - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "training_policies_org_year_idx": { - "name": "training_policies_org_year_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "year", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "training_policies_organization_id_organizations_id_fk": { - "name": "training_policies_organization_id_organizations_id_fk", - "tableFrom": "training_policies", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.training_records": { - "name": "training_records", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "training_records_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_id": { - "name": "course_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "course_name": { - "name": "course_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "training_date": { - "name": "training_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "training_type": { - "name": "training_type", - "type": "training_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "submitted_minutes": { - "name": "submitted_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "hours": { - "name": "hours", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "approved_minutes": { - "name": "approved_minutes", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "approved_hours": { - "name": "approved_hours", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "category": { - "name": "category", - "type": "training_category", - "typeSchema": "public", - "primaryKey": false, - "notNull": false - }, - "organizer": { - "name": "organizer", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approval_status": { - "name": "approval_status", - "type": "approval_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "reviewer_note": { - "name": "reviewer_note", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reject_reason": { - "name": "reject_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "submitted_by_user_id": { - "name": "submitted_by_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_by_user_id": { - "name": "reviewed_by_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_by": { - "name": "reviewed_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reviewed_at": { - "name": "reviewed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "training_records_organization_id_organizations_id_fk": { - "name": "training_records_organization_id_organizations_id_fk", - "tableFrom": "training_records", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "training_records_user_id_users_id_fk": { - "name": "training_records_user_id_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_employee_id_employees_id_fk": { - "name": "training_records_employee_id_employees_id_fk", - "tableFrom": "training_records", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_course_id_courses_id_fk": { - "name": "training_records_course_id_courses_id_fk", - "tableFrom": "training_records", - "tableTo": "courses", - "columnsFrom": [ - "course_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "training_records_submitted_by_user_id_users_id_fk": { - "name": "training_records_submitted_by_user_id_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "submitted_by_user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_reviewed_by_user_id_users_id_fk": { - "name": "training_records_reviewed_by_user_id_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "reviewed_by_user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_reviewed_by_users_id_fk": { - "name": "training_records_reviewed_by_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "reviewed_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "training_records_created_by_users_id_fk": { - "name": "training_records_created_by_users_id_fk", - "tableFrom": "training_records", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.user_employee_maps": { - "name": "user_employee_maps", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "user_employee_maps_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "provider_user_id": { - "name": "provider_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'manual'" - }, - "is_primary": { - "name": "is_primary", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "linked_at": { - "name": "linked_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "user_employee_maps_org_user_employee_idx": { - "name": "user_employee_maps_org_user_employee_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "employee_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "user_employee_maps_organization_id_organizations_id_fk": { - "name": "user_employee_maps_organization_id_organizations_id_fk", - "tableFrom": "user_employee_maps", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "user_employee_maps_user_id_users_id_fk": { - "name": "user_employee_maps_user_id_users_id_fk", - "tableFrom": "user_employee_maps", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "user_employee_maps_employee_id_employees_id_fk": { - "name": "user_employee_maps_employee_id_employees_id_fk", - "tableFrom": "user_employee_maps", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.user_permission_overrides": { - "name": "user_permission_overrides", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "user_permission_overrides_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "permission": { - "name": "permission", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "effect": { - "name": "effect", - "type": "permission_override_effect", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "reason": { - "name": "reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "revoked_by": { - "name": "revoked_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "revoked_at": { - "name": "revoked_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "user_permission_overrides_organization_id_organizations_id_fk": { - "name": "user_permission_overrides_organization_id_organizations_id_fk", - "tableFrom": "user_permission_overrides", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "user_permission_overrides_user_id_users_id_fk": { - "name": "user_permission_overrides_user_id_users_id_fk", - "tableFrom": "user_permission_overrides", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "user_permission_overrides_created_by_users_id_fk": { - "name": "user_permission_overrides_created_by_users_id_fk", - "tableFrom": "user_permission_overrides", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "user_permission_overrides_revoked_by_users_id_fk": { - "name": "user_permission_overrides_revoked_by_users_id_fk", - "tableFrom": "user_permission_overrides", - "tableTo": "users", - "columnsFrom": [ - "revoked_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.user_permission_template_assignments": { - "name": "user_permission_template_assignments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "user_permission_template_assignments_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "template_id": { - "name": "template_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "assigned_by": { - "name": "assigned_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assigned_at": { - "name": "assigned_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "user_permission_template_assignments_org_user_template_idx": { - "name": "user_permission_template_assignments_org_user_template_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "template_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "user_permission_template_assignments_organization_id_organizations_id_fk": { - "name": "user_permission_template_assignments_organization_id_organizations_id_fk", - "tableFrom": "user_permission_template_assignments", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "user_permission_template_assignments_user_id_users_id_fk": { - "name": "user_permission_template_assignments_user_id_users_id_fk", - "tableFrom": "user_permission_template_assignments", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "user_permission_template_assignments_template_id_permission_templates_id_fk": { - "name": "user_permission_template_assignments_template_id_permission_templates_id_fk", - "tableFrom": "user_permission_template_assignments", - "tableTo": "permission_templates", - "columnsFrom": [ - "template_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "user_permission_template_assignments_assigned_by_users_id_fk": { - "name": "user_permission_template_assignments_assigned_by_users_id_fk", - "tableFrom": "user_permission_template_assignments", - "tableTo": "users", - "columnsFrom": [ - "assigned_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "username": { - "name": "username", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "password_hash": { - "name": "password_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'credentials'" - }, - "provider_user_id": { - "name": "provider_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "image": { - "name": "image", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "system_role": { - "name": "system_role", - "type": "system_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'standard'" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "employee_code": { - "name": "employee_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "employee_id": { - "name": "employee_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "department_id": { - "name": "department_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "position_id": { - "name": "position_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "company_name": { - "name": "company_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "hired_at": { - "name": "hired_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "active_organization_id": { - "name": "active_organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "last_login_at": { - "name": "last_login_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "users_email_idx": { - "name": "users_email_idx", - "columns": [ - { - "expression": "email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_username_idx": { - "name": "users_username_idx", - "columns": [ - { - "expression": "username", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_provider_user_id_idx": { - "name": "users_provider_user_id_idx", - "columns": [ - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider_user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "users_employee_id_employees_id_fk": { - "name": "users_employee_id_employees_id_fk", - "tableFrom": "users", - "tableTo": "employees", - "columnsFrom": [ - "employee_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": { - "public.announcement_status": { - "name": "announcement_status", - "schema": "public", - "values": [ - "draft", - "published", - "archived" - ] - }, - "public.approval_status": { - "name": "approval_status", - "schema": "public", - "values": [ - "draft", - "pending", - "approved", - "rejected", - "needs_revision" - ] - }, - "public.import_status": { - "name": "import_status", - "schema": "public", - "values": [ - "processing", - "completed", - "failed" - ] - }, - "public.membership_role": { - "name": "membership_role", - "schema": "public", - "values": [ - "owner", - "admin", - "member" - ] - }, - "public.notification_type": { - "name": "notification_type", - "schema": "public", - "values": [ - "approved", - "rejected", - "announcement", - "reminder" - ] - }, - "public.online_lesson_status": { - "name": "online_lesson_status", - "schema": "public", - "values": [ - "draft", - "published", - "archived" - ] - }, - "public.permission_override_effect": { - "name": "permission_override_effect", - "schema": "public", - "values": [ - "allow", - "deny" - ] - }, - "public.system_role": { - "name": "system_role", - "schema": "public", - "values": [ - "standard", - "super_admin" - ] - }, - "public.training_category": { - "name": "training_category", - "schema": "public", - "values": [ - "K", - "S", - "A" - ] - }, - "public.training_type": { - "name": "training_type", - "schema": "public", - "values": [ - "online", - "onsite", - "internal", - "external" - ] - } - }, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index 5607d16..5b15592 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -5,142 +5,9 @@ { "idx": 0, "version": "7", - "when": 1780621204596, - "tag": "0000_married_ink", - "breakpoints": true - }, - { - "idx": 1, - "version": "7", - "when": 1780624516901, - "tag": "0001_fancy_wolfpack", - "breakpoints": true - }, - { - "idx": 2, - "version": "7", - "when": 1780642551848, - "tag": "0002_unusual_whirlwind", - "breakpoints": true - }, - { - "idx": 3, - "version": "7", - "when": 1780664200000, - "tag": "0003_unify_users_training", - "breakpoints": true - }, - { - "idx": 4, - "version": "7", - "when": 1788638400000, - "tag": "0004_free_text_training_courses", - "breakpoints": true - }, - { - "idx": 5, - "version": "7", - "when": 1780669454315, - "tag": "0005_training_record_employee_id_nullable", - "breakpoints": true - }, - { - "idx": 6, - "version": "7", - "when": 1788639600000, - "tag": "0006_training_record_employee_id_nullable_fix", - "breakpoints": true - }, - { - "idx": 7, - "version": "7", - "when": 1781162457987, - "tag": "0007_sticky_korath", - "breakpoints": true - }, - { - "idx": 8, - "version": "7", - "when": 1782110903496, - "tag": "0008_nosy_robin_chapel", - "breakpoints": true - }, - { - "idx": 9, - "version": "7", - "when": 1782359921598, - "tag": "0009_lean_hobgoblin", - "breakpoints": true - }, - { - "idx": 10, - "version": "7", - "when": 1782364383108, - "tag": "0010_romantic_marauders", - "breakpoints": true - }, - { - "idx": 11, - "version": "7", - "when": 1782368062128, - "tag": "0011_equal_cannonball", - "breakpoints": true - }, - { - "idx": 12, - "version": "7", - "when": 1782896400000, - "tag": "0012_change_duration_minutes", - "breakpoints": true - }, - { - "idx": 13, - "version": "7", - "when": 1782713460067, - "tag": "0013_glamorous_mysterio", - "breakpoints": true - }, - { - "idx": 14, - "version": "7", - "when": 1783322920425, - "tag": "0014_sweet_nico_minoru", - "breakpoints": true - }, - { - "idx": 15, - "version": "7", - "when": 1783386000000, - "tag": "0015_permission_template_authorization", - "breakpoints": true - }, - { - "idx": 16, - "version": "7", - "when": 1783401232038, - "tag": "0016_curious_giant_man", - "breakpoints": true - }, - { - "idx": 17, - "version": "7", - "when": 1783496392790, - "tag": "0017_flowery_moondragon", - "breakpoints": true - }, - { - "idx": 18, - "version": "7", - "when": 1783899000000, - "tag": "0018_organizations_soft_delete_repair", - "breakpoints": true - }, - { - "idx": 19, - "version": "7", - "when": 1789251000000, - "tag": "0019_content_approval_workflow", + "when": 1784222322639, + "tag": "0000_secret_sasquatch", "breakpoints": true } ] -} +} \ No newline at end of file