Skip to content

Instantly share code, notes, and snippets.

@Abstrct
Created July 6, 2012 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Abstrct/3061011 to your computer and use it in GitHub Desktop.
Save Abstrct/3061011 to your computer and use it in GitHub Desktop.
CREATE OR REPLACE RULE ship_control_update AS
ON UPDATE TO my_ships DO INSTEAD ( UPDATE ship_control SET target_speed = new.target_speed,
target_direction = new.target_direction,
destination_x = COALESCE(new.destination_x, new.destination[0]),
destination_y = coalesce(new.destination_y, new.destination[1]),
destination = COALESCE(new.destination,POINT(new.destination_x, new.destination_y)), repair_priority = new.repair_priority, action = new.action, action_target_id = new.action_target_id
WHERE ship_control.ship_id = new.id;
UPDATE ship SET name = new.name, fleet_id = new.fleet_id
WHERE ship.id = new.id;
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment