 #
 # This file is part of the Anotatornia suite.
 # 
 # Copyright © 2007, 2008, 2009, 2010 by Instytut Podstaw Informatyki
 # Polskiej Akademii Nauk (IPI PAN; Institute of Computer Science, Polish
 # Academy of Sciences; cf. www.ipipan.waw.pl).  All rights reserved.
 # 
 # This file may be distributed and/or modified under the terms of the
 # GNU General Public License version 3 as published by the Free Software
 # Foundation and appearing in the file COPYING included in the packaging
 # of this file.  (See http://www.gnu.org/licenses/translations.html for
 # unofficial translations.)
 # 
 # A commercial license is available from IPI PAN (contact
 # Michal.Ciesiolka.waw.pl or ipi.waw.pl for more
 # information).  Licensees holding a valid commercial license from IPI
 # PAN may use this file in accordance with that license.
 # 
 # This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
 # THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 # PURPOSE.
 #

class ReverseNiedostrzeganiemMasturbacji < ActiveRecord::Migration
  # Ma sens tylko w~wersji 8003, gdzie niefortunnie dodałem wariant segmentacyjny „niedostrzeganiem” w~akapicie 19.

  def self.up
    if AnoVersion.nkjp?
      if ( a = Akapit.find( :first, :conditions => "akapit_id=19" )
           # #{Akapit.find( 19 )} causes error if absent
           ) and a.tresc =~ /^Oddramatyzowanie problemu masturbacji nie może też łączyć się.*nie dostrzeganiem niedostrzeganiem/
        t = Token.find( :first, :conditions =>{ :orth => 'niedostrzeganiem', :akapit_id => 19 })
        if t
          sgc_id = t.sg_choice_id
          t.sg_choice.destroy
          t.destroy
          execute "update token set chosen='t', sg_variant_id=null, sg_choice_id=null where sg_choice_id=#{sgc_id}"
          # #{Akapit.dopuść_posegmentowane( 19, 19 )} nie ma sensu, bo tam jest wariant segmentacyjny
        end
      end
    end
  end

  def self.down
  end
end
