-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
84 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
class FixFootnotesIndexes < ActiveRecord::Migration | ||
def change | ||
change_table :usda_footnotes do |t| | ||
t.remove_index :nutrient_databank_number | ||
t.remove_index :footnote_number | ||
t.remove_index :footnote_type | ||
t.remove_index :nutrient_number | ||
|
||
t.index [ | ||
:nutrient_databank_number, | ||
:nutrient_number, | ||
:footnote_number | ||
], { | ||
unique: true, | ||
name: "index_usda_footnotes_on_unique_keys" | ||
} | ||
|
||
t.index [ | ||
:nutrient_databank_number, | ||
:footnote_type | ||
], { | ||
name: "index_usda_footnotes_on_databank_number_and_type" | ||
} | ||
end | ||
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,16 @@ | ||
class FixUsdaWeights < ActiveRecord::Migration | ||
def change | ||
remove_column :usda_weights, :id | ||
|
||
change_table :usda_weights do |t| | ||
t.remove_index :nutrient_databank_number | ||
|
||
t.index [ | ||
:nutrient_databank_number, | ||
:sequence_number | ||
], { | ||
unique: true | ||
} | ||
end | ||
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,12 @@ | ||
class FixUsdaFoodsNutrients < ActiveRecord::Migration | ||
def change | ||
remove_column :usda_foods_nutrients, :id | ||
|
||
change_table :usda_foods_nutrients do |t| | ||
t.remove_index [ | ||
:nutrient_databank_number, | ||
:nutrient_number | ||
] | ||
end | ||
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
require 'spec_helper' | ||
|
||
describe UsdaNutrientDatabase::FoodGroup do | ||
describe UsdaNutrientDatabase::FoodGroup, type: :model do | ||
it { should validate_presence_of(:code) } | ||
it { should validate_presence_of(:description) } | ||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
require 'spec_helper' | ||
|
||
describe UsdaNutrientDatabase::Footnote do | ||
it { should validate_presence_of(:nutrient_databank_number) } | ||
it { should validate_presence_of(:footnote_number) } | ||
it { should validate_presence_of(:footnote_type) } | ||
it { should validate_presence_of(:footnote_text) } | ||
describe UsdaNutrientDatabase::Footnote, type: :model do | ||
# it 'validates uniqueness of nutrient_databank_number' do | ||
# expect(subject) | ||
# .to validate_uniqueness_of(:nutrient_databank_number) | ||
# .scoped_to(:footnote_number, :nutrient_number) | ||
# end | ||
it { is_expected.to validate_presence_of(:footnote_number) } | ||
it { is_expected.to validate_presence_of(:footnote_type) } | ||
it { is_expected.to validate_presence_of(:footnote_text) } | ||
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
require 'spec_helper' | ||
|
||
describe UsdaNutrientDatabase::SourceCode do | ||
describe UsdaNutrientDatabase::SourceCode, type: :model do | ||
it { validate_presence_of(:code) } | ||
it { validate_presence_of(:description) } | ||
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
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