 #
 # 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 PoprawNierowneStatusy < ActiveRecord::Migration
  
  extend MigrationHelper
  
  def self.up
    kill_anotatorniæ_if_8003
    sth_done = false
    AkapitTranszy.find_by_sql( 
                              "select * from akapit_transzy where akapit_transzy_id in " +
                              "(select s1.akapit_transzy_id from " +
                              " statusy s1 inner join statusy s2 on " +
                              " s1.akapit_id=s2.akapit_id and s1.statusy_id<>s2.statusy_id" +
                              " where s1.morphosyntactic>=13 and s2.morphosyntactic<=12 )"
                                       ).
      each { |at211|
      puts "poprawiam status #{at211.akapit_id}/#{at211.id}"
      at211.set_status( :morphosyntactic, :dopuszczony, :tylko_to )
      sth_done = true unless sth_done
    }

    puts " »sth. done« is #{sth_done.inspect}"
  end

  def self.down
  end
end
