diff --git a/db/migrate/20230705095430_populate_device_archived_at_column.rb b/db/migrate/20230705095430_populate_device_archived_at_column.rb new file mode 100644 index 00000000..a54c9e42 --- /dev/null +++ b/db/migrate/20230705095430_populate_device_archived_at_column.rb @@ -0,0 +1,9 @@ +class PopulateDeviceArchivedAtColumn < ActiveRecord::Migration[6.0] + def change + execute %{ + UPDATE devices + SET archived_at = NOW() + WHERE workflow_state = 'archived' + } + end +end diff --git a/db/schema.rb b/db/schema.rb index f233d921..530b1b70 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -96,8 +96,8 @@ t.string "state" t.string "device_token" t.jsonb "hardware_info" - t.datetime "notify_stopped_publishing_timestamp", default: "2019-01-16 16:19:35" - t.datetime "notify_low_battery_timestamp", default: "2019-01-16 16:19:35" + t.datetime "notify_stopped_publishing_timestamp", default: "2019-01-21 16:07:41" + t.datetime "notify_low_battery_timestamp", default: "2019-01-21 16:07:41" t.boolean "notify_low_battery", default: false t.boolean "notify_stopped_publishing", default: false t.boolean "is_private", default: false diff --git a/env.example b/env.example index 8d09fe19..b3ef1acf 100644 --- a/env.example +++ b/env.example @@ -20,7 +20,8 @@ REDIS_STORE=redis://redis:6379/3 MQTT_HOST=mqtt #MQTT_CLEAN_SESSION=true #MQTT_CLIENT_ID=some_id - +#MQTT_PORT=port +#MQTT_SSL=false aws_secret_key=123 # kairos Dockerized diff --git a/lib/tasks/mqtt_subscriber.rake b/lib/tasks/mqtt_subscriber.rake index 30f15c24..6b432a9b 100644 --- a/lib/tasks/mqtt_subscriber.rake +++ b/lib/tasks/mqtt_subscriber.rake @@ -7,17 +7,23 @@ namespace :mqtt do mqtt_clean_session = ENV.has_key?('MQTT_CLEAN_SESSION') ? ENV['MQTT_CLEAN_SESSION'] == "true" : true mqtt_client_id = ENV.has_key?('MQTT_CLIENT_ID') ? ENV['MQTT_CLIENT_ID'] : nil mqtt_host = ENV.has_key?('MQTT_HOST') ? ENV['MQTT_HOST'] : 'mqtt' + mqtt_port = ENV.has_key?('MQTT_PORT') ? ENV['MQTT_PORT'] : 1883 + mqtt_ssl = ENV.has_key?('MQTT_SSL') ? ENV['MQTT_SSL'] : false mqtt_log.info('MQTT TASK STARTING') mqtt_log.info("clean_session: #{mqtt_clean_session}") mqtt_log.info("client_id: #{mqtt_client_id}") mqtt_log.info("host: #{mqtt_host}") + mqtt_log.info("port: #{mqtt_port}") + mqtt_log.info("ssl: #{mqtt_ssl}") begin MQTT::Client.connect( :host => mqtt_host, + :port => mqtt_port, :clean_session => mqtt_clean_session, - :client_id => mqtt_client_id + :client_id => mqtt_client_id, + :ssl => mqtt_ssl ) do |client| mqtt_log.info "Connected to #{client.host}"