Add timezone column to devices table
parent
303e1453a4
commit
55f9dab459
|
@ -2,6 +2,8 @@
|
|||
class Device < ActiveRecord::Base
|
||||
DEFAULT_MAX_LOGS = 50
|
||||
DEFAULT_MAX_IMAGES = 100
|
||||
TIMEZONES = ActiveSupport::TimeZone.all.map(&:to_s)
|
||||
|
||||
has_many :users
|
||||
has_many :farm_events, dependent: :destroy
|
||||
has_many :points, dependent: :destroy
|
||||
|
|
|
@ -7,6 +7,7 @@ module Devices
|
|||
end
|
||||
|
||||
optional do
|
||||
string :timezone, in: Device::TIMEZONES
|
||||
string :name
|
||||
string :webcam_url
|
||||
end
|
||||
|
@ -23,7 +24,7 @@ module Devices
|
|||
device
|
||||
end
|
||||
private
|
||||
|
||||
|
||||
def merge_default_values
|
||||
inputs[:name] ||= random_name
|
||||
end
|
||||
|
|
|
@ -5,6 +5,7 @@ module Devices
|
|||
end
|
||||
|
||||
optional do
|
||||
string :timezone, in: Device::TIMEZONES
|
||||
string :name
|
||||
string :webcam_url
|
||||
end
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
class AddTimezoneToDevices < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :devices, :timezone, :string
|
||||
add_index :devices, :timezone
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20170213151834) do
|
||||
ActiveRecord::Schema.define(version: 20170308231108) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -37,7 +37,9 @@ ActiveRecord::Schema.define(version: 20170213151834) do
|
|||
t.string "webcam_url"
|
||||
t.integer "max_log_count", default: 100
|
||||
t.integer "max_images_count", default: 100
|
||||
t.string "timezone"
|
||||
t.index ["planting_area_id"], name: "index_devices_on_planting_area_id", using: :btree
|
||||
t.index ["timezone"], name: "index_devices_on_timezone", using: :btree
|
||||
end
|
||||
|
||||
create_table "farm_events", force: :cascade do |t|
|
||||
|
|
Loading…
Reference in New Issue