Skip to content

Commit

Permalink
Generate movies model and add two migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
ImsirovicAjdin committed Dec 24, 2019
1 parent bbc9770 commit d2858a5
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/models/movie.rb
@@ -0,0 +1,2 @@
class Movie < ApplicationRecord
end
15 changes: 15 additions & 0 deletions db/migrate/20191224161645_create_movies.rb
@@ -0,0 +1,15 @@
class CreateMovies < ActiveRecord::Migration[6.0]
def up
create_table :movies do |t|
t.column "title", :string, :limit => 150
t.column "description", :string, :limit => 300
t.column "rating", :integer, :limit => 5
t.timestamps
end
end

def down
drop_table :movies
end

end
4 changes: 4 additions & 0 deletions db/migrate/20191224205624_change_movies.rb
@@ -0,0 +1,4 @@
class ChangeMovies < ActiveRecord::Migration[6.0]
def change
end
end
10 changes: 9 additions & 1 deletion db/schema.rb
Expand Up @@ -10,9 +10,17 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.


ActiveRecord::Schema.define(version: 0) do ActiveRecord::Schema.define(version: 2019_12_24_161645) do


# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"


create_table "movies", force: :cascade do |t|
t.string "title", limit: 150
t.string "description", limit: 300
t.bigint "rating"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end

end end
11 changes: 11 additions & 0 deletions test/fixtures/movies.yml
@@ -0,0 +1,11 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

# This model initially had no columns defined. If you add columns to the
# model remove the '{}' from the fixture names and add the columns immediately
# below each fixture, per the syntax in the comments below
#
one: {}
# column: value
#
two: {}
# column: value
7 changes: 7 additions & 0 deletions test/models/movie_test.rb
@@ -0,0 +1,7 @@
require 'test_helper'

class MovieTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

0 comments on commit d2858a5

Please sign in to comment.