Permalink
Browse files

always use UTC for created_at

  • Loading branch information...
1 parent 3e74405 commit e9645c89f3e67d8bf339d4aed6ad4ff21a1f11f4 @DerGuteMoritz DerGuteMoritz committed Dec 6, 2010
Showing with 3 additions and 3 deletions.
  1. +1 −1 README.md
  2. +2 −2 lib/salesforce_sync/database.rb
View
@@ -12,7 +12,7 @@ following statements:
ALTER TABLE _salesforce_syncs RENAME COLUMN started_at TO timestamp;
ALTER TABLE _salesforce_syncs ADD COLUMN created_at TIMESTAMP;
- UPDATE _salesforce_syncs SET created_at = (SELECT statement_timestamp() - (interval '1 hour' * ((SELECT MAX(id) FROM _salesforce_syncs LIMIT 1) - id)));
+ UPDATE _salesforce_syncs SET created_at = (SELECT statement_timestamp() AT TIME ZONE 'UTC' - (interval '1 hour' * ((SELECT MAX(id) FROM _salesforce_syncs LIMIT 1) - id)));
## Copyright
@@ -64,12 +64,12 @@ def last_sync_for(object)
end
def insert_sync_timestamp(object, timestamp)
- db.insert('INSERT INTO %s (object, timestamp, created_at) VALUES (%s, %s, statement_timestamp())' %
+ db.insert("INSERT INTO %s (object, timestamp, created_at) VALUES (%s, %s, statement_timestamp() AT TIME ZONE 'UTC')" %
[syncs_table, db.quote(object), db.quote(timestamp)])
end
def clean_syncs_table(days)
- db.delete("DELETE FROM %s WHERE created_at < statement_timestamp() - interval '%i days'" %
+ db.delete("DELETE FROM %s WHERE created_at < statement_timestamp() AT TIME ZONE 'UTC' - interval '%i days'" %
[syncs_table, db.quote(days)])
end

0 comments on commit e9645c8

Please sign in to comment.