insert into workflow_action_allowed_roles select :action_id, (select role_id from workflow_roles where workflow_id = :workflow_id and short_name = :allowed_role) as role_id insert into workflow_action_privileges (action_id, privilege) values (:action_id, :privilege) insert into workflow_actions (action_id, workflow_id, sort_order, short_name, pretty_name, pretty_past_tense, assigned_role, always_enabled_p) values (:action_id, :workflow_id, :sort_order, :short_name, :pretty_name, :pretty_past_tense, :assigned_role_id, :always_enabled_p) insert into workflow_initial_action (workflow_id, action_id) values (:workflow_id, :action_id) select assigned_role from workflow_actions where action_id = :action_id select role_id from workflow_action_allowed_roles where action_id = :action_id select privilege from workflow_action_privileges where action_id = :action_id select action_id from workflow_actions where workflow_id = :workflow_id and short_name = :short_name select workflow_id, sort_order, short_name, pretty_name, pretty_past_tense, assigned_role, always_enabled_p from workflow_actions where action_id = :action_id insert into workflow_fsm_actions (action_id, new_state) values (:action_id, :new_state_id) insert into workflow_fsm_action_enabled_in_states (action_id, state_id) values (:action_id, :enabled_state_id) select new_state from workflow_fsm_actions a where action_id = :action_id