-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Look at database consistency issues (#1189)
* Lets push these changes out! * Only one annoucment can be live at a time, so add a index. * lint
- Loading branch information
Showing
13 changed files
with
95 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
14 changes: 14 additions & 0 deletions
14
db/migrate/20250118223041_add_unique_index_to_web_requests_snapshot_query_id.rb
This file contains 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Loaded configurations: .database_consistency.yml, .database_consistency.todo.yml | ||
# UniqueIndexChecker fail Score index_case_scores_annotation_id index is unique in the database but do not have uniqueness validator | ||
# LengthConstraintChecker fail User system_prompt column has limit in the database but do not have length validator | ||
# LengthConstraintChecker fail User openai_key column has limit in the database but do not have length validator | ||
# ForeignKeyChecker fail WebRequest snapshot_query should have foreign key in the database | ||
# MissingIndexChecker fail SnapshotQuery web_request associated model should have proper unique index in the database | ||
|
||
class AddUniqueIndexToWebRequestsSnapshotQueryId < ActiveRecord::Migration[8.0] | ||
def change | ||
remove_index :web_requests, :snapshot_query_id if index_exists?(:web_requests, :snapshot_query_id) | ||
add_index :web_requests, :snapshot_query_id, unique: true | ||
add_foreign_key :web_requests, :snapshot_queries | ||
end | ||
end |
This file contains 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# RedundantIndexChecker fail Case user_id index is redundant as idx_owner_archived covers it | ||
|
||
class RefineStructure < ActiveRecord::Migration[8.0] | ||
def change | ||
if index_exists?(:cases, [:user_id, :archived], name: 'idx_owner_archived') | ||
remove_index :cases, :user_id if index_exists?(:cases, :user_id) | ||
end | ||
|
||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
db/migrate/20250119123525_add_users_id_users_invited_by_id_fk.rb
This file contains 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddUsersIdUsersInvitedByIdFk < ActiveRecord::Migration[8.0] | ||
def change | ||
add_foreign_key :users, :users, column: :invited_by_id, primary_key: :id | ||
end | ||
end |
This file contains 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddAnnouncementsLiveIndex < ActiveRecord::Migration[8.0] | ||
def change | ||
add_index :announcements, :live, name: :index_announcements_live, unique: true | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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 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