Skip to content

Commit 5271543

Browse files
authored
Merge pull request #174 from DiscourseGraphs/ENG-328-forgot-a-step
ENG-328 forgot a step to apply migrations locally
2 parents 3eb8b7f + 4e3dbb3 commit 5271543

3 files changed

Lines changed: 70 additions & 58 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",

packages/database/types.gen.ts

Lines changed: 58 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export type Database = {
4343
foreignKeyName: "Account_platform_id_fkey"
4444
columns: ["platform_id"]
4545
isOneToOne: false
46-
referencedRelation: "DiscoursePlatform"
46+
referencedRelation: "Platform"
4747
referencedColumns: ["id"]
4848
},
4949
]
@@ -167,7 +167,7 @@ export type Database = {
167167
foreignKeyName: "Concept_space_id_fkey"
168168
columns: ["space_id"]
169169
isOneToOne: false
170-
referencedRelation: "DiscourseSpace"
170+
referencedRelation: "Space"
171171
referencedColumns: ["id"]
172172
},
173173
]
@@ -278,7 +278,7 @@ export type Database = {
278278
foreignKeyName: "Content_space_id_fkey"
279279
columns: ["space_id"]
280280
isOneToOne: false
281-
referencedRelation: "DiscourseSpace"
281+
referencedRelation: "Space"
282282
referencedColumns: ["id"]
283283
},
284284
]
@@ -342,53 +342,6 @@ export type Database = {
342342
},
343343
]
344344
}
345-
DiscoursePlatform: {
346-
Row: {
347-
id: number
348-
name: string
349-
url: string
350-
}
351-
Insert: {
352-
id?: number
353-
name: string
354-
url: string
355-
}
356-
Update: {
357-
id?: number
358-
name?: string
359-
url?: string
360-
}
361-
Relationships: []
362-
}
363-
DiscourseSpace: {
364-
Row: {
365-
discourse_platform_id: number
366-
id: number
367-
name: string
368-
url: string | null
369-
}
370-
Insert: {
371-
discourse_platform_id: number
372-
id?: number
373-
name: string
374-
url?: string | null
375-
}
376-
Update: {
377-
discourse_platform_id?: number
378-
id?: number
379-
name?: string
380-
url?: string | null
381-
}
382-
Relationships: [
383-
{
384-
foreignKeyName: "DiscourseSpace_discourse_platform_id_fkey"
385-
columns: ["discourse_platform_id"]
386-
isOneToOne: false
387-
referencedRelation: "DiscoursePlatform"
388-
referencedColumns: ["id"]
389-
},
390-
]
391-
}
392345
Document: {
393346
Row: {
394347
author_id: number
@@ -435,7 +388,7 @@ export type Database = {
435388
foreignKeyName: "Document_space_id_fkey"
436389
columns: ["space_id"]
437390
isOneToOne: false
438-
referencedRelation: "DiscourseSpace"
391+
referencedRelation: "Space"
439392
referencedColumns: ["id"]
440393
},
441394
]
@@ -469,6 +422,53 @@ export type Database = {
469422
},
470423
]
471424
}
425+
Platform: {
426+
Row: {
427+
id: number
428+
name: string
429+
url: string
430+
}
431+
Insert: {
432+
id?: number
433+
name: string
434+
url: string
435+
}
436+
Update: {
437+
id?: number
438+
name?: string
439+
url?: string
440+
}
441+
Relationships: []
442+
}
443+
Space: {
444+
Row: {
445+
id: number
446+
name: string
447+
platform_id: number
448+
url: string | null
449+
}
450+
Insert: {
451+
id?: number
452+
name: string
453+
platform_id: number
454+
url?: string | null
455+
}
456+
Update: {
457+
id?: number
458+
name?: string
459+
platform_id?: number
460+
url?: string | null
461+
}
462+
Relationships: [
463+
{
464+
foreignKeyName: "Space_platform_id_fkey"
465+
columns: ["platform_id"]
466+
isOneToOne: false
467+
referencedRelation: "Platform"
468+
referencedColumns: ["id"]
469+
},
470+
]
471+
}
472472
SpaceAccess: {
473473
Row: {
474474
account_id: number
@@ -500,7 +500,7 @@ export type Database = {
500500
foreignKeyName: "SpaceAccess_space_id_fkey"
501501
columns: ["space_id"]
502502
isOneToOne: false
503-
referencedRelation: "DiscourseSpace"
503+
referencedRelation: "Space"
504504
referencedColumns: ["id"]
505505
},
506506
]
@@ -555,6 +555,12 @@ export type Database = {
555555
}
556556
Returns: undefined
557557
}
558+
get_nodes_needing_sync: {
559+
Args: { nodes_from_roam: Json }
560+
Returns: {
561+
uid_to_sync: string
562+
}[]
563+
}
558564
match_content_embeddings: {
559565
Args: {
560566
query_embedding: string

0 commit comments

Comments
 (0)