-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adjust data structure for movies / crews
- Loading branch information
Zack Siri
committed
May 1, 2015
1 parent
2fd7929
commit b92af6e
Showing
10 changed files
with
83 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
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,4 @@ | ||
class Role < ActiveRecord::Base | ||
belongs_to :movie | ||
belongs_to :crew | ||
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 @@ | ||
class AddFieldsToMovies < ActiveRecord::Migration | ||
def change | ||
add_column :movies, :country, :string | ||
add_column :movies, :year, :integer | ||
add_column :movies, :review, :float | ||
add_column :movies, :rating, :string | ||
add_column :movies, :runtime, :integer | ||
add_column :movies, :language, :string | ||
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,13 @@ | ||
class CreateRoles < ActiveRecord::Migration | ||
def change | ||
create_table :roles do |t| | ||
t.references :movie, index: true | ||
t.references :crew, index: true | ||
t.string :job | ||
|
||
t.timestamps null: false | ||
end | ||
add_foreign_key :roles, :movies | ||
add_foreign_key :roles, :crews | ||
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 DropCrewsMovies < ActiveRecord::Migration | ||
def change | ||
drop_table :crews_movies | ||
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 AddReleaseDateToMovies < ActiveRecord::Migration | ||
def change | ||
add_column :movies, :release_date, :date | ||
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,10 +1,15 @@ | ||
require 'thor' | ||
require File.expand_path('config/environment.rb') | ||
|
||
class Omdb < Thor | ||
def import | ||
movies = Sequel.connect('postgres://zacksiri@localhost:5432/omdb')[:movies] | ||
movies.each do |movie| | ||
|
||
Movie.create do |m| | ||
m.name = movie[:Title] | ||
m.synopsis = movie[:FullPlot] unless movie[:FullPlot] == 'N/A' | ||
m.year = | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
one: | ||
movie_id: | ||
crew_id: | ||
job: MyString | ||
|
||
two: | ||
movie_id: | ||
crew_id: | ||
job: MyString |
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,7 @@ | ||
require 'test_helper' | ||
|
||
class RoleTest < ActiveSupport::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |