Skip to content

Commit 629e671

Browse files
chore: add supabase CLI and restore migration new command (#13)
Adds supabase as a dev dependency so agents can use `npx supabase migration new <name>` for consistent timestamp prefixes. Reverts the manual YYYYMMDDHHmmss instructions from the previous PR. Co-authored-by: Ona <no-reply@ona.com>
1 parent 97c34a6 commit 629e671

8 files changed

Lines changed: 187 additions & 18 deletions

File tree

.agents/conventions.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,10 @@ Pattern: wrap in try/catch, return structured JSON with appropriate status codes
232232

233233
## Database Migrations
234234

235-
Create migration files manually in `supabase/migrations/` with a UTC timestamp prefix:
236-
237235
```bash
238-
# Format: YYYYMMDDHHmmss_<descriptive_name>.sql
239-
# Use the current UTC time when creating the file.
240-
# Example (created at 2026-04-14 20:00:00 UTC):
241-
touch supabase/migrations/20260414200000_add_pages_table.sql
236+
npx supabase migration new <descriptive-name>
237+
# Creates: supabase/migrations/<YYYYMMDDHHmmss>_<name>.sql
238+
# The CLI generates the correct UTC timestamp prefix automatically.
242239
```
243240

244241
```sql
@@ -261,7 +258,7 @@ create policy "workspace members can read pages"
261258
```
262259

263260
Rules:
264-
- Timestamp must be current UTC time — never reuse or backdate timestamps.
261+
- Always use `npx supabase migration new` — never create migration files manually.
265262
- One migration per logical change (table + its RLS policies together).
266263
- Auto-applied on merge to main via the deploy-migrations CI workflow.
267264

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ yarn-error.log*
4141
# typescript
4242
*.tsbuildinfo
4343
next-env.d.ts
44+
supabase/.temp/

.ona/automations/bug-fixer.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ action:
9999
9. Fix the root cause. Do NOT fix symptoms.
100100
- Follow every convention in AGENTS.md without exception.
101101
- Add a regression test that would have caught this bug.
102-
- For database changes: create a migration file in `supabase/migrations/` with a UTC
103-
timestamp prefix: `YYYYMMDDHHmmss_<name>.sql` (use current UTC time).
102+
- For database changes: `npx supabase migration new <name>`
104103
10. Run the full CI check locally: `pnpm lint && pnpm typecheck && pnpm test`
105104
11. Fix any errors before proceeding.
106105

.ona/automations/feature-builder.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@ action:
9595
9696
Before coding, decide:
9797
- **Database**: does this need a new table, new columns, or new RLS policies?
98-
If yes, create the migration file first in `supabase/migrations/` with a UTC
99-
timestamp prefix: `YYYYMMDDHHmmss_<name>.sql` (e.g. `20260414200000_add_pages_table.sql`).
100-
Use the current UTC time — never reuse or backdate timestamps.
98+
If yes, create the migration first: `npx supabase migration new <name>`
10199
- **API**: does this need new API routes? Follow the existing pattern in `src/app/api/`.
102100
- **Components**: which existing components can be reused? What new ones are needed?
103101
Check `src/components/ui/` (shadcn) before building anything custom.

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ metrics/ → Daily/weekly metrics snapshots
3535
- Named exports only. No default exports.
3636
- Conventional commits: `feat|fix|chore|docs|test|refactor(scope): description`
3737
- PRs with type `feat` or `fix` must reference an issue: `Closes #N`. Chore PRs (metrics, docs, deps) do not require an issue.
38-
- Database changes require a migration file in `supabase/migrations/` with timestamp prefix: `YYYYMMDDHHmmss_<name>.sql` (use current UTC time, e.g. `20260414200000_add_pages_table.sql`)
38+
- Database changes require a migration: `npx supabase migration new <name>`
3939
- Environment variables: `NEXT_PUBLIC_` prefix only for browser-safe values.
4040

4141
## Testing

docs/automations.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,7 @@ Before writing anything, understand the current codebase:
401401

402402
Before coding, decide:
403403
- **Database**: does this need a new table, new columns, or new RLS policies?
404-
If yes, create the migration file first in `supabase/migrations/` with a UTC
405-
timestamp prefix: `YYYYMMDDHHmmss_<name>.sql` (e.g. `20260414200000_add_pages_table.sql`).
406-
Use the current UTC time — never reuse or backdate timestamps.
404+
If yes, create the migration first: `npx supabase migration new <name>`
407405
- **API**: does this need new API routes? Follow the existing pattern in `src/app/api/`.
408406
- **Components**: which existing components can be reused? What new ones are needed?
409407
Check `src/components/ui/` (shadcn) before building anything custom.
@@ -698,8 +696,7 @@ For infra/config bugs:
698696
9. Fix the root cause. Do NOT fix symptoms.
699697
- Follow every convention in AGENTS.md without exception.
700698
- Add a regression test that would have caught this bug.
701-
- For database changes: create a migration file in `supabase/migrations/` with a UTC
702-
timestamp prefix: `YYYYMMDDHHmmss_<name>.sql` (use current UTC time).
699+
- For database changes: `npx supabase migration new <name>`
703700
10. Run the full CI check locally: `pnpm lint && pnpm typecheck && pnpm test`
704701
11. Fix any errors before proceeding.
705702

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,16 @@
3131
"eslint-config-next": "16.2.3",
3232
"jsdom": "^29.0.2",
3333
"playwright": "^1.59.1",
34+
"supabase": "^2.91.1",
3435
"tailwindcss": "^4",
3536
"twitter-api-v2": "^1.29.0",
3637
"typescript": "^5",
3738
"vitest": "^4.1.4"
39+
},
40+
"pnpm": {
41+
"onlyBuiltDependencies": [
42+
"supabase",
43+
"@sentry/cli"
44+
]
3845
}
3946
}

0 commit comments

Comments
 (0)