Merge pull request #1573 from FarmBot/thursday_deploy
v8.2.0 - Iridescent Irispull/1574/head v8.2.0
commit
b8867cc165
|
@ -18,7 +18,6 @@ api_docs.md
|
|||
erd_diagram.png
|
||||
erd.pdf
|
||||
*scratchpad*
|
||||
scratchpad.rb
|
||||
/config/master.key
|
||||
config/credentials.yml.enc
|
||||
# ActiveStorage blobs:
|
||||
|
|
1
Gemfile
1
Gemfile
|
@ -24,7 +24,6 @@ gem "scenic"
|
|||
gem "secure_headers"
|
||||
gem "tzinfo" # For validation of user selected timezone names
|
||||
gem "valid_url"
|
||||
gem "zero_downtime_migrations"
|
||||
|
||||
group :development, :test do
|
||||
gem "climate_control"
|
||||
|
|
|
@ -297,8 +297,6 @@ GEM
|
|||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.4)
|
||||
zeitwerk (2.2.0)
|
||||
zero_downtime_migrations (0.0.7)
|
||||
activerecord
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
@ -340,7 +338,6 @@ DEPENDENCIES
|
|||
smarf_doc!
|
||||
tzinfo
|
||||
valid_url
|
||||
zero_downtime_migrations
|
||||
|
||||
RUBY VERSION
|
||||
ruby 2.6.5p114
|
||||
|
|
|
@ -33,6 +33,7 @@ module Api
|
|||
rescue_from(JWT::VerificationError) { |e| auth_err }
|
||||
|
||||
rescue_from(ActionDispatch::Http::Parameters::ParseError) { sorry NOT_JSON }
|
||||
rescue_from(JSON::ParserError) { sorry NOT_JSON }
|
||||
|
||||
rescue_from(ActiveRecord::ValueTooLong) do
|
||||
sorry "Please use reasonable lengths on string inputs"
|
||||
|
|
|
@ -79,7 +79,7 @@ module Api
|
|||
class PasswordFailure < Exception; end
|
||||
|
||||
rescue_from PasswordFailure, with: :report_suspicious_behavior
|
||||
rescue_from BrokerConnectionLimiter::RateLimit, with: :deny
|
||||
rescue_from BrokerConnectionLimiter::RateLimit, with: :do_rate_limit
|
||||
|
||||
skip_before_action :check_fbos_version, except: []
|
||||
skip_before_action :authenticate_user!, except: []
|
||||
|
@ -97,13 +97,13 @@ module Api
|
|||
# "farmbot_demo". We intentionally
|
||||
# differentiate to avoid accidental
|
||||
# security issues. -RC
|
||||
when "guest" then deny
|
||||
when "guest" then deny("Can't use guest account on this server.")
|
||||
when "admin" then authenticate_admin
|
||||
when FARMBOT_DEMO_USER
|
||||
with_rate_limit { allow }
|
||||
else
|
||||
is_ok = device_id_in_username == current_device.id
|
||||
is_ok ? (with_rate_limit { allow }) : deny
|
||||
is_ok ? (with_rate_limit { allow }) : deny("Guests are rate limited")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -112,7 +112,7 @@ module Api
|
|||
# "username" => "admin",
|
||||
# "vhost" => "/",
|
||||
# "ip" => "::ffff:172.23.0.1",
|
||||
vhost_param == VHOST ? allow : deny
|
||||
vhost_param == VHOST ? allow : deny("Bad vhost")
|
||||
end
|
||||
|
||||
def resource_action
|
||||
|
@ -123,7 +123,7 @@ module Api
|
|||
# "name" => "mqtt-subscription-MQTT_FX_Clientqos0",
|
||||
# "permission" => "configure",
|
||||
ok = RESOURCES.include?(resource_param) && PERMISSIONS.include?(permission_param)
|
||||
ok ? allow : deny
|
||||
ok ? allow : deny("Bad resource action")
|
||||
end
|
||||
|
||||
def topic_action # Called during subscribe
|
||||
|
@ -136,10 +136,14 @@ module Api
|
|||
# "vhost" => "/",
|
||||
case routing_key_param
|
||||
when *PUBLIC_CHANNELS
|
||||
permission_param == "read" ? allow : deny
|
||||
permission_param == "read" ? allow : deny("Topic is read only")
|
||||
else
|
||||
if_topic_is_safe do
|
||||
device_id_in_topic == device_id_in_username ? allow : deny
|
||||
if device_id_in_topic == device_id_in_username
|
||||
allow
|
||||
else
|
||||
deny("Unsafe topic")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -177,10 +181,15 @@ module Api
|
|||
|
||||
def report_suspicious_behavior
|
||||
Rollbar.error("Failed password attempt on RMQ: " + password_param)
|
||||
deny
|
||||
deny("Failed password attempt")
|
||||
end
|
||||
|
||||
def deny
|
||||
def do_rate_limit
|
||||
deny("Device is rate limited")
|
||||
end
|
||||
|
||||
def deny(reason)
|
||||
maybe_alert_user(reason)
|
||||
render json: "deny", status: 403
|
||||
end
|
||||
|
||||
|
@ -217,32 +226,32 @@ module Api
|
|||
a, b, c = (routing_key_param || "").split(".")
|
||||
|
||||
if !(permission_param == "read")
|
||||
deny
|
||||
deny("!(permission_param == read)")
|
||||
return
|
||||
end
|
||||
|
||||
if !(a == DEMO_REGISTRY_ROOT)
|
||||
deny
|
||||
deny("!(a == DEMO_REGISTRY_ROOT)")
|
||||
return
|
||||
end
|
||||
|
||||
if b.nil?
|
||||
deny
|
||||
deny("b.nil?")
|
||||
return
|
||||
end
|
||||
|
||||
if b.include?("*")
|
||||
deny
|
||||
deny("b.include?(*)")
|
||||
return
|
||||
end
|
||||
|
||||
if b.include?("#")
|
||||
deny
|
||||
deny("b.include?(#)")
|
||||
return
|
||||
end
|
||||
|
||||
if c.present?
|
||||
deny
|
||||
deny("c.present?")
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -255,6 +264,9 @@ module Api
|
|||
return
|
||||
end
|
||||
|
||||
msg = "Subscribed to illegal topic #{routing_key_param || ""}"
|
||||
maybe_alert_user(msg)
|
||||
|
||||
render json: MALFORMED_TOPIC, status: 422
|
||||
end
|
||||
|
||||
|
@ -267,6 +279,7 @@ module Api
|
|||
end
|
||||
|
||||
def with_rate_limit
|
||||
# TODO: Replace this with `ThrottlePolicy`.
|
||||
BrokerConnectionLimiter
|
||||
.current
|
||||
.maybe_continue(username_param) { yield }
|
||||
|
@ -281,5 +294,13 @@ module Api
|
|||
def device_id_in_username
|
||||
@device_id ||= username_param.gsub("device_", "").to_i
|
||||
end
|
||||
|
||||
def maybe_alert_user(reason)
|
||||
msg = "MQTT ACCESS DENIED #{reason}"
|
||||
puts msg unless Rails.env.test?
|
||||
if device_id_in_username > 0
|
||||
Device.find(device_id_in_username).delay.tell(msg)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,6 +6,7 @@ class Device < ApplicationRecord
|
|||
|
||||
TIMEZONES = TZInfo::Timezone.all_identifiers
|
||||
BAD_TZ = "%{value} is not a valid timezone"
|
||||
BAD_OTA_HOUR = "must be a value from 0 to 23."
|
||||
THROTTLE_ON = "Device is sending too many logs (%s). " \
|
||||
"Suspending log storage and display until %s."
|
||||
THROTTLE_OFF = "Cooldown period has ended. " \
|
||||
|
@ -40,6 +41,8 @@ class Device < ApplicationRecord
|
|||
message: BAD_TZ,
|
||||
allow_nil: true,
|
||||
}
|
||||
validates :ota_hour,
|
||||
inclusion: { in: [*0..23], message: BAD_OTA_HOUR, allow_nil: true }
|
||||
|
||||
# Give the user back the amount of logs they are allowed to view.
|
||||
def limited_log_list
|
||||
|
|
|
@ -13,6 +13,7 @@ module Devices
|
|||
time :last_ota
|
||||
time :last_ota_checkup
|
||||
integer :mounted_tool_id, nils: true
|
||||
integer :ota_hour, nils: true
|
||||
end
|
||||
|
||||
def validate
|
||||
|
|
|
@ -1,6 +1,15 @@
|
|||
class DeviceSerializer < ApplicationSerializer
|
||||
attributes :fbos_version, :last_saw_api, :last_saw_mq,
|
||||
:mounted_tool_id, :name, :serial_number,
|
||||
:throttled_at, :throttled_until, :timezone,
|
||||
:tz_offset_hrs, :last_ota, :last_ota_checkup
|
||||
attributes :fbos_version,
|
||||
:last_ota_checkup,
|
||||
:last_ota,
|
||||
:last_saw_api,
|
||||
:last_saw_mq,
|
||||
:mounted_tool_id,
|
||||
:name,
|
||||
:ota_hour,
|
||||
:serial_number,
|
||||
:throttled_at,
|
||||
:throttled_until,
|
||||
:timezone,
|
||||
:tz_offset_hrs
|
||||
end
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class InitSchema < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
def up
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class ReasonableStringLengths < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
TWEETx2 = 280
|
||||
def change
|
||||
{ devices: "name",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddLastSeenToDevices < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :devices, :last_seen, :datetime
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class SquasherClean < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
class SchemaMigration < ActiveRecord::Base
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class CreateWebcamFeeds < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
create_table :webcam_feeds do |t|
|
||||
t.references :device
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddNameToWebcamFeed < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :webcam_feeds,
|
||||
:name,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class RenameDeviceLastSeenToLastSawApi < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
rename_column :devices, :last_seen, :last_saw_api
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddLastSawMqToDevices < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :devices, :last_saw_mq, :datetime
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddUncofirmedEmailFieldToUser < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
rename_column :users, :verification_token, :confirmation_token
|
||||
rename_column :users, :verified_at, :confirmed_at
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class DeleteWebcamUrlFromDevice < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
remove_column :devices, :webcam_url
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddPulloutToTools < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :tools, :pullout_direction, :integer, default: 0
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class CreateConfigTables < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
create_table :firmware_configs do |t|
|
||||
t.references :device
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddWeedDetectorToWebAppConfig < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :web_app_configs,
|
||||
:weed_detector,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class RemoveTypoColumnsFromConfigs < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
remove_column :firmware_configs, :status_general, :boolean
|
||||
remove_column :web_app_configs, :successs_log, :boolean
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddFirstPartyFarmwareToFbosConfigs < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :web_app_configs,
|
||||
:show_first_party_farmware,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class UpdateConfigColumns < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
# arduino_debug_messages
|
||||
add_column :fbos_configs, :api_migrated, :boolean, default: false
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class FixPulloutDirection < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
remove_column :tools, :pullout_direction, :integer, default: 0
|
||||
add_column :tool_slots, :pullout_direction, :integer, default: 0
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class NewSequenceSchema < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
create_table :primary_nodes do |t|
|
||||
t.timestamps null: false
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddEnableBrowserSpeakToWebAppConfigs < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :web_app_configs,
|
||||
:enable_browser_speak,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddMigratedNodesToSequences < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :sequences, :migrated_nodes, :boolean, default: false
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class ChangePrimaryNodeColumnNames < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_reference :primary_nodes, :next, index: true
|
||||
add_reference :primary_nodes, :body, index: true
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddApiMigratedToFirmwareConfigs < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :firmware_configs,
|
||||
:api_migrated,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddCommentColumnToPrimaryNodes < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :primary_nodes,
|
||||
:comment,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddShowImagesToWebAppConfigs < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :web_app_configs,
|
||||
:show_images,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class RemoveModeFromPeripherals < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
remove_column :peripherals, :mode, :integer
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddPhotoFiltersToWebAppConfigs < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :web_app_configs, :photo_filter_begin, :string
|
||||
add_column :web_app_configs, :photo_filter_end, :string
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class CreateSensorReadings < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
create_table :sensor_readings do |t|
|
||||
t.references :device, foreign_key: true
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class UpdateDevicesAndPeripherals < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :devices, :fbos_version, :string, limit: 15 # "99.99.99-rc99"
|
||||
add_column :peripherals, :mode, :integer
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddDefaultToModeOnPeripherals < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def up
|
||||
change_column :peripherals, :mode, :integer, default: 0
|
||||
Peripheral.where(mode: nil).update_all(mode: 0)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddModeToSensorReadingTable < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :sensor_readings, :mode, :integer, default: 0
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class CreateSensors < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
create_table :sensors do |t|
|
||||
t.references :device, foreign_key: true
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class CreateFarmwareInstallations < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
create_table :farmware_installations do |t|
|
||||
t.references :device, foreign_key: true
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class CreateFarmwareEnvs < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
|
||||
def change
|
||||
create_table :farmware_envs do |t|
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class CreatePinBindings < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
create_table :pin_bindings do |t|
|
||||
t.references :device, foreign_key: true
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddPlantedAtToPlants < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :plants, :planted_at, :datetime, default: nil
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddPlantStageToPlants < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :plants, :plant_stage, :string, limit: 10, default: "planned",
|
||||
presence: true
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddDiscardUnsavedChanges < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :web_app_configs,
|
||||
:discard_unsaved,
|
||||
|
|
|
@ -2,7 +2,7 @@ class ChangeEncoderScalingDefault < ActiveRecord::Migration[5.1]
|
|||
ALL = [:encoder_scaling_x, :encoder_scaling_y, :encoder_scaling_z]
|
||||
AFTER = 5556
|
||||
BEFORE = 56
|
||||
safety_assured
|
||||
|
||||
def up
|
||||
ALL.map do |enc|
|
||||
change_column :firmware_configs, enc, :integer, default: AFTER
|
||||
|
|
|
@ -2,7 +2,7 @@ class OsAutoUpdateEnabled < ActiveRecord::Migration[5.1]
|
|||
BEFORE = false
|
||||
AFTER = true
|
||||
|
||||
safety_assured
|
||||
|
||||
def up
|
||||
change_column :fbos_configs, :os_auto_update, :boolean, default: AFTER
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class CreateGlobalConfigs < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
create_table :global_configs do |t|
|
||||
t.string :key
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class MakeDefaulDeviceNameFarmbot < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
change_column_default(:devices, :name, "Farmbot")
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class SetMaxSpeed < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
# There were still some sequences found on 25 MAR 18 that had a speed
|
||||
# value > 100. -RC
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class DropSequenceDepsTable < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
# NOTE TO FUTURE SELF:
|
||||
# if data issues prevent this migration from running try
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class CreateTokenIssuances < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
create_table :token_issuances do |t|
|
||||
t.references :device, foreign_key: true, null: false
|
||||
|
|
|
@ -8,5 +8,5 @@ class DropTokenExpirations < ActiveRecord::Migration[5.1]
|
|||
t.datetime :updated_at, null: false
|
||||
end
|
||||
end
|
||||
safety_assured
|
||||
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class FlattenMetaColumn < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :logs, :type, :string, limit: 10, default: "info"
|
||||
add_column :logs, :major_version, :integer
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class MigrateAwayFromMetaColumn < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def up
|
||||
# We dont want this one, actually.
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class RepairLogs < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
REPAIRABLES = [:x, :y, :z, :verbosity, :major_version, :minor_version, :type]
|
||||
|
||||
def up
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class RemoveArgsAndBodyFromSequence < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
remove_column :sequences, :args, :text
|
||||
remove_column :sequences, :body, :text
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class CreateSequenceToolsView < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
# I goofed up on this migration and deployed to staging before I could fix.
|
||||
# See later migration that creates a new view using the `scenic` gem.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddArchivedAtToPoints < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :points, :archived_at, :datetime, default: nil
|
||||
add_column :points, :planted_at, :datetime, default: nil
|
||||
|
|
|
@ -4,7 +4,7 @@ class RenameLegacyPointerTables < ActiveRecord::Migration[5.1]
|
|||
"tool_slots" => "legacy_tool_slots",
|
||||
"plants" => "legacy_plants",
|
||||
}
|
||||
safety_assured
|
||||
|
||||
|
||||
def self.up
|
||||
add_column :points, :migrated_at, :datetime
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class DropOldDbFunctions < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def up
|
||||
# These are old database functions that were created by the
|
||||
# `polymorphic_constraints` gem. No longer needed.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddDiscardedAtToPoints < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :points, :discarded_at, :datetime
|
||||
add_index :points, :discarded_at
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class CreateInUseResources < ActiveRecord::Migration[5.1]
|
||||
# I goofed up on this migration and deployed to staging before I could fix.
|
||||
# See later migration that creates a new view using the `scenic` gem. - RC
|
||||
safety_assured
|
||||
|
||||
def up
|
||||
execute "DROP VIEW IF EXISTS in_use_tools;"
|
||||
execute "DROP VIEW IF EXISTS in_use_points;"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddMissingIndexPointToolId < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_index :points, :tool_id
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class UpdateInUseToolsToVersion2 < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
update_view :in_use_tools, version: 2, revert_to_version: 1
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddMissingIndexes < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_index :edge_nodes, [:kind, :value]
|
||||
add_index :farm_events, :end_time
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddMoreMissingIndexes < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def up
|
||||
add_index :logs, :verbosity
|
||||
change_column :logs, :verbosity, :integer, default: 1
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddXySwapToWebAppConfigs < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :web_app_configs,
|
||||
:xy_swap,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class CreateSequenceUsageReports < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
create_view :sequence_usage_reports
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class RetroactivelySetDefaultVerbosity < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
Log.where(verbosity: nil).update_all(verbosity: 1)
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class NeedMoarIntegrity < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_foreign_key :points, :tools, null: true
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class CreateSavedGardens < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
create_table :saved_gardens do |t|
|
||||
t.string :name, null: false
|
||||
|
|
|
@ -3,7 +3,7 @@ class FiftySix < ActiveRecord::Migration[5.1]
|
|||
GOOD = 5556
|
||||
ALL_OF_THEM = [ :encoder_scaling_x, :encoder_scaling_y, :encoder_scaling_z ]
|
||||
|
||||
safety_assured
|
||||
|
||||
def up
|
||||
ALL_OF_THEM.map do |attr|
|
||||
FirmwareConfig.where(attr => BAD).update_all(attr => GOOD)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class UpdateInUsePointsToVersion2 < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
update_view :in_use_points, version: 2, revert_to_version: 1
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class NoInfinity < ActiveRecord::Migration[5.1]
|
||||
MAX_AXIS_SIZE = 50_000 # The biggest axis on prod today is 21k
|
||||
|
||||
safety_assured
|
||||
|
||||
def ∞
|
||||
1.0/0.0
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ class AprilParameterAdditions < ActiveRecord::Migration[5.1]
|
|||
movement_invert_2_endpoints_y: 0,
|
||||
movement_invert_2_endpoints_z: 0 }
|
||||
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
NEW_STUFF.map do |(name, default)|
|
||||
add_column :firmware_configs, name, :integer, default: default
|
||||
|
|
|
@ -2,7 +2,7 @@ class RemoveLegacyPointsTables < ActiveRecord::Migration[5.1]
|
|||
BIG_WARNING = \
|
||||
"It appears that your database contains records which still require "\
|
||||
"migration. Please migrate data before proceeding."
|
||||
safety_assured
|
||||
|
||||
def safe_to_proceed?
|
||||
any_plants = \
|
||||
Plant.where(migrated_at: nil).where.not(pointer_id: 0).count > 0
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddHomeButtonHomingToWebAppConfigs < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :web_app_configs,
|
||||
:home_button_homing,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class RemoveArchivedAtColFromPoints < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
# We use `discarded_at` now, because that what the "discard" gem wants.
|
||||
remove_column :points, :archived_at, :datetime, default: nil
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddMissingIndexesAgain < ActiveRecord::Migration[5.1]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_index :points, [:id, :pointer_type]
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddThrottledAtToDevice < ActiveRecord::Migration[5.2]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :devices, :throttled_at, :datetime
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class ChangeDeviceThrottledAt < ActiveRecord::Migration[5.2]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
remove_column :devices, :throttled_at, :datetime
|
||||
add_column :devices, :throttled_until, :datetime
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddThrottledAtToDeviceAgain < ActiveRecord::Migration[5.2]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :devices, :throttled_at, :datetime
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddSentAtToLog < ActiveRecord::Migration[5.2]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :logs, :sent_at, :datetime
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class IncreaseCommentLength < ActiveRecord::Migration[5.2]
|
||||
safety_assured
|
||||
|
||||
def up
|
||||
change_column :primary_nodes, :comment, :string, limit: 240
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class GetRidOfLogDispatches < ActiveRecord::Migration[5.2]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
drop_table :log_dispatches do |t|
|
||||
t.bigint :device_id
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class CreateDiagnosticDumps < ActiveRecord::Migration[5.2]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
create_table :diagnostic_dumps do |t|
|
||||
t.references :device, foreign_key: true, null: false
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddSpecialActionToPinBinding < ActiveRecord::Migration[5.2]
|
||||
safety_assured
|
||||
|
||||
def up
|
||||
execute <<-SQL
|
||||
CREATE TYPE special_action AS
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class ChangeLogColumnsToFloats < ActiveRecord::Migration[5.2]
|
||||
ALL = [ :x, :y, :z ]
|
||||
|
||||
safety_assured
|
||||
|
||||
def up
|
||||
ALL.map { |ax| change_column :logs, ax, :float }
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddMoreStuffToDataDumps < ActiveRecord::Migration[5.2]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :diagnostic_dumps, :sync_status, :string, limit: 12
|
||||
add_column :diagnostic_dumps, :wifi_level, :string, limit: 12
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class FirmwareConfigFloatConversion < ActiveRecord::Migration[5.2]
|
||||
safety_assured
|
||||
|
||||
def up
|
||||
change_column :firmware_configs, :movement_step_per_mm_x, :float
|
||||
change_column :firmware_configs, :movement_step_per_mm_y, :float
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddMoreLogIndexes < ActiveRecord::Migration[5.2]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_index :logs, :updated_at
|
||||
add_index :logs, :sent_at
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddMoreMoreLogIndexes < ActiveRecord::Migration[5.2]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_index :logs, [:device_id, :created_at]
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddShowMotorPlotToWebAppConfigs < ActiveRecord::Migration[5.2]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :web_app_configs,
|
||||
:show_motor_plot,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddShowHistoricPointsToWebAppConfigs < ActiveRecord::Migration[5.2]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :web_app_configs,
|
||||
:show_historic_points,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddShowSensorReadingsToWebAppConfigs < ActiveRecord::Migration[5.2]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :web_app_configs,
|
||||
:show_sensor_readings,
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
class AddFirmwareConfsToFbosConfigs < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :fbos_configs, :firmware_path, :string
|
||||
safety_assured do # This table is small enough to not worry about.
|
||||
add_column :fbos_configs, :firmware_debug_log, :boolean, default: false
|
||||
end
|
||||
add_column :fbos_configs, :firmware_path, :string
|
||||
add_column :fbos_configs, :firmware_debug_log, :boolean, default: false
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class AddUpdateChannelToFbosConfigs < ActiveRecord::Migration[5.2]
|
||||
safety_assured # This table is small enough.
|
||||
def change
|
||||
add_column :fbos_configs,
|
||||
:update_channel,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddShowDevMenuToWebAppConfigs < ActiveRecord::Migration[5.2]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :web_app_configs,
|
||||
:show_dev_menu,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddTimeFormat24HourToWebAppConfigs < ActiveRecord::Migration[5.2]
|
||||
safety_assured
|
||||
|
||||
def change
|
||||
add_column :web_app_configs,
|
||||
:time_format_24_hour,
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue