From 2bcffc2698b0282edca5f34e5fc740a0cd63b5f1 Mon Sep 17 00:00:00 2001 From: LaRita Robinson Date: Fri, 15 Dec 2023 17:25:19 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9Database=20migration=20&=20schema?= =?UTF-8?q?=20update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For table hyrax_counter_metrics --- ...5705_create_hyrax_counter_metrics.hyrax.rb | 14 +++++++++++++ ...15215706_change_work_id_to_string.hyrax.rb | 5 +++++ ..._indices_to_hyrax_counter_metrics.hyrax.rb | 8 +++++++ ...5708_add_fields_to_counter_metric.hyrax.rb | 8 +++++++ db/schema.rb | 21 ++++++++++++++++++- 5 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20231215215705_create_hyrax_counter_metrics.hyrax.rb create mode 100644 db/migrate/20231215215706_change_work_id_to_string.hyrax.rb create mode 100644 db/migrate/20231215215707_add_indices_to_hyrax_counter_metrics.hyrax.rb create mode 100644 db/migrate/20231215215708_add_fields_to_counter_metric.hyrax.rb diff --git a/db/migrate/20231215215705_create_hyrax_counter_metrics.hyrax.rb b/db/migrate/20231215215705_create_hyrax_counter_metrics.hyrax.rb new file mode 100644 index 000000000..80caf88c1 --- /dev/null +++ b/db/migrate/20231215215705_create_hyrax_counter_metrics.hyrax.rb @@ -0,0 +1,14 @@ +class CreateHyraxCounterMetrics < ActiveRecord::Migration[6.1] + def change + create_table :hyrax_counter_metrics do |t| + t.string :worktype + t.string :resource_type + t.integer :work_id + t.date :date + t.integer :total_item_investigations + t.integer :total_item_requests + + t.timestamps + end + end +end diff --git a/db/migrate/20231215215706_change_work_id_to_string.hyrax.rb b/db/migrate/20231215215706_change_work_id_to_string.hyrax.rb new file mode 100644 index 000000000..1cdb92a36 --- /dev/null +++ b/db/migrate/20231215215706_change_work_id_to_string.hyrax.rb @@ -0,0 +1,5 @@ +class ChangeWorkIdToString < ActiveRecord::Migration[6.1] + def change + change_column :hyrax_counter_metrics, :work_id, :string + end +end diff --git a/db/migrate/20231215215707_add_indices_to_hyrax_counter_metrics.hyrax.rb b/db/migrate/20231215215707_add_indices_to_hyrax_counter_metrics.hyrax.rb new file mode 100644 index 000000000..b71e0977b --- /dev/null +++ b/db/migrate/20231215215707_add_indices_to_hyrax_counter_metrics.hyrax.rb @@ -0,0 +1,8 @@ +class AddIndicesToHyraxCounterMetrics < ActiveRecord::Migration[6.1] + def change + add_index :hyrax_counter_metrics, :worktype + add_index :hyrax_counter_metrics, :resource_type + add_index :hyrax_counter_metrics, :work_id + add_index :hyrax_counter_metrics, :date + end +end diff --git a/db/migrate/20231215215708_add_fields_to_counter_metric.hyrax.rb b/db/migrate/20231215215708_add_fields_to_counter_metric.hyrax.rb new file mode 100644 index 000000000..7b2ec02fa --- /dev/null +++ b/db/migrate/20231215215708_add_fields_to_counter_metric.hyrax.rb @@ -0,0 +1,8 @@ +class AddFieldsToCounterMetric < ActiveRecord::Migration[6.1] + def change + add_column :hyrax_counter_metrics, :title, :string + add_column :hyrax_counter_metrics, :year_of_publication, :integer, index: true + add_column :hyrax_counter_metrics, :publisher, :string, index: true + add_column :hyrax_counter_metrics, :author, :string, index: true + end +end diff --git a/db/schema.rb b/db/schema.rb index f65809e9f..7d5629751 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2023_08_04_073106) do +ActiveRecord::Schema.define(version: 2023_12_15_215708) do # These are extensions that must be enabled in order to support this database enable_extension "hstore" @@ -372,6 +372,25 @@ t.index ["machine_id"], name: "index_hyrax_collection_types_on_machine_id", unique: true end + create_table "hyrax_counter_metrics", force: :cascade do |t| + t.string "worktype" + t.string "resource_type" + t.string "work_id" + t.date "date" + t.integer "total_item_investigations" + t.integer "total_item_requests" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.string "title" + t.integer "year_of_publication" + t.string "publisher" + t.string "author" + t.index ["date"], name: "index_hyrax_counter_metrics_on_date" + t.index ["resource_type"], name: "index_hyrax_counter_metrics_on_resource_type" + t.index ["work_id"], name: "index_hyrax_counter_metrics_on_work_id" + t.index ["worktype"], name: "index_hyrax_counter_metrics_on_worktype" + end + create_table "hyrax_default_administrative_set", force: :cascade do |t| t.string "default_admin_set_id", null: false t.datetime "created_at", null: false