# it appears that execute will only accept string arguments, so
# this is an ugly, ugly hack to get some sort of mysql/postgres
# independence. now i have to go wash my brain with bleach.
- execute("update changesets set closed_at=(now()-'1 hour') where open=(1=0)")
- execute("update changesets set closed_at=(now()+'1 hour') where open=(1=1)")
+ execute("update changesets set closed_at=(now()-#{interval_constant('1 hour')}) where open=(1=0)")
+ execute("update changesets set closed_at=(now()+#{interval_constant('1 hour')}) where open=(1=1)")
# remove the open column as it is unnecessary now and denormalises
# the table.
def alter_primary_key(table_name, new_columns)
execute("alter table #{table_name} drop primary key, add primary key (#{new_columns.join(',')})")
end
+
+ def interval_constant(interval)
+ "'#{interval}'"
+ end
end
class PostgreSQLAdapter
def alter_primary_key(table_name, new_columns)
execute "alter table #{table_name} drop constraint #{table_name}_pkey; alter table #{table_name} add primary key (#{new_columns.join(',')})"
end
+
+ def interval_constant(interval)
+ "'#{interval}'::interval"
+ end
end
end
end