class InsertDatekProjects < ActiveRecord::Migration def self.up change_column :backlogs, :name, :string, :limit => 64, :null => false if RAILS_ENV =~ /datek|development/ projects = { 1 => 'Viderefakturering SCR', 2 => 'NSB Godstrafikk vedlikehold', 3 => 'NSB Persontrafikk vedlikehold', 4 => 'NSB Godstrafikk løpende prosjekter', 5 => 'NSB Persontrafikk løpende prosjekter', 12 => 'Norsk Tipping', 13 => 'Norsk Tipping initiell', 14 => 'Norsk Tipping IBM', 26 => 'Mobilnet', 27 => 'Ikke fakturerbar feilretting for kunde', 28 => 'Ikke fakturerbar support for kunde', 29 => 'Ikke fakturerbar videreutvikling CPAS', 30 => 'Ikke fakturerbar videreutvikling SISS', 31 => 'Ikke fakturerbar videreutvikling diverse', 34 => 'Interne oppgaver spesifisert', 35 => 'Fakturerbar support mindre kunder', 43 => 'Support Modem', 46 => 'CPAS 5,0 SMS', 49 => 'CPAS 5,0 MMS', 52 => 'Lysstyring', 54 => 'GoPocket', 55 => 'Mobilnet WAP Plattform', 56 => 'De norske Bokklubbene', 57 => 'NSB SIT MK2', 58 => 'Cargonet Oppgr 2003', 60 => 'Porteringsprosjektet', 61 => 'M2M server', 62 => 'Mesta', 63 => 'GSM-R Pilot', 64 => 'CTU', 66 => 'Netcom utvidede takstklasser', 67 => 'Gateway', 68 => 'Diverse til lager', 69 => 'Trådløs bedrift', 70 => 'Abonnementshåndtering', 71 => 'Utvikling applikasjoner', 72 => 'NSB Materiell', 73 => 'JBV kameraovervåkning', 74 => 'Conax, Globacom', 75 => 'Pilot for enhetstracking', 76 => 'CPAS 5.0 WAP', 78 => 'Support WAT', 79 => 'M2M Fleet', 80 => 'Transportsentralen Lillestrøm', 81 => 'GFS', } Backlog.reset_column_information projects.each do |invoice_code, name| if backlog = Backlog.find_by_invoice_code(invoice_code.to_s) if backlog.invoice_code.nil? || backlog.invoice_code.length >= 31 puts "Set Mamut project code to #{invoice_code} for '#{name}'" backlog.invoice_code = invoice_code backlog.save! end else puts "Adding Mamut project #{invoice_code} #{name}" Backlog.new(:invoice_code => invoice_code, :name => name).save! end end users = { 'uwe' => 'Uwe Kubosch', 'lars' => 'Lars Ingjer larsi@datek.no' } users.each do |login, full_name| unless User.find_by_login(login) puts "Added user #{login} #{full_name}" first_name = full_name.split[0] last_name = full_name.split[1] email = full_name.split[2] || (login + '@datek.no') execute "INSERT INTO users (login, salted_password, email, first_name, last_name, salt, verified, role, security_token, token_expiry, deleted) VALUES ('#{login}', '8db087dd79f0f904be5027f27becd517a9df6055', '#{email}', '#{first_name}', '#{last_name}', '48aaecbc8568ffb9913177d5369b54c5eb603237', true, NULL, '32b3ab565d89cf066b0c286fd203bb65824b26f9', '2007-06-13 13:41:54', false)" end end end end def self.down execute "UPDATE backlogs SET name = SUBSTR(name, 0, 33)" change_column :backlogs, :name, :string, :limit => 32, :null => false end class Backlog < ActiveRecord::Base end class Period < ActiveRecord::Base end class User < ActiveRecord::Base end end