class ActiveRecord::Migration
+ def self.dialect
+ ActiveRecord::Base.configurations[ ENV['RAILS_ENV'] ]['dialect']
+ end
+
def self.add_index(table_name, column_name, options = {})
# ActiveRecord can generate index names longer than 30 characters, but that's
# not supported by Oracle, the "Enterprise" database.
t.column :text_value, :text, :null => true
t.column :user_id, :integer, :null => true
end
- add_index :properties, :prop_key, :name => 'properties_key'
+
+ if dialect()=='mysql'
+ # Index of varchar column is limited to 767 bytes on mysql (<= 255 UTF-8 characters)
+ # See http://jira.codehaus.org/browse/SONAR-4137 and
+ # http://dev.mysql.com/doc/refman/5.6/en/innodb-restrictions.html
+ add_index :properties, :prop_key, :name => 'properties_key', :length => 255
+ else
+ add_index :properties, :prop_key, :name => 'properties_key'
+ end
end
end
ProjectMeasure.reset_column_information
Snapshot.reset_column_information
- dialect = ActiveRecord::Base.configurations[ ENV['RAILS_ENV'] ]["dialect"]
- say "Detected dialect: #{dialect}"
-
- case dialect
+ case dialect()
when "sqlserver"
upgrade_sqlserver()
when "oracle"
class IncreaseQualifierSize < ActiveRecord::Migration
def self.up
- dialect = ActiveRecord::Base.configurations[ ENV['RAILS_ENV'] ]["dialect"]
-
- if dialect == 'sqlserver'
+ if dialect()=='sqlserver'
remove_index :snapshots, :name => 'snapshots_qualifier'
end
change_column('snapshots', 'qualifier', :string, :limit => 10, :null => true)
change_column('projects', 'qualifier', :string, :limit => 10, :null => true)
- if dialect == 'sqlserver'
+ if dialect()=='sqlserver'
add_index :snapshots, :qualifier, :name => 'snapshots_qualifier'
end
end