From 2b32a88a8e9f1d0bb5055843ac987d9cb9981803 Mon Sep 17 00:00:00 2001 From: David Gay Date: Sun, 2 May 2021 20:21:04 -0400 Subject: Add Activities --- db/migrate/20210503001859_create_activities.rb | 12 ++++++++++++ db/schema.rb | 11 ++++++++++- db/seeds.rb | 5 +++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20210503001859_create_activities.rb (limited to 'db') diff --git a/db/migrate/20210503001859_create_activities.rb b/db/migrate/20210503001859_create_activities.rb new file mode 100644 index 0000000..883d82a --- /dev/null +++ b/db/migrate/20210503001859_create_activities.rb @@ -0,0 +1,12 @@ +class CreateActivities < ActiveRecord::Migration[6.1] + def change + create_table :activities do |t| + t.string :gid + t.string :name + t.text :description + t.jsonb :whatnot + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 67fd0f5..85aa952 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,11 +10,20 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_05_02_212517) do +ActiveRecord::Schema.define(version: 2021_05_03_001859) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" + create_table "activities", force: :cascade do |t| + t.string "gid" + t.string "name" + t.text "description" + t.jsonb "whatnot" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + create_table "items", force: :cascade do |t| t.string "gid" t.string "name" diff --git a/db/seeds.rb b/db/seeds.rb index 2008d89..00a0566 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -24,3 +24,8 @@ load_data_file("data/items.yml").map do |gid, hash| item.whatnot = hash[:whatnot] item.save end + +load_data_file("data/activities.yml").map do |gid, hash| + activity = Activity.find_or_create_by(gid: gid) + activity.update(hash) +end -- cgit v1.2.3