Skip to content

Commit

Permalink
Migrated db and added records to it
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhruva-K committed Sep 7, 2024
1 parent fc05e6a commit 8e614c8
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 9 deletions.
2 changes: 2 additions & 0 deletions app/models/movie.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Movie < ActiveRecord::Base
end
13 changes: 13 additions & 0 deletions db/migrate/20240907201834_create_movies.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class CreateMovies < ActiveRecord::Migration[7.0]
def change
create_table 'movies' do |t|
t.string 'title'
t.string 'rating'
t.text 'description'
t.datetime 'release_date'
# Add fields that let Rails automatically keep track
# of when movies are added or modified:
t.timestamps
end
end
end
22 changes: 22 additions & 0 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 17 additions & 9 deletions db/seeds.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
# This file should ensure the existence of records required to run the application in every environment (production,
# development, test). The code here should be idempotent so that it can be executed at any point in every environment.
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
#
# Example:
#
# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name|
# MovieGenre.find_or_create_by!(name: genre_name)
# end
# Seed the RottenPotatoes DB with some movies.
more_movies = [
{ title: 'My Neighbor Totoro', rating: 'G',
release_date: '16-Apr-1988' },
{ title: 'Green Book', rating: 'PG-13',
release_date: '16-Nov-2018' },
{ title: 'Parasite', rating: 'R',
release_date: '30-May-2019' },
{ title: 'Nomadland', rating: 'R',
release_date: '19-Feb-2021' },
{ title: 'CODA', rating: 'PG-13',
release_date: '13-Aug-2021' }
]

more_movies.each do |movie|
Movie.create!(movie)
end

0 comments on commit 8e614c8

Please sign in to comment.