|  | @@ -11,4 +11,25 @@ CREATE OR REPLACE VIEW pod_nodes AS
 | 
	
		
			
			| 11 | 11 |      FROM pod_nodes_history
 | 
	
		
			
			| 12 | 12 |      ORDER BY node_id, updated_at DESC;
 | 
	
		
			
			| 13 | 13 |  
 | 
	
		
			
			|  | 14 | +CREATE OR REPLACE RULE pod_insert_new_node AS ON INSERT
 | 
	
		
			
			|  | 15 | +TO pod_nodes
 | 
	
		
			
			|  | 16 | +DO INSTEAD INSERT INTO pod_nodes_history (node_id, parent_id, node_order, node_type, created_at, updated_at, 
 | 
	
		
			
			|  | 17 | +       data_label, data_content, data_datetime, node_status, data_reminder_datetime, 
 | 
	
		
			
			|  | 18 | +       data_file_name, data_file_content, data_file_mime_type, parent_tree_path, 
 | 
	
		
			
			|  | 19 | +       node_depth, owner_id, version_id, is_shared, is_public, public_url_key) VALUES (nextval('pod_nodes__node_id__sequence'), NEW.parent_id, NEW.node_order, NEW.node_type, NEW.created_at, NEW.updated_at, NEW.data_label, NEW.data_content, NEW.data_datetime, NEW.node_status, NEW.data_reminder_datetime, NEW.data_file_name, NEW.data_file_content, NEW.data_file_mime_type, NEW.parent_tree_path, NEW.node_depth, NEW.owner_id, nextval('pod_nodes_version_id_sequence'), NEW.is_shared, NEW.is_public, NEW.public_url_key)
 | 
	
		
			
			|  | 20 | +RETURNING node_id, parent_id, node_order, node_type, created_at, updated_at, 
 | 
	
		
			
			|  | 21 | +       data_label, data_content, data_datetime, node_status, data_reminder_datetime, 
 | 
	
		
			
			|  | 22 | +       data_file_name, data_file_content, data_file_mime_type, parent_tree_path, 
 | 
	
		
			
			|  | 23 | +       node_depth, owner_id, is_shared, is_public, public_url_key;
 | 
	
		
			
			| 14 | 24 |  
 | 
	
		
			
			|  | 25 | +CREATE OR REPLACE FUNCTION pod_update_node() RETURNS trigger AS $$
 | 
	
		
			
			|  | 26 | +BEGIN
 | 
	
		
			
			|  | 27 | +INSERT INTO pod_nodes_history (node_id, parent_id, node_order, node_type, created_at, updated_at, 
 | 
	
		
			
			|  | 28 | +       data_label, data_content, data_datetime, node_status, data_reminder_datetime, 
 | 
	
		
			
			|  | 29 | +       data_file_name, data_file_content, data_file_mime_type, parent_tree_path, 
 | 
	
		
			
			|  | 30 | +       node_depth, owner_id, version_id, is_shared, is_public, public_url_key) VALUES (NEW.node_id, NEW.parent_id, NEW.node_order, NEW.node_type, NEW.created_at, NEW.updated_at, NEW.data_label, NEW.data_content, NEW.data_datetime, NEW.node_status, NEW.data_reminder_datetime, NEW.data_file_name, NEW.data_file_content, NEW.data_file_mime_type, NEW.parent_tree_path, NEW.node_depth, NEW.owner_id, nextval('pod_nodes_version_id_sequence'), NEW.is_shared, NEW.is_public, NEW.public_url_key);
 | 
	
		
			
			|  | 31 | +return new;
 | 
	
		
			
			|  | 32 | +END;
 | 
	
		
			
			|  | 33 | +$$ LANGUAGE plpgsql;
 | 
	
		
			
			|  | 34 | +
 | 
	
		
			
			|  | 35 | +CREATE TRIGGER pod_update_node_tg INSTEAD OF UPDATE ON pod_nodes FOR EACH ROW EXECUTE PROCEDURE pod_update_node();
 |