luckyframework/avram

Adding ensure UTC default to DB with config option

Offen

#732 geöffnet am 23.09.2021

 (3 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Crystal (67 Forks)auto 404
feature requesthacktoberfest

Repository-Metriken

Stars
 (180 Sterne)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

When you create a new DB, postgres seems to set the timezone to the host machine by default. This could lead to some odd behavior, especially in development, where your local DB is in PST, but your production DB is in UTC.

Postgres allows you to set this timezone at the session, DB, and global levels. What we could do is add some SQL to set this when you first create your DB:

execute <<-SQL
alter database #{Avram::Migrator::Runner.db_name} set time zone '#{Avram.settings.default_timezone}';
SQL

By default we could have a habitat setting default_timezone that's UTC. Then if you wanted to change this, you could. If you inherit a DB, then this would never affect you since you'd never run the create task.

Contributor Guide