Skip to content

Generate Supabase migrations from generated collection APIs #8

Description

@artiphishle

Goal

Consume manifest.data.apis entries with generated collection resources and emit Supabase/Postgres migration artifacts.

Context

The nutrition scanner challenge template now declares generated domain APIs for products, captures, challenges, and scan events through manifest.data.apis.

The current infra package already generates Supabase auth/profile artifacts, but does not appear to generate database tables from generated collection API resources yet.

Scope

For generated API entries where:

api.kind === 'generated'
api.resource.kind === 'collection'

emit a Supabase migration with create table if not exists statements for each collection.

Minimum field mapping:

  • uuid -> uuid
  • text -> text
  • number -> numeric
  • boolean -> boolean
  • datetime -> timestamptz
  • json -> jsonb

Minimum behavior:

  • honor collection.schema, collection.name, and collection.primaryKey
  • honor field required
  • honor field unique
  • honor safe scalar defaults such as strings, numbers, and booleans
  • enable RLS for generated tables when the API declares auth.required = true
  • add an authenticated read policy and a conservative authenticated insert policy for auth-required generated APIs

Acceptance criteria

  • Supabase/minikube infra emits a domain data migration when generated collection APIs exist.
  • Tests cover nutrition-like products, captures, challenges, and scan events.
  • The generated migration contains the expected tables, columns, unique barcode constraint, jsonb nutrition fields, timestamptz fields, and RLS policies.
  • Existing manifests without manifest.data.apis remain backward compatible.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions