Skip to content

Commit 8bbc36a

Browse files
committed
Missing a step to apply migrations locally. Has impact on dev sequence.
1 parent 3eb8b7f commit 8bbc36a

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

packages/database/README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@ All CLI commands below should be run in this directory (`packages/database`.)
1515
1. Assuming you're working on a feature branch.
1616
2. Make changes to the schema, by editing files in `packages/database/supabase/schemas`
1717
3. If you created a new schema file, make sure to add it to `[db.migrations] schema_paths` in `packages/database/supabase/config.toml`. Schema files are applied in that order, you may need to be strategic in placing your file.
18-
4. `turbo build`, which will do the following:
19-
1. Check your logic with `sqruff lint supabase/schemas`, and eventually `sqruff fix supabase/schemas`
20-
2. Regenerate the types file with `supabase gen types typescript --local > types.gen.ts`
18+
4. `turbo check-types`, which will do the following:
19+
1. Check your logic with `sqruff lint supabase/schemas`
20+
1. If there are errors there, you can fix them with `npm run lint:fix`
21+
2. Stop supabase.
2122
3. See if there would be a migration to apply with `supabase db diff`
2223
5. If applying the new schema fails, repeat step 4
2324
6. If you are satisfied with the migration, create a migration file with `npm run dbdiff:save some_meaningful_migration_name`
2425
1. If all goes well, there should be a new file named `supbase/migration/2..._some_meaningful_migration_name.sql` which you should `git add`.
25-
10. You can start using your changes again `turbo dev`
26+
7. `turbo build`, which will do the following:
27+
1. Start supbase
28+
2. Apply the new migration locally
29+
3. Regenerate the types file with `supabase gen types typescript --local > types.gen.ts`
30+
4. Copy it where appropriate
31+
8. You can start using your changes again `turbo dev`

packages/database/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
"init": "supabase login",
1212
"dev": "supabase start",
1313
"stop": "supabase stop",
14-
"build": "npm run lint && npm run gentypes:local && cp ./types.gen.ts ../../apps/website/app/utils/supabase && npm run dbdiff",
14+
"check-types": "npm run lint && supabase stop && npm run dbdiff",
1515
"lint": "tsx scripts/lint.ts",
1616
"lint:fix": "tsx scripts/lint.ts -f",
17-
"gentypes:local": "supabase start && supabase gen types typescript --local --schema public > types.gen.ts",
17+
"build": "supabase start && supabase migrations up && supabase gen types typescript --local --schema public > types.gen.ts && && cp ./types.gen.ts ../../apps/website/app/utils/supabase",
1818
"gentypes:production": "supabase start && supabase gen types typescript --project-id \"$SUPABASE_PROJECT_ID\" --schema public > types.gen.ts",
1919
"dbdiff": "supabase stop && supabase db diff",
2020
"dbdiff:save": "supabase stop && supabase db diff -f",

0 commit comments

Comments
 (0)