BUG: Creating tables fails with incorrect schema.sql

Open
#155 0 comments 0 reactions 0 assignees View on GitHub

@TaeBbong is already working on this.

Since Feb 24, 2026.

  • #156 by @TaeBbong — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
dart, postgresql, sql, supabase
Domain
databases

Research direction

Open supabase/schemas/schema.sql and compare its table order, commas, foreign-key references, and therapy_type definition with the issue details and the TherapyTypeModel. Run the complete script in the Supabase SQL Editor. Done means all tables and indexes are created in one run without syntax or missing-relation errors.

Written by the indexing model from the issue text.

Description

Is there an existing issue for this?
  • I have searched the existing issues
What happened?

This issue and related PR were fully identified and analyzed by myself. Claude was only used to assist with writing descriptions in English.

📌 Issue Overview

schema.sql fails to execute when copied into the Supabase SQL Editor due to multiple syntax errors, missing table definitions, and incorrect table declaration order.

Previous PR #146 also indicates syntax error, and I found more errors.

🔍 Steps to Reproduce

  1. Go to Supabase Dashboard → SQL Editor
  2. Copy and paste the entire contents of supabase/schemas/schema.sql guided by README
  3. Click Run
  4. See the error:
ERROR: 42601: syntax error at or near ")"
ERROR: 42P01: relation "therapist" does not exist
ERROR: 42P01: relation "therapy_type" does not exist

🎯 Expected Behavior

The full schema.sql should execute in a single run, creating all tables and indexes without errors.

🚨 Actual Behavior

Execution fails due to the following issues:

  1. Table declaration order: patient is declared before therapist, but patient.therapist_id references therapist(id). Similarly, therapy_goal references therapy_type(id) which is declared later.
  2. Trailing commas: therapist, session, observation_master, activity_master, daily_activities, and daily_activity_logs have a trailing comma after the last column definition.
  3. Missing comma: daily_activity_logs is missing a comma after activity_items JSONB NOT NULL.
  4. Missing table: therapy_goal.therapy_type_id references therapy_type(id), but the therapy_type table is not defined in the schema.
  5. Dead column: therapy_goal.therapy_type INT2 is not used anywhere in the codebase.

📷 Screenshot

N/A

💡 Suggested Improvements

All fixes have already been applied to schema.sql and verified by successfully executing the full script in the Supabase SQL Editor without errors. A PR is ready to be submitted with the following changes:

  • Reordered table declarations to respect FK dependencies (therapist before patient, therapy/therapy_type before therapy_goal)
  • Added therapy_type table matching the TherapyTypeModel in the codebase (id, created_at, name, description)
  • Removed all trailing commas
  • Added the missing comma in daily_activity_logs
  • Removed the unused therapy_goal.therapy_type INT2 column

Have same concern with issue #153 , but this is currently occurring error, so it should be fixed whether we use Supabase as backend or not.

Record
  • I agree to follow this project's Code of Conduct
  • I want to work on this issue
Dominant language
Dart
Stars
30
Forks
49
PR merge metrics
No merged PRs in 30d

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AOSSIE-Org/NeuroTrack

All issues in AOSSIE-Org/NeuroTrack

Similar issues

More Dart issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.