Skip to content

Commit

Permalink
Reference between movies and directors.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalimaha committed Apr 14, 2016
1 parent 00b454c commit ea2edc3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
Binary file modified db/development.sqlite3
Binary file not shown.
5 changes: 5 additions & 0 deletions db/migrate/20160414053806_add_director_id_to_movies.rb
@@ -0,0 +1,5 @@
class AddDirectorIdToMovies < ActiveRecord::Migration
def change
add_reference :movies, :director, index: true, foreign_key: true
end
end
9 changes: 6 additions & 3 deletions db/schema.rb
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160414052838) do
ActiveRecord::Schema.define(version: 20160414053806) do

create_table "directors", force: :cascade do |t|
t.string "first_name"
Expand All @@ -25,8 +25,11 @@
t.string "title"
t.integer "year"
t.text "synopsis"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "director_id"
end

add_index "movies", ["director_id"], name: "index_movies_on_director_id"

end
17 changes: 17 additions & 0 deletions log/development.log
Expand Up @@ -1514,3 +1514,20 @@ Migrating to CreateDirectors (20160414052838)
SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20160414052838"]]
 (1.6ms) commit transaction
ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
ActiveRecord::SchemaMigration Load (1.8ms) SELECT "schema_migrations".* FROM "schema_migrations"
Migrating to AddDirectorIdToMovies (20160414053806)
 (0.1ms) begin transaction
 (0.6ms) ALTER TABLE "movies" ADD "director_id" integer
 (0.1ms) select sqlite_version(*)
 (0.4ms) CREATE INDEX "index_movies_on_director_id" ON "movies" ("director_id")
SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20160414053806"]]
 (0.8ms) commit transaction
ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
 (0.2ms)  SELECT sql
FROM sqlite_master
WHERE name='index_movies_on_director_id' AND type='index'
UNION ALL
SELECT sql
FROM sqlite_temp_master
WHERE name='index_movies_on_director_id' AND type='index'


0 comments on commit ea2edc3

Please sign in to comment.