diff --git a/apps/api/drizzle/0006_seed_builtin_exercises.sql b/apps/api/drizzle/0006_seed_builtin_exercises.sql new file mode 100644 index 0000000..1eefed9 --- /dev/null +++ b/apps/api/drizzle/0006_seed_builtin_exercises.sql @@ -0,0 +1,16 @@ +-- Installs the stable built-in exercise catalog required by routine creation. +INSERT INTO "exercises" ("id", "owner_user_id", "name") +VALUES + ('9f4b5a8e-2c3d-4f10-8a11-000000000001', NULL, 'Bicep Curl'), + ('9f4b5a8e-2c3d-4f10-8a11-000000000002', NULL, 'Hammer Curl'), + ('9f4b5a8e-2c3d-4f10-8a11-000000000003', NULL, 'Tricep Extension'), + ('9f4b5a8e-2c3d-4f10-8a11-000000000004', NULL, 'Overhead Press'), + ('9f4b5a8e-2c3d-4f10-8a11-000000000005', NULL, 'Lateral Raise') +ON CONFLICT ("id") DO UPDATE +SET + "owner_user_id" = EXCLUDED."owner_user_id", + "name" = EXCLUDED."name", + "updated_at" = NOW() +WHERE + "exercises"."owner_user_id" IS DISTINCT FROM EXCLUDED."owner_user_id" + OR "exercises"."name" IS DISTINCT FROM EXCLUDED."name"; diff --git a/apps/api/drizzle/meta/0006_snapshot.json b/apps/api/drizzle/meta/0006_snapshot.json new file mode 100644 index 0000000..dda66e3 --- /dev/null +++ b/apps/api/drizzle/meta/0006_snapshot.json @@ -0,0 +1,584 @@ +{ + "id": "b5ad31cd-44ab-4dd5-9e9a-91a5a1f50db2", + "prevId": "8e09e649-8bf9-41e8-92d1-b9d3cd08d4d0", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.exercises": { + "name": "exercises", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "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": { + "exercises_owner_user_id_idx": { + "name": "exercises_owner_user_id_idx", + "columns": [ + { + "expression": "owner_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "with": {}, + "method": "btree", + "concurrently": false + } + }, + "foreignKeys": { + "exercises_owner_user_id_users_id_fk": { + "name": "exercises_owner_user_id_users_id_fk", + "tableFrom": "exercises", + "columnsFrom": ["owner_user_id"], + "tableTo": "users", + "columnsTo": ["id"], + "onUpdate": "no action", + "onDelete": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.routine_exercises": { + "name": "routine_exercises", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "routine_id": { + "name": "routine_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "exercise_id": { + "name": "exercise_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "sets": { + "name": "sets", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "target_reps": { + "name": "target_reps", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "weight": { + "name": "weight", + "type": "numeric(8, 2)", + "primaryKey": false, + "notNull": true + }, + "weight_unit": { + "name": "weight_unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rest_between_sets_seconds": { + "name": "rest_between_sets_seconds", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "rest_after_exercise_seconds": { + "name": "rest_after_exercise_seconds", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "notes": { + "name": "notes", + "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": { + "routine_exercises_routine_position_unique": { + "name": "routine_exercises_routine_position_unique", + "columns": [ + { + "expression": "routine_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "position", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "with": {}, + "method": "btree", + "concurrently": false + }, + "routine_exercises_exercise_id_idx": { + "name": "routine_exercises_exercise_id_idx", + "columns": [ + { + "expression": "exercise_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "with": {}, + "method": "btree", + "concurrently": false + } + }, + "foreignKeys": { + "routine_exercises_routine_id_routines_id_fk": { + "name": "routine_exercises_routine_id_routines_id_fk", + "tableFrom": "routine_exercises", + "columnsFrom": ["routine_id"], + "tableTo": "routines", + "columnsTo": ["id"], + "onUpdate": "no action", + "onDelete": "cascade" + }, + "routine_exercises_exercise_id_exercises_id_fk": { + "name": "routine_exercises_exercise_id_exercises_id_fk", + "tableFrom": "routine_exercises", + "columnsFrom": ["exercise_id"], + "tableTo": "exercises", + "columnsTo": ["id"], + "onUpdate": "no action", + "onDelete": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "routine_exercises_position_nonnegative": { + "name": "routine_exercises_position_nonnegative", + "value": "\"routine_exercises\".\"position\" >= 0" + }, + "routine_exercises_sets_positive": { + "name": "routine_exercises_sets_positive", + "value": "\"routine_exercises\".\"sets\" > 0" + }, + "routine_exercises_target_reps_positive": { + "name": "routine_exercises_target_reps_positive", + "value": "\"routine_exercises\".\"target_reps\" > 0" + }, + "routine_exercises_weight_nonnegative": { + "name": "routine_exercises_weight_nonnegative", + "value": "\"routine_exercises\".\"weight\" >= 0" + }, + "routine_exercises_weight_unit_supported": { + "name": "routine_exercises_weight_unit_supported", + "value": "\"routine_exercises\".\"weight_unit\" IN ('lb', 'kg')" + }, + "routine_exercises_rest_between_sets_nonnegative": { + "name": "routine_exercises_rest_between_sets_nonnegative", + "value": "\"routine_exercises\".\"rest_between_sets_seconds\" >= 0" + }, + "routine_exercises_rest_after_exercise_nonnegative": { + "name": "routine_exercises_rest_after_exercise_nonnegative", + "value": "\"routine_exercises\".\"rest_after_exercise_seconds\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.routine_schedules": { + "name": "routine_schedules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "routine_id": { + "name": "routine_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "day_of_week": { + "name": "day_of_week", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "local_time": { + "name": "local_time", + "type": "time(0)", + "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": { + "routine_schedules_routine_day_time_unique": { + "name": "routine_schedules_routine_day_time_unique", + "columns": [ + { + "expression": "routine_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day_of_week", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "local_time", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "with": {}, + "method": "btree", + "concurrently": false + } + }, + "foreignKeys": { + "routine_schedules_routine_id_routines_id_fk": { + "name": "routine_schedules_routine_id_routines_id_fk", + "tableFrom": "routine_schedules", + "columnsFrom": ["routine_id"], + "tableTo": "routines", + "columnsTo": ["id"], + "onUpdate": "no action", + "onDelete": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "routine_schedules_day_of_week_supported": { + "name": "routine_schedules_day_of_week_supported", + "value": "\"routine_schedules\".\"day_of_week\" BETWEEN 0 AND 6" + } + }, + "isRLSEnabled": false + }, + "public.routines": { + "name": "routines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "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": { + "routines_user_id_idx": { + "name": "routines_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "with": {}, + "method": "btree", + "concurrently": false + } + }, + "foreignKeys": { + "routines_user_id_users_id_fk": { + "name": "routines_user_id_users_id_fk", + "tableFrom": "routines", + "columnsFrom": ["user_id"], + "tableTo": "users", + "columnsTo": ["id"], + "onUpdate": "no action", + "onDelete": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sessions": { + "name": "sessions", + "schema": "", + "columns": { + "sid": { + "name": "sid", + "type": "varchar", + "primaryKey": true, + "notNull": true + }, + "sess": { + "name": "sess", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "expire": { + "name": "expire", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "sessions_expire_idx": { + "name": "sessions_expire_idx", + "columns": [ + { + "expression": "expire", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "with": {}, + "method": "btree", + "concurrently": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "avatar_url": { + "name": "avatar_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "auth_provider": { + "name": "auth_provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "auth_provider_subject": { + "name": "auth_provider_subject", + "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": { + "users_auth_provider_subject_unique": { + "name": "users_auth_provider_subject_unique", + "columns": [ + { + "expression": "auth_provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "auth_provider_subject", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "with": {}, + "method": "btree", + "concurrently": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "views": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} diff --git a/apps/api/drizzle/meta/_journal.json b/apps/api/drizzle/meta/_journal.json index dd1ba9c..2b7dd6f 100644 --- a/apps/api/drizzle/meta/_journal.json +++ b/apps/api/drizzle/meta/_journal.json @@ -43,6 +43,13 @@ "when": 1787609439724, "tag": "0005_freezing_siren", "breakpoints": true + }, + { + "idx": 6, + "version": "7", + "when": 1787609706396, + "tag": "0006_seed_builtin_exercises", + "breakpoints": true } ] }