I have a PostGres 9.4 database. I want to change the default column type of a DATETIME column to be the time when the record was created. I thought this was the right way, in as far as this is my rails migration
class ChangeDefaultValueForStratumWorkerSubmissions < ActiveRecord::Migration[5.1]
def change
change_column_default(:stratum_worker_submissions, :created_at, 'NOW')
end
end
but when I look at my database, the default timestamp shows as the time when I ran the migration, instead of the expression I want. How do I write a migration that will do what I want?
Column | Type | Modifiers
-------------------+-----------------------------+----------------------------------------------------------------------------
id | integer | not null default nextval('stratum_worker_submissions_id_seq'::regclass)
stratum_worker_id | integer |
created_at | timestamp without time zone | not null default '2018-04-04 19:46:22.781613'::timestamp without time zone