Merge pull request #2180 from consul/polls-timestamps

Adds timestamps to polls
This commit is contained in:
BertoCQ
2017-12-14 14:14:47 +01:00
committed by GitHub
3 changed files with 14 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
class AddTimestampsToPolls < ActiveRecord::Migration
def change
add_timestamps :polls, null: true
end
end

View File

@@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # 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 # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@@ -798,6 +798,8 @@ ActiveRecord::Schema.define(version: 20171127230716) do
t.datetime "hidden_at" t.datetime "hidden_at"
t.boolean "results_enabled", default: false t.boolean "results_enabled", default: false
t.boolean "stats_enabled", default: false t.boolean "stats_enabled", default: false
t.datetime "created_at"
t.datetime "updated_at"
end end
add_index "polls", ["starts_at", "ends_at"], name: "index_polls_on_starts_at_and_ends_at", using: :btree 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
View 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