Fix bug where missing version numbers caused unintentional migrations.
parent
a6209b2740
commit
96ea9d1da1
|
@ -49,6 +49,7 @@ module SequenceMigration
|
|||
if incorrect_version
|
||||
raise "Version must be #{expected_version} to run #{self.class}"
|
||||
end
|
||||
Rollbar.info "RUNNING MIGRATION #{sequence_version}"
|
||||
end
|
||||
|
||||
def after
|
||||
|
|
|
@ -14,18 +14,25 @@ module SequenceMigration
|
|||
.body
|
||||
.select { |x| x["kind"] == "move_absolute" }
|
||||
.each do |x|
|
||||
loc = { "kind" => "coordinate" }.merge(x["args"].slice("x", "y", "z"))
|
||||
x["args"]["location"] = loc
|
||||
x["args"].except!("x", "y", "z")
|
||||
x["args"]["offset"] = {
|
||||
"kind" => "coordinate",
|
||||
"args" => {
|
||||
"x" => 0,
|
||||
"y" => 0,
|
||||
"z" => 0
|
||||
# THIS IS MY FAULT. 25 JAN 17, RC.
|
||||
# I must fix a mistake I made. Some sequence.args.version was `nil`
|
||||
# but actually should have been `4`.
|
||||
if (x["args"].keys.include?("location"))
|
||||
# I will need to manually fix these.
|
||||
Rollbar.info("Sequence #{sequence.id} is bad.")
|
||||
else
|
||||
loc = { "kind" => "coordinate" }.merge(x["args"].slice("x", "y", "z"))
|
||||
x["args"]["location"] = loc
|
||||
x["args"].except!("x", "y", "z")
|
||||
x["args"]["offset"] = {
|
||||
"kind" => "coordinate",
|
||||
"args" => {
|
||||
"x" => 0,
|
||||
"y" => 0,
|
||||
"z" => 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ class Sequence < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def load(value)
|
||||
output = (JSON.load(value) || @default.new)
|
||||
output = value ? YAML.load(value) : @default.new
|
||||
if(output.respond_to?(:with_indifferent_access))
|
||||
return output.with_indifferent_access
|
||||
else
|
||||
|
@ -20,7 +20,7 @@ class Sequence < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def dump(value)
|
||||
(value || @default.new).to_json
|
||||
YAML.dump(value || @default.new)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -14,7 +14,12 @@ module Sequences
|
|||
:comment
|
||||
]
|
||||
def validate_sequence
|
||||
add_error :body, :syntax_error, checker.error.message if !checker.valid?
|
||||
# TODO: The code below strips out unneeded attributes, or attributes that
|
||||
# are not part of CeleryScript. We're only stripping attributes out of the
|
||||
# first level, though. I would like to recursively strip out "noise" via
|
||||
# CeleryScript::JSONClimber. I am holding off for now in the name of time.
|
||||
(inputs[:body] || []).map! { |x| x.slice(*ALLOWED_NODE_KEYS) }
|
||||
add_error :body, :syntax_error, checker.error.message if !checker.valid?
|
||||
end
|
||||
|
||||
def seq
|
||||
|
@ -37,8 +42,6 @@ module Sequences
|
|||
end
|
||||
|
||||
def tree
|
||||
# TODO: Change this to recursive tree climbing if it causes issues in prod
|
||||
seq[:body].map! { |x| x.slice(*ALLOWED_NODE_KEYS) }
|
||||
@tree = CeleryScript::AstNode.new(**seq)
|
||||
end
|
||||
|
||||
|
|
|
@ -19,6 +19,10 @@ module Sequences
|
|||
def execute
|
||||
seq = Sequence.new(inputs)
|
||||
seq.args["is_outdated"] = false
|
||||
# version is never user definable!
|
||||
# IF YOU UNCOMMENT THIS BAD STUFF WILL HAPPEN.
|
||||
seq.args["version"] = SequenceMigration::Base.latest_version
|
||||
# See comment above ^
|
||||
ActiveRecord::Base.transaction do
|
||||
seq.save!
|
||||
reload_dependencies(seq)
|
||||
|
|
|
@ -115,8 +115,10 @@ describe Sequences::Create do
|
|||
color: "gray",
|
||||
name: "New Sequence",
|
||||
}).reload
|
||||
expected = result.body.dig(0, "args", "location", "args")
|
||||
actual = body.dig(0, "args", "location", "args")
|
||||
expected = result.body.dig(0, "args", "location", "args")
|
||||
actual = body.dig(0, "args", "location", "args")
|
||||
extra_stuff = result.body.map{|x| x["uuid"]}.compact
|
||||
expect(extra_stuff.length).to eq(0)
|
||||
expect(expected).to eq(actual)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue