diff --git a/app/models/movie.rb b/app/models/movie.rb new file mode 100644 index 0000000..49198a7 --- /dev/null +++ b/app/models/movie.rb @@ -0,0 +1,2 @@ +class Movie < ActiveRecord::Base +end diff --git a/db/migrate/20240907201834_create_movies.rb b/db/migrate/20240907201834_create_movies.rb new file mode 100644 index 0000000..16f359a --- /dev/null +++ b/db/migrate/20240907201834_create_movies.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..7ff4ddb --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,22 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema[7.2].define(version: 2024_09_07_201834) do + create_table "movies", force: :cascade do |t| + t.string "title" + t.string "rating" + t.text "description" + t.datetime "release_date" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end +end diff --git a/db/seeds.rb b/db/seeds.rb index 4fbd6ed..62badca 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -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