This repository was archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
internal/db: do not run TimescaleDB migrations against singleton database #17585
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
600a856
internal/db: do not run TimescaleDB migrations against singleton data…
2263427
internal/database: make "single database" usage explicit
701851a
update MigrateDB callers (+ more type safety)
e44e1b2
fixup
54b2835
fix DB names (caught by test)
306c5d4
Merge remote-tracking branch 'origin/main' into sg/insights-dbtesting
609cbb8
Merge remote-tracking branch 'origin/main' into sg/insights-dbtesting
5fb7f14
fix typo
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,9 +97,8 @@ func emptyDBPreserveSchema(t testing.TB, d *sql.DB) { | |
| } | ||
|
|
||
| var conds []string | ||
| for _, migrationTable := range dbconn.MigrationTables { | ||
| conds = append(conds, fmt.Sprintf("table_name != '%s'", migrationTable)) | ||
| } | ||
| conds = append(conds, fmt.Sprintf("table_name != '%s'", dbconn.Frontend.MigrationsTable)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lol but what if code intel wants a legit table named |
||
| conds = append(conds, fmt.Sprintf("table_name != '%s'", dbconn.CodeIntel.MigrationsTable)) | ||
|
|
||
| rows, err := d.Query("SELECT table_name FROM information_schema.tables WHERE table_schema='public' AND table_type='BASE TABLE' AND " + strings.Join(conds, " AND ")) | ||
| if err != nil { | ||
|
|
@@ -159,8 +158,11 @@ func initTest(nameSuffix string) error { | |
| return err | ||
| } | ||
|
|
||
| for _, databaseName := range dbconn.DatabaseNames { | ||
| if err := dbconn.MigrateDB(dbconn.Global, databaseName); err != nil { | ||
| for _, database := range []*dbconn.Database{ | ||
| dbconn.Frontend, | ||
| dbconn.CodeIntel, | ||
| } { | ||
| if err := dbconn.MigrateDB(dbconn.Global, database); err != nil { | ||
| return err | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Still using a few lists like this in some places to use "the same DB for frontend and codeintel" but I will start fixing that in subsequent PRs where I aim to add code-insights-equivilents to these locations.
For now, it at least makes this "we use multiple DBs here which is kinda clunky" clear & explicit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think this is worlds better than tacking a third one on and doing retroactive edge case fixes.