diff --git a/db/migrate/20181015152049_microseconds_in_time_columns.rb b/db/migrate/20181015152049_microseconds_in_time_columns.rb new file mode 100644 index 000000000..0ec799a71 --- /dev/null +++ b/db/migrate/20181015152049_microseconds_in_time_columns.rb @@ -0,0 +1,17 @@ +class MicrosecondsInTimeColumns < ActiveRecord::Migration[5.2] + def up + change_column :dataset, :created, :datetime, limit: 3 + change_column :dataset, :updated, :datetime, limit: 3 + + add_column :dataset, :indexed, :datetime, limit: 3, default: '1970-01-01 00:00:00', null: false + add_index "dataset", ["created", "indexed", "updated"], name: "index_dataset_on_created_indexed_updated" + end + + def down + remove_index :dataset, column: ["created", "indexed", "updated"], name: "index_dataset_on_created_indexed_updated" + remove_column :dataset, :indexed + + change_column :dataset, :created, :datetime + change_column :dataset, :updated, :datetime + end +end diff --git a/db/schema.rb b/db/schema.rb index af601dfee..3993c1879 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: 2018_09_04_161700) do +ActiveRecord::Schema.define(version: 2018_10_15_152049) do create_table "active_storage_attachments", options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| t.string "name", limit: 191, null: false @@ -110,7 +110,7 @@ end create_table "dataset", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT", force: :cascade do |t| - t.datetime "created" + t.datetime "created", precision: 3 t.string "doi", null: false t.binary "is_active", limit: 1, null: false t.binary "is_ref_quality", limit: 1 @@ -118,7 +118,7 @@ t.datetime "last_landing_page_status_check" t.json "last_landing_page_status_result" t.string "last_metadata_status" - t.datetime "updated" + t.datetime "updated", precision: 3 t.integer "version" t.bigint "datacentre", null: false t.datetime "minted" @@ -128,7 +128,9 @@ t.string "aasm_state" t.string "reason" t.string "source", limit: 191 + t.datetime "indexed", precision: 3, default: "1970-01-01 00:00:00", null: false t.index ["aasm_state"], name: "index_dataset_on_aasm_state" + t.index ["created", "indexed", "updated"], name: "index_dataset_on_created_indexed_updated" t.index ["datacentre"], name: "FK5605B47847B5F5FF" t.index ["doi"], name: "doi", unique: true t.index ["last_landing_page_content_type"], name: "index_dataset_on_last_landing_page_content_type"