Merge pull request #2180 from consul/polls-timestamps
Adds timestamps to polls
This commit is contained in:
5
db/migrate/20171212193323_add_timestamps_to_polls.rb
Normal file
5
db/migrate/20171212193323_add_timestamps_to_polls.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddTimestampsToPolls < ActiveRecord::Migration
|
||||
def change
|
||||
add_timestamps :polls, null: true
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20171127230716) do
|
||||
ActiveRecord::Schema.define(version: 20171212193323) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@@ -798,6 +798,8 @@ ActiveRecord::Schema.define(version: 20171127230716) do
|
||||
t.datetime "hidden_at"
|
||||
t.boolean "results_enabled", default: false
|
||||
t.boolean "stats_enabled", default: false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
add_index "polls", ["starts_at", "ends_at"], name: "index_polls_on_starts_at_and_ends_at", using: :btree
|
||||
|
||||
6
lib/tasks/polls.rake
Normal file
6
lib/tasks/polls.rake
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace :polls do
|
||||
desc "Adds created_at and updated_at values to existing polls"
|
||||
task initialize_timestamps: :environment do
|
||||
Poll.update_all(created_at: Time.current, updated_at: Time.current)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user