Add created_at to event_log_states table

parent f1331073
# frozen_string_literal: true
class AddCreatedAtToEventLogStates < ActiveRecord::Migration[5.2]
DOWNTIME = false
def up
add_column(:event_log_states, :created_at, :datetime, null: true)
# There should only be 1 record in the event_log_states table
execute('UPDATE event_log_states SET created_at = (
SELECT COALESCE(
(SELECT project_registry.created_at
FROM project_registry
ORDER BY project_registry.id ASC
LIMIT 1), NOW()
)
)')
change_column_null(:event_log_states, :created_at, false)
end
def down
remove_column(:event_log_states, :created_at)
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2019_06_12_211021) do
ActiveRecord::Schema.define(version: 2019_08_02_200655) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......@@ -29,6 +29,7 @@ ActiveRecord::Schema.define(version: 2019_06_12_211021) do
end
create_table "event_log_states", primary_key: "event_id", force: :cascade do |t|
t.datetime "created_at", null: false
end
create_table "file_registry", id: :serial, force: :cascade do |t|
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment