Commit 0d23da4
authored
## Description
This PR fixes issue #409 where the rails generate ruby_llm:install
generator creates migrations with foreign key references to tables that
haven't been created yet, causing migration failures.
## Problem
When running the install generator on a fresh Rails application, the
generated migrations contain t.references calls that try to create
foreign key constraints to tables that are created in later migrations.
This causes PostgreSQL (and other databases) to fail with "relation does
not exist" errors because the referenced tables haven't been created
yet.
## Solution
1. Removes the t.references lines from the initial table creation
migrations
2. Creates a new migration that runs after all tables are created to add
the foreign key references.
This can be tested with a brand new rails app by adding the gem from
this branch:
`gem "ruby_llm", git: "https://github.com/matiasmoya/ruby_llm", branch:
"409-fix-install-migrations"`
## What this does
- Remove t.reference calls from initial table creation migrations
- Add new migration generator template for adding references separately
- Update install generator to create tables first, then add references
## Type of change
- [x] Bug fix
## Scope check
- [x] I read the [Contributing
Guide](https://github.com/crmne/ruby_llm/blob/main/CONTRIBUTING.md)
- [x] This aligns with RubyLLM's focus on **LLM communication**
- [x] This isn't application-specific logic that belongs in user code
- [x] This benefits most users, not just my specific use case
## Quality check
- [x] I ran `overcommit --install` and all hooks pass
- [x] I tested my changes thoroughly
- [x] For provider changes: Re-recorded VCR cassettes with `bundle exec
rake vcr:record[provider_name]`
- [x] All tests pass: `bundle exec rspec`
- [x] I updated documentation if needed
- [x] I didn't modify auto-generated files manually (`models.json`,
`aliases.json`)
## API changes
- [x] No API changes
## Related issues
Fixes #409
1 parent fa10f0c commit 0d23da4
File tree
6 files changed
+63
-19
lines changed- lib/generators/ruby_llm/install
- templates
- spec/lib/generators/ruby_llm
6 files changed
+63
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
49 | 55 | | |
50 | 56 | | |
51 | 57 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
| |||
Lines changed: 0 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
7 | | - | |
8 | 6 | | |
9 | 7 | | |
10 | | - | |
11 | 8 | | |
12 | 9 | | |
13 | 10 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | 35 | | |
39 | 36 | | |
40 | 37 | | |
| |||
44 | 41 | | |
45 | 42 | | |
46 | 43 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | 44 | | |
52 | 45 | | |
53 | 46 | | |
| |||
72 | 65 | | |
73 | 66 | | |
74 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
75 | 101 | | |
76 | 102 | | |
77 | 103 | | |
| |||
257 | 283 | | |
258 | 284 | | |
259 | 285 | | |
260 | | - | |
| 286 | + | |
261 | 287 | | |
262 | | - | |
263 | | - | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
264 | 298 | | |
265 | 299 | | |
266 | 300 | | |
| |||
0 commit comments