Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setup relations in models + indexes on foreign keys
- Loading branch information
Showing
8 changed files
with
20 additions
and
0 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,2 +1,4 @@ | |||
class Checkout < ActiveRecord::Base | class Checkout < ActiveRecord::Base | ||
belongs_to :users | |||
belongs_to :medias | |||
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,2 +1,4 @@ | |||
class Downloads < ActiveRecord::Base | class Downloads < ActiveRecord::Base | ||
belongs_to :users | |||
belongs_to :medias | |||
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,2 +1,3 @@ | |||
class Item < ActiveRecord::Base | class Item < ActiveRecord::Base | ||
has_many :medias | |||
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,2 +1,5 @@ | |||
class Media < ActiveRecord::Base | class Media < ActiveRecord::Base | ||
belongs_to :items | |||
has_many :checkouts | |||
has_many :downloads | |||
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,2 +1,4 @@ | |||
class User < ActiveRecord::Base | class User < ActiveRecord::Base | ||
has_many :checkouts | |||
has_many :downloads | |||
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,9 +1,11 @@ | |||
class AddKeysToMedia < ActiveRecord::Migration | class AddKeysToMedia < ActiveRecord::Migration | ||
def self.up | def self.up | ||
add_column :medias, :item_id, :integer | add_column :medias, :item_id, :integer | ||
add_index :medias, :item_id | |||
end | end | ||
|
|
||
def self.down | def self.down | ||
remove_column :medias, :item_id | remove_column :medias, :item_id | ||
remove_index :medias, :item_id | |||
end | 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