Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | // PowerSync client-side SQLite schema.
// If a migration touches a PowerSync-synced table, update this schema and redeploy sync rules.
import { column, Schema, Table } from '@powersync/web';
// ---------------------------------------------------------------------------
// Table definitions — columns match the Postgres migrations exactly.
// Column type mapping:
// uuid → column.text
// timestamptz → column.text
// date → column.text
// boolean → column.integer
// jsonb → column.text (JSON-serialised)
// numeric → column.real
// integer → column.integer
// Postgres enum → column.text
// Postgres array→ column.text (JSON-serialised)
// id column is automatic in PowerSync — do NOT declare it
// ---------------------------------------------------------------------------
// Source: 20260331085034_athletes_exercises_schema.sql
const athletes = new Table({
display_name: column.text,
parq: column.text, // jsonb → text
experience_level: column.text, // enum → text
onboarding_status: column.text, // enum → text
created_at: column.text,
});
// Source: 20260331085034_athletes_exercises_schema.sql
const athlete_profiles = new Table({
athlete_id: column.text,
age: column.integer,
bodyweight_kg: column.real,
training_days: column.text, // jsonb → text
familiar_only_request_count: column.integer,
created_at: column.text,
updated_at: column.text,
});
// Source: 20260331085034_athletes_exercises_schema.sql
const goals = new Table({
athlete_id: column.text,
description: column.text,
clarity: column.text, // enum → text
status: column.text, // enum → text
created_at: column.text,
updated_at: column.text,
});
// Source: 20260331085034_athletes_exercises_schema.sql
// Note: no 'type' or 'severity' columns in the actual migration —
// uses 'body_area', 'source', etc.
const athlete_constraints = new Table({
athlete_id: column.text,
body_area: column.text,
description: column.text,
contraindicated_movements: column.text, // text[] → JSON-serialised text
allowed_alternatives: column.text, // text[] → JSON-serialised text
recovery_notes: column.text,
max_consecutive_hard_days: column.integer,
source: column.text, // enum → text
discovered_at: column.text,
});
// Source: 20260331085034_athletes_exercises_schema.sql
const training_locations = new Table({
athlete_id: column.text,
name: column.text,
equipment: column.text, // jsonb → text
is_default: column.integer, // boolean → integer
is_temporary: column.integer, // boolean → integer
created_at: column.text,
});
// Source: 20260331194549_programming_logging_reviews_schema.sql
const mesocycles = new Table({
athlete_id: column.text,
cycle_number: column.integer,
start_date: column.text,
end_date: column.text,
status: column.text, // enum → text
focus_areas: column.text, // jsonb → text
created_at: column.text,
});
// Source: 20260331194549_programming_logging_reviews_schema.sql
const blocks = new Table({
mesocycle_id: column.text,
block_number: column.integer,
start_date: column.text,
end_date: column.text,
status: column.text, // enum → text
rep_range_low: column.integer,
rep_range_high: column.integer,
rest_seconds_target: column.integer,
created_at: column.text,
});
// Source: 20260331194549_programming_logging_reviews_schema.sql
const workouts = new Table({
block_id: column.text,
athlete_id: column.text,
scheduled_date: column.text,
session_type: column.text, // enum → text
location_id: column.text,
time_cap_minutes: column.integer,
status: column.text, // enum → text
is_deload: column.integer, // boolean → integer
validation_passed: column.integer, // boolean → integer
validation_results: column.text, // jsonb → text
created_at: column.text,
});
// Source: 20260331194549_programming_logging_reviews_schema.sql
// 'order' is a SQL reserved word. PowerSync quotes column names internally
// when generating SQLite DDL, so this is safe to declare as-is.
const prescribed_exercises = new Table({
workout_id: column.text,
exercise_id: column.text,
order: column.integer,
sets: column.text, // jsonb → text
is_warmup: column.integer, // boolean → integer
is_backup: column.integer, // boolean → integer
notes: column.text,
});
// Source: 20260331085034_athletes_exercises_schema.sql
const exercises = new Table({
name: column.text,
movement_patterns: column.text, // movement_pattern[] → JSON-serialised text
muscle_groups: column.text, // muscle_group[] → JSON-serialised text
equipment_required: column.text, // uuid[] → JSON-serialised text
laterality: column.text, // enum → text
difficulty_tier: column.text, // enum → text
domain: column.text, // enum → text (column is named 'domain' not 'exercise_domain')
is_custom: column.integer, // boolean → integer
created_by: column.text,
created_at: column.text,
});
// Source: 20260331194549_programming_logging_reviews_schema.sql
// Note: no 'created_at' in the migration — only started_at, completed_at
const workout_logs = new Table({
workout_id: column.text,
athlete_id: column.text,
started_at: column.text,
completed_at: column.text,
overall_feeling: column.text, // enum → text
was_scaled: column.integer, // boolean → integer
});
// Source: 20260331194549_programming_logging_reviews_schema.sql
// Note: no 'athlete_id' or 'created_at' in the migration
const set_logs = new Table({
workout_log_id: column.text,
prescribed_exercise_id: column.text,
set_number: column.integer,
actual_weight_kg: column.real,
actual_reps: column.integer,
feeling: column.text, // enum → text
skipped: column.integer, // boolean → integer
});
// Source: 20260331085034_athletes_exercises_schema.sql
const exercise_familiarities = new Table({
athlete_id: column.text,
exercise_id: column.text,
readiness: column.text, // enum → text
source: column.text, // enum → text
assessed_at: column.text,
});
// Source: 20260331085034_athletes_exercises_schema.sql
const equipment_types = new Table({
name: column.text,
is_custom: column.integer, // boolean → integer
created_by: column.text,
created_at: column.text,
});
export const AppSchema = new Schema({
athletes,
athlete_profiles,
goals,
athlete_constraints,
training_locations,
mesocycles,
blocks,
workouts,
prescribed_exercises,
exercises,
workout_logs,
set_logs,
exercise_familiarities,
equipment_types,
});
export type Database = (typeof AppSchema)['types'];
|