sqlserver.patch

Pavel Rosick√Ĺ, 2019-06-11 21:34

Download (4.55 KB)

View differences:

db/migrate/087_change_projects_description_to_text.rb (working copy)
1 1
class ChangeProjectsDescriptionToText < ActiveRecord::Migration[4.2]
2 2
  def self.up
3
    if Redmine::Database.sqlserver?
4
      change_column :projects, :description, :text
5
    end
3 6
    change_column :projects, :description, :text, :null => true, :default => nil
4 7
  end
5 8

  
db/migrate/20100705164950_change_changes_path_length_limit.rb (working copy)
1 1
class ChangeChangesPathLengthLimit < ActiveRecord::Migration[4.2]
2 2
  def self.up
3
    if Redmine::Database.sqlserver?
4
      change_column :changes, :path, :text
5
    end
3 6
    # these are two steps to please MySQL 5 on Win32
4 7
    change_column :changes, :path, :text, :default => nil, :null => true
5 8
    change_column :changes, :path, :text, :null => false
db/migrate/20151020182334_change_attachments_filesize_limit_to_8.rb (working copy)
1 1
class ChangeAttachmentsFilesizeLimitTo8 < ActiveRecord::Migration[4.2]
2 2
  def self.up
3
    change_column :attachments, :filesize, :integer, :limit => 8, :default => 0, :null => false
3
    if Redmine::Database.sqlserver?
4
      change_column :attachments, :filesize, :bigint
5
      change_column :attachments, :filesize, :bigint, :limit => 8, :default => 0, :null => false
6
    else
7
      change_column :attachments, :filesize, :integer, :limit => 8, :default => 0, :null => false
8
    end
4 9
  end
5 10

  
6 11
  def self.down
Gemfile (working copy)
59 59
      when /sqlite3/
60 60
        gem "sqlite3", "~> 1.4.0", :platforms => [:mri, :mingw, :x64_mingw]
61 61
      when /sqlserver/
62
        gem "tiny_tds", "~> 1.0.5", :platforms => [:mri, :mingw, :x64_mingw]
63
        gem "activerecord-sqlserver-adapter", :platforms => [:mri, :mingw, :x64_mingw]
62
        gem "tiny_tds", "~> 2.1.2", :platforms => [:mri, :mingw, :x64_mingw]
63
        gem "activerecord-sqlserver-adapter", "~> 5.2.0", :platforms => [:mri, :mingw, :x64_mingw]
64 64
      else
65 65
        warn("Unknown database adapter `#{adapter}` found in config/database.yml, use Gemfile.local to load your own database gems")
66 66
      end
lib/redmine/database.rb (working copy)
51 51
        /mysql/i.match?(ActiveRecord::Base.connection.adapter_name)
52 52
      end
53 53

  
54
      # Returns true if the database is SQL Server
55
      def sqlserver?
56
        /sqlserver/i.match?(ActiveRecord::Base.connection.adapter_name)
57
      end
58

  
54 59
      # Returns a SQL statement for case/accent (if possible) insensitive match
55 60
      def like(left, right, options={})
56 61
        neg = (options[:match] == false ? 'NOT ' : '')
lib/redmine/nested_set/issue_nested_set.rb (working copy)
151 151
      end
152 152

  
153 153
      def lock_nested_set
154
        if /sqlserver/i.match?(self.class.connection.adapter_name)
154
        if Redmine::Database.sqlserver?
155 155
          lock = "WITH (ROWLOCK HOLDLOCK UPDLOCK)"
156 156
          # Custom lock for SQLServer
157 157
          # This can be problematic if root_id or parent root_id changes
lib/redmine/nested_set/project_nested_set.rb (working copy)
121 121

  
122 122
      def lock_nested_set
123 123
        lock = true
124
        if /sqlserver/i.match?(self.class.connection.adapter_name)
124
        if Redmine::Database.sqlserver?
125 125
          lock = "WITH (ROWLOCK HOLDLOCK UPDLOCK)"
126 126
        end
127 127
        self.class.order(:id).lock(lock).ids