From 4883b21b30d14ea888ba5595ddf618147a205f3d Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Wed, 10 Mar 2021 14:27:11 +0500 Subject: [PATCH] Add model Profile --- app/models/profile.rb | 2 ++ db/migrate/20210310092513_create_profiles.rb | 10 +++++++++ db/schema.rb | 23 ++++++++++++++++++++ test/fixtures/profiles.yml | 11 ++++++++++ test/models/profile_test.rb | 7 ++++++ 5 files changed, 53 insertions(+) create mode 100644 app/models/profile.rb create mode 100644 db/migrate/20210310092513_create_profiles.rb create mode 100644 db/schema.rb create mode 100644 test/fixtures/profiles.yml create mode 100644 test/models/profile_test.rb diff --git a/app/models/profile.rb b/app/models/profile.rb new file mode 100644 index 0000000..8b5c14e --- /dev/null +++ b/app/models/profile.rb @@ -0,0 +1,2 @@ +class Profile < ApplicationRecord +end diff --git a/db/migrate/20210310092513_create_profiles.rb b/db/migrate/20210310092513_create_profiles.rb new file mode 100644 index 0000000..0fd3f5d --- /dev/null +++ b/db/migrate/20210310092513_create_profiles.rb @@ -0,0 +1,10 @@ +class CreateProfiles < ActiveRecord::Migration[6.1] + def change + create_table :profiles do |t| + t.timestamps + t.string :first_name + t.string :last_name + t.string :description + end + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..3b50af6 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,23 @@ +# 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.define(version: 2021_03_10_092513) do + + create_table "profiles", force: :cascade do |t| + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.string "first_name" + t.string "last_name" + t.string "description" + end + +end diff --git a/test/fixtures/profiles.yml b/test/fixtures/profiles.yml new file mode 100644 index 0000000..c0e2a96 --- /dev/null +++ b/test/fixtures/profiles.yml @@ -0,0 +1,11 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + first_name: Alex + last_name: Kotov + description: Founder + +two: + first_name: Oleg + last_name: Ivanov + description: Guy diff --git a/test/models/profile_test.rb b/test/models/profile_test.rb new file mode 100644 index 0000000..701636f --- /dev/null +++ b/test/models/profile_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class ProfileTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end