CREATE TABLE "projects" (
	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
	"tenant_id" uuid NOT NULL,
	"name" text NOT NULL,
	"created_by_id" uuid,
	"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,
	CONSTRAINT "projects_tenant_name_unique" UNIQUE("tenant_id","name")
);
--> statement-breakpoint
ALTER TABLE "tickets" ADD COLUMN "project_id" uuid;--> statement-breakpoint
ALTER TABLE "tickets" ADD COLUMN "department" text;--> statement-breakpoint
ALTER TABLE "tickets" ADD COLUMN "date_of_occurrence" date;--> statement-breakpoint
ALTER TABLE "tickets" ADD COLUMN "issue_category" text;--> statement-breakpoint
ALTER TABLE "tickets" ADD COLUMN "affected_system" text;--> statement-breakpoint
ALTER TABLE "tickets" ADD COLUMN "user_priority" text;--> statement-breakpoint
ALTER TABLE "tickets" ADD COLUMN "success_criteria" text;--> statement-breakpoint
ALTER TABLE "tickets" ADD COLUMN "action_requested" text;--> statement-breakpoint
ALTER TABLE "tickets" ADD COLUMN "resolution_severity" text;--> statement-breakpoint
ALTER TABLE "tickets" ADD COLUMN "resolution_concerns" text;--> statement-breakpoint
ALTER TABLE "tickets" ADD COLUMN "resolution_summary" text;--> statement-breakpoint
ALTER TABLE "projects" ADD CONSTRAINT "projects_tenant_id_tenants_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "projects" ADD CONSTRAINT "projects_created_by_id_users_id_fk" FOREIGN KEY ("created_by_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "tickets" ADD CONSTRAINT "tickets_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE no action ON UPDATE no action;