Add timestamps to broadcasts (#8181)
* Add timestamps to broadcasts * Update schema version
This commit is contained in:
parent
552c581412
commit
70dc2429bc
3 changed files with 23 additions and 1 deletions
|
|
@ -0,0 +1,7 @@
|
|||
class AddTimestampsToBroadcasts < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
# NOTE: we need to have nullable timestamps as the table is already
|
||||
# populated. Will remove the NULL clause when data is safely backfilled
|
||||
add_timestamps(:broadcasts, null: true)
|
||||
end
|
||||
end
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2020_05_26_151807) do
|
||||
ActiveRecord::Schema.define(version: 2020_05_30_084533) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
|
@ -268,9 +268,11 @@ ActiveRecord::Schema.define(version: 2020_05_26_151807) do
|
|||
create_table "broadcasts", id: :serial, force: :cascade do |t|
|
||||
t.boolean "active", default: false
|
||||
t.text "body_markdown"
|
||||
t.datetime "created_at"
|
||||
t.text "processed_html"
|
||||
t.string "title"
|
||||
t.string "type_of"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "buffer_updates", force: :cascade do |t|
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
module DataUpdateScripts
|
||||
class BackfillBroadcastsTimestamps
|
||||
def run
|
||||
# Broadcasts didn't have timestamps columns until
|
||||
# 20200530084533_add_timestamps_to_broadcasts was created, thus we can
|
||||
# safely assume that only those with `created_at IS NULL` need their
|
||||
# timestamps overridden
|
||||
Broadcast.where(created_at: nil).order(title: :asc).each do |cast|
|
||||
cast.update(created_at: Time.current, updated_at: Time.current)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue