You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: 20160505134052_migrate_flex_projects.rb
    path of file: ./repos/catarse/db/migrate
    
    the code of the file until where you have to start completion: class Migrate
    
  def change
    execute <<-SQL
      UPDATE projects p SET mode = 'flex', state = (SELECT state from flexible_projects fp WHERE project_id = p.id) WHERE EXISTS (SELECT project_id from flexible_projects fp WHERE project_id = p.id);
      INSERT INTO project_transitions(to_state, metadata, sort_key, project_id, most_recent, created_at, updated_at) 
        SELECT to_state, metadata, sort_key, (SELECT project_id from flexible_projects fp where fp.id = flexible_project_id), most_recent, created_at, updated_at from flexible_project_transitions WHERE NOT EXISTS(SELECT * from project_transitions WHERE project_id = (SELECT project_id from flexible_projects fp where fp.id = flexible_project_id));
    SQL
  end