Set up core database structure to store user and application data
Initializes PostgreSQL database with tables for users, tasks, sessions, and AI interactions. Replit-Commit-Author: Agent Replit-Commit-Session-Id: ff0be73b-afdd-4747-978b-bb8301fb0a82 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/9777c70b-fc38-4831-8d6b-78dfffe041b0/7930aad1-3044-457e-b465-8c9b7c2af1b9.jpg
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
CREATE TYPE "public"."appointment_status" AS ENUM('pending', 'confirmed', 'cancelled', 'completed', 'no_show');--> statement-breakpoint
|
||||
CREATE TYPE "public"."connection_status" AS ENUM('pending', 'accepted', 'blocked');--> statement-breakpoint
|
||||
CREATE TYPE "public"."day_of_week" AS ENUM('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday');--> statement-breakpoint
|
||||
CREATE TYPE "public"."professional_type" AS ENUM('doctor', 'dentist', 'therapist', 'consultant', 'lawyer', 'accountant', 'coach', 'tutor', 'other');--> statement-breakpoint
|
||||
CREATE TABLE "ai_interactions" (
|
||||
"id" serial PRIMARY KEY NOT NULL,
|
||||
"user_id" integer,
|
||||
"type" varchar(20) NOT NULL,
|
||||
"prompt" text,
|
||||
"response" text NOT NULL,
|
||||
"model_used" text,
|
||||
"processing_time" integer,
|
||||
"was_spoken" boolean DEFAULT false,
|
||||
"created_at" timestamp DEFAULT now()
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "financial_records" (
|
||||
"id" serial PRIMARY KEY NOT NULL,
|
||||
"user_id" integer NOT NULL,
|
||||
"type" varchar(10) NOT NULL,
|
||||
"amount" numeric(12, 2) NOT NULL,
|
||||
"category" text NOT NULL,
|
||||
"description" text,
|
||||
"date" timestamp NOT NULL,
|
||||
"created_via_voice" boolean DEFAULT false,
|
||||
"voice_transcription" text,
|
||||
"metadata" json,
|
||||
"created_at" timestamp DEFAULT now(),
|
||||
"updated_at" timestamp DEFAULT now()
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "sessions" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"user_id" integer NOT NULL,
|
||||
"token" text NOT NULL,
|
||||
"expires_at" timestamp NOT NULL,
|
||||
"created_at" timestamp DEFAULT now(),
|
||||
CONSTRAINT "sessions_token_unique" UNIQUE("token")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "tasks" (
|
||||
"id" serial PRIMARY KEY NOT NULL,
|
||||
"user_id" integer NOT NULL,
|
||||
"title" text NOT NULL,
|
||||
"description" text,
|
||||
"priority" varchar(10) DEFAULT 'medium' NOT NULL,
|
||||
"status" varchar(20) DEFAULT 'pending' NOT NULL,
|
||||
"due_date" timestamp,
|
||||
"completed_at" timestamp,
|
||||
"created_via_voice" boolean DEFAULT false,
|
||||
"voice_transcription" text,
|
||||
"created_at" timestamp DEFAULT now(),
|
||||
"updated_at" timestamp DEFAULT now()
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "user_preferences" (
|
||||
"id" serial PRIMARY KEY NOT NULL,
|
||||
"user_id" integer NOT NULL,
|
||||
"theme" varchar(10) DEFAULT 'light',
|
||||
"language" varchar(10) DEFAULT 'en',
|
||||
"voice_model" text DEFAULT 'base',
|
||||
"tts_voice" text DEFAULT 'default',
|
||||
"notifications" json,
|
||||
"dashboard_layout" json,
|
||||
"created_at" timestamp DEFAULT now(),
|
||||
"updated_at" timestamp DEFAULT now(),
|
||||
CONSTRAINT "user_preferences_user_id_unique" UNIQUE("user_id")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "users" (
|
||||
"id" serial PRIMARY KEY NOT NULL,
|
||||
"username" text NOT NULL,
|
||||
"email" text NOT NULL,
|
||||
"password" text NOT NULL,
|
||||
"role" varchar(20) DEFAULT 'standard' NOT NULL,
|
||||
"first_name" text,
|
||||
"last_name" text,
|
||||
"onboarding_complete" boolean DEFAULT false,
|
||||
"voice_enabled" boolean DEFAULT true,
|
||||
"tts_enabled" boolean DEFAULT true,
|
||||
"is_professional" boolean DEFAULT false NOT NULL,
|
||||
"professional_type" "professional_type",
|
||||
"business_name" varchar(255),
|
||||
"bio" text,
|
||||
"specializations" text,
|
||||
"phone_number" varchar(20),
|
||||
"address" text,
|
||||
"is_public_profile" boolean DEFAULT false NOT NULL,
|
||||
"allow_appointment_booking" boolean DEFAULT false NOT NULL,
|
||||
"profile_image_url" varchar(500),
|
||||
"created_at" timestamp DEFAULT now(),
|
||||
"updated_at" timestamp DEFAULT now(),
|
||||
CONSTRAINT "users_username_unique" UNIQUE("username"),
|
||||
CONSTRAINT "users_email_unique" UNIQUE("email")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "voice_commands" (
|
||||
"id" serial PRIMARY KEY NOT NULL,
|
||||
"user_id" integer NOT NULL,
|
||||
"command" text NOT NULL,
|
||||
"transcription" text NOT NULL,
|
||||
"intent" varchar(50),
|
||||
"confidence" numeric(5, 4),
|
||||
"processing_time" integer,
|
||||
"successful" boolean DEFAULT true,
|
||||
"error_message" text,
|
||||
"created_at" timestamp DEFAULT now()
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "ai_interactions" ADD CONSTRAINT "ai_interactions_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "financial_records" ADD CONSTRAINT "financial_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 "sessions" ADD CONSTRAINT "sessions_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "tasks" ADD CONSTRAINT "tasks_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_preferences" ADD CONSTRAINT "user_preferences_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "voice_commands" ADD CONSTRAINT "voice_commands_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
|
||||
Reference in New Issue
Block a user