pedometar

problem with expogo, should be sorted before build
This commit is contained in:
dimitar committed 2025-11-28 18:08:52 +01:00
1 parent b0d751540e
commit 24ed0b6190
16 files changed
+1676 -64

No files matched your search

@@ -0,0 +1,136 @@
CREATE TABLE `activity_logs` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`date` text NOT NULL,
`steps` integer DEFAULT 0 NOT NULL,
`calories` real DEFAULT 0,
`duration` integer DEFAULT 0,
`distance` real DEFAULT 0,
`created_at` integer NOT NULL,
`updated_at` integer NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `attendance` (
`id` text PRIMARY KEY NOT NULL,
`client_id` text NOT NULL,
`check_in_time` integer NOT NULL,
`check_out_time` integer,
`type` text DEFAULT 'gym' NOT NULL,
`notes` text,
`created_at` integer NOT NULL,
FOREIGN KEY (`client_id`) REFERENCES `clients`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `clients` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`membership_type` text DEFAULT 'basic' NOT NULL,
`membership_status` text DEFAULT 'active' NOT NULL,
`join_date` integer NOT NULL,
`last_visit` integer,
`emergency_contact_name` text,
`emergency_contact_phone` text,
`emergency_contact_relationship` text,
`created_at` integer NOT NULL,
`updated_at` integer NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `fitness_goals` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`fitness_profile_id` text,
`goal_type` text NOT NULL,
`title` text NOT NULL,
`description` text,
`target_value` real,
`current_value` real,
`unit` text,
`start_date` integer NOT NULL,
`target_date` integer,
`completed_date` integer,
`status` text DEFAULT 'active' NOT NULL,
`progress` real DEFAULT 0,
`priority` text DEFAULT 'medium',
`notes` text,
`created_at` integer NOT NULL,
`updated_at` integer NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (`fitness_profile_id`) REFERENCES `fitness_profiles`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `fitness_profiles` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`height` real,
`weight` real,
`age` integer,
`gender` text,
`fitness_goal` text,
`activity_level` text,
`medical_conditions` text,
`allergies` text,
`injuries` text,
`created_at` integer NOT NULL,
`updated_at` integer NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE UNIQUE INDEX `fitness_profiles_user_id_unique` ON `fitness_profiles` (`user_id`);--> statement-breakpoint
CREATE TABLE `notifications` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`title` text NOT NULL,
`message` text NOT NULL,
`type` text NOT NULL,
`read` integer DEFAULT false NOT NULL,
`created_at` integer NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `payments` (
`id` text PRIMARY KEY NOT NULL,
`client_id` text NOT NULL,
`amount` real NOT NULL,
`currency` text DEFAULT 'USD' NOT NULL,
`status` text DEFAULT 'pending' NOT NULL,
`payment_method` text NOT NULL,
`due_date` integer NOT NULL,
`paid_at` integer,
`description` text NOT NULL,
`created_at` integer NOT NULL,
`updated_at` integer NOT NULL,
FOREIGN KEY (`client_id`) REFERENCES `clients`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `recommendations` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`fitness_profile_id` text NOT NULL,
`recommendation_text` text NOT NULL,
`activity_plan` text NOT NULL,
`diet_plan` text NOT NULL,
`status` text DEFAULT 'pending' NOT NULL,
`generated_at` integer NOT NULL,
`approved_at` integer,
`approved_by` text,
`created_at` integer NOT NULL,
`updated_at` integer NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (`fitness_profile_id`) REFERENCES `fitness_profiles`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `users` (
`id` text PRIMARY KEY NOT NULL,
`email` text NOT NULL,
`first_name` text NOT NULL,
`last_name` text NOT NULL,
`password` text,
`role` text DEFAULT 'client' NOT NULL,
`phone` text,
`created_at` integer NOT NULL,
`updated_at` integer NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX `users_email_unique` ON `users` (`email`);
@@ -0,0 +1,956 @@
{
"version": "6",
"dialect": "sqlite",
"id": "5e9ba8c4-bf41-4f17-a17f-68591b227fa7",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"activity_logs": {
"name": "activity_logs",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"date": {
"name": "date",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"steps": {
"name": "steps",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": 0
},
"calories": {
"name": "calories",
"type": "real",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": 0
},
"duration": {
"name": "duration",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": 0
},
"distance": {
"name": "distance",
"type": "real",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": 0
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"activity_logs_user_id_users_id_fk": {
"name": "activity_logs_user_id_users_id_fk",
"tableFrom": "activity_logs",
"tableTo": "users",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"attendance": {
"name": "attendance",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"client_id": {
"name": "client_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"check_in_time": {
"name": "check_in_time",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"check_out_time": {
"name": "check_out_time",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"type": {
"name": "type",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'gym'"
},
"notes": {
"name": "notes",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"attendance_client_id_clients_id_fk": {
"name": "attendance_client_id_clients_id_fk",
"tableFrom": "attendance",
"tableTo": "clients",
"columnsFrom": [
"client_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"clients": {
"name": "clients",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"membership_type": {
"name": "membership_type",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'basic'"
},
"membership_status": {
"name": "membership_status",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'active'"
},
"join_date": {
"name": "join_date",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"last_visit": {
"name": "last_visit",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"emergency_contact_name": {
"name": "emergency_contact_name",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"emergency_contact_phone": {
"name": "emergency_contact_phone",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"emergency_contact_relationship": {
"name": "emergency_contact_relationship",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"clients_user_id_users_id_fk": {
"name": "clients_user_id_users_id_fk",
"tableFrom": "clients",
"tableTo": "users",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"fitness_goals": {
"name": "fitness_goals",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"fitness_profile_id": {
"name": "fitness_profile_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"goal_type": {
"name": "goal_type",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"title": {
"name": "title",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"target_value": {
"name": "target_value",
"type": "real",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"current_value": {
"name": "current_value",
"type": "real",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"unit": {
"name": "unit",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"start_date": {
"name": "start_date",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"target_date": {
"name": "target_date",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"completed_date": {
"name": "completed_date",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"status": {
"name": "status",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'active'"
},
"progress": {
"name": "progress",
"type": "real",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": 0
},
"priority": {
"name": "priority",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": "'medium'"
},
"notes": {
"name": "notes",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"fitness_goals_user_id_users_id_fk": {
"name": "fitness_goals_user_id_users_id_fk",
"tableFrom": "fitness_goals",
"tableTo": "users",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"fitness_goals_fitness_profile_id_fitness_profiles_id_fk": {
"name": "fitness_goals_fitness_profile_id_fitness_profiles_id_fk",
"tableFrom": "fitness_goals",
"tableTo": "fitness_profiles",
"columnsFrom": [
"fitness_profile_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"fitness_profiles": {
"name": "fitness_profiles",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"height": {
"name": "height",
"type": "real",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"weight": {
"name": "weight",
"type": "real",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"age": {
"name": "age",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"gender": {
"name": "gender",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"fitness_goal": {
"name": "fitness_goal",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"activity_level": {
"name": "activity_level",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"medical_conditions": {
"name": "medical_conditions",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"allergies": {
"name": "allergies",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"injuries": {
"name": "injuries",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"fitness_profiles_user_id_unique": {
"name": "fitness_profiles_user_id_unique",
"columns": [
"user_id"
],
"isUnique": true
}
},
"foreignKeys": {
"fitness_profiles_user_id_users_id_fk": {
"name": "fitness_profiles_user_id_users_id_fk",
"tableFrom": "fitness_profiles",
"tableTo": "users",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"notifications": {
"name": "notifications",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"title": {
"name": "title",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"message": {
"name": "message",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"type": {
"name": "type",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"read": {
"name": "read",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"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": {},
"checkConstraints": {}
},
"payments": {
"name": "payments",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"client_id": {
"name": "client_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"amount": {
"name": "amount",
"type": "real",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"currency": {
"name": "currency",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'USD'"
},
"status": {
"name": "status",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'pending'"
},
"payment_method": {
"name": "payment_method",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"due_date": {
"name": "due_date",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"paid_at": {
"name": "paid_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"payments_client_id_clients_id_fk": {
"name": "payments_client_id_clients_id_fk",
"tableFrom": "payments",
"tableTo": "clients",
"columnsFrom": [
"client_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"recommendations": {
"name": "recommendations",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"fitness_profile_id": {
"name": "fitness_profile_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"recommendation_text": {
"name": "recommendation_text",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"activity_plan": {
"name": "activity_plan",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"diet_plan": {
"name": "diet_plan",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"status": {
"name": "status",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'pending'"
},
"generated_at": {
"name": "generated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"approved_at": {
"name": "approved_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"approved_by": {
"name": "approved_by",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"recommendations_user_id_users_id_fk": {
"name": "recommendations_user_id_users_id_fk",
"tableFrom": "recommendations",
"tableTo": "users",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"recommendations_fitness_profile_id_fitness_profiles_id_fk": {
"name": "recommendations_fitness_profile_id_fitness_profiles_id_fk",
"tableFrom": "recommendations",
"tableTo": "fitness_profiles",
"columnsFrom": [
"fitness_profile_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"users": {
"name": "users",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"first_name": {
"name": "first_name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"last_name": {
"name": "last_name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"password": {
"name": "password",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"role": {
"name": "role",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'client'"
},
"phone": {
"name": "phone",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"users_email_unique": {
"name": "users_email_unique",
"columns": [
"email"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
}
},
"views": {},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
},
"internal": {
"indexes": {}
}
}
@@ -0,0 +1,13 @@
{
"version": "7",
"dialect": "sqlite",
"entries": [
{
"idx": 0,
"version": "6",
"when": 1764132388314,
"tag": "0000_classy_jigsaw",
"breakpoints": true
}
]
}