From 7997e112fbc67eef309bb3969ad41f90a8bfbc89 Mon Sep 17 00:00:00 2001 From: David Gay Date: Sun, 2 May 2021 16:15:55 -0400 Subject: Add skills --- db/migrate/20210502200959_create_skills.rb | 11 +++++++++++ db/schema.rb | 10 +++++++++- db/seeds.rb | 9 +++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20210502200959_create_skills.rb (limited to 'db') diff --git a/db/migrate/20210502200959_create_skills.rb b/db/migrate/20210502200959_create_skills.rb new file mode 100644 index 0000000..dbe3d3e --- /dev/null +++ b/db/migrate/20210502200959_create_skills.rb @@ -0,0 +1,11 @@ +class CreateSkills < ActiveRecord::Migration[6.1] + def change + create_table :skills do |t| + t.string :gid + t.string :name + t.text :description + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 6f2579f..5fc0f94 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,11 +10,19 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_04_22_014607) do +ActiveRecord::Schema.define(version: 2021_05_02_200959) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" + create_table "skills", force: :cascade do |t| + t.string "gid" + t.string "name" + t.text "description" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + create_table "users", force: :cascade do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false diff --git a/db/seeds.rb b/db/seeds.rb index f3a0480..637a355 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -5,3 +5,12 @@ # # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # Character.create(name: 'Luke', movie: movies.first) + +def load_data_file(path) + YAML.load(File.read(path)).deep_transform_keys(&:to_sym) +end + +load_data_file("data/skills.yml").map do |gid, hash| + skill = Skill.find_or_create_by(gid: gid) + skill.update(hash) +end -- cgit v1.2.3