Ticket #4721: db2_migrations.diff
| File db2_migrations.diff, 3.4 kB (added by contact@maik-schmidt.de, 2 years ago) |
|---|
-
test/migration_test.rb
old new 113 113 Person.connection.drop_table :testings rescue nil 114 114 end 115 115 116 # SQL Server and Sybasewill not allow you to add a NOT NULL column116 # SQL Server, Sybase, and DB2 will not allow you to add a NOT NULL column 117 117 # to a table without specifying a default value, so the 118 118 # following test must be skipped 119 unless current_adapter?(:SQLServerAdapter) || current_adapter?(:SybaseAdapter) 119 unless current_adapter?(:SQLServerAdapter) || current_adapter?(:SybaseAdapter) || current_adapter?(:DB2Adapter) 120 120 def test_add_column_not_null_without_default 121 121 Person.connection.create_table :testings do |t| 122 122 t.column :foo, :string -
lib/active_record/connection_adapters/db2_adapter.rb
old new 42 42 super(connection, logger) 43 43 @connection_options = connection_options 44 44 if schema = @connection_options[:schema] 45 with_statement do |stmt| 46 stmt.exec_direct("SET SCHEMA=#{schema}") 47 end 45 execute "SET SCHEMA=#{schema}" 48 46 end 47 db_version = select_value('select versionnumber from sysibm.sysversions') 48 @db2_major_version = db_version.to_s[0].chr.to_i 49 49 end 50 50 51 51 def select_all(sql, name = nil) … … 179 179 '0' 180 180 end 181 181 182 def current_database 183 select_value('select current server from sysibm.sysdummy1') 184 end 185 186 def supports_migrations? 187 @db2_major_version > 7 188 end 189 190 def rename_table(name, new_name) 191 execute "rename table #{name} to #{new_name}" 192 end 193 194 def remove_column(table_name, column_name) 195 execute "alter table #{name} drop column #{column_name}" 196 end 197 198 def change_column_default(table_name, column_name, default) 199 execute "alter table #{table_name} alter column #{column_name} set #{default}" 200 end 201 182 202 def active? 183 203 @connection.select_one 'select 1 from ibm.sysdummy1' 184 204 true -
lib/active_record/vendor/db2.rb
old new 111 111 end 112 112 113 113 def columns(table_name, schema_name = '%') 114 check_rc(SQLColumns(@handle, '', schema_name. upcase, table_name.upcase, '%'))114 check_rc(SQLColumns(@handle, '', schema_name.to_s.upcase, table_name.to_s.upcase, '%')) 115 115 fetch_all 116 116 end 117 117 118 118 def tables(schema_name = '%') 119 check_rc(SQLTables(@handle, '', schema_name. upcase, '%', 'TABLE'))119 check_rc(SQLTables(@handle, '', schema_name.to_s.upcase, '%', 'TABLE')) 120 120 fetch_all 121 121 end 122 122 123 123 def indexes(table_name, schema_name = '') 124 check_rc(SQLStatistics(@handle, '', schema_name. upcase, table_name.upcase, SQL_INDEX_ALL, SQL_ENSURE))124 check_rc(SQLStatistics(@handle, '', schema_name.to_s.upcase, table_name.to_s.upcase, SQL_INDEX_ALL, SQL_ENSURE)) 125 125 fetch_all 126 126 end 127 127