diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-01-15 18:19:19 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-01-15 18:19:19 +0000 |
commit | 1bd5e58c847816ae5751ee0026e55597d1541dd4 (patch) | |
tree | b5c1be1f966f8b08986978713882856d014e363d /db/migrate | |
parent | d996cc0584901e7f44171093b170f882978124f7 (diff) | |
download | redmine-1bd5e58c847816ae5751ee0026e55597d1541dd4.tar.gz redmine-1bd5e58c847816ae5751ee0026e55597d1541dd4.zip |
Adds support for multiple repositories per project (#779).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8650 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'db/migrate')
3 files changed, 32 insertions, 0 deletions
diff --git a/db/migrate/20120115143024_add_repositories_identifier.rb b/db/migrate/20120115143024_add_repositories_identifier.rb new file mode 100644 index 000000000..b54ebd1d5 --- /dev/null +++ b/db/migrate/20120115143024_add_repositories_identifier.rb @@ -0,0 +1,9 @@ +class AddRepositoriesIdentifier < ActiveRecord::Migration + def self.up + add_column :repositories, :identifier, :string + end + + def self.down + remove_column :repositories, :identifier + end +end diff --git a/db/migrate/20120115143100_add_repositories_is_default.rb b/db/migrate/20120115143100_add_repositories_is_default.rb new file mode 100644 index 000000000..87f018120 --- /dev/null +++ b/db/migrate/20120115143100_add_repositories_is_default.rb @@ -0,0 +1,9 @@ +class AddRepositoriesIsDefault < ActiveRecord::Migration + def self.up + add_column :repositories, :is_default, :boolean, :default => false + end + + def self.down + remove_column :repositories, :is_default + end +end diff --git a/db/migrate/20120115143126_set_default_repositories.rb b/db/migrate/20120115143126_set_default_repositories.rb new file mode 100644 index 000000000..cd7674e71 --- /dev/null +++ b/db/migrate/20120115143126_set_default_repositories.rb @@ -0,0 +1,14 @@ +class SetDefaultRepositories < ActiveRecord::Migration + def self.up + Repository.update_all(["is_default = ?", false]) + # Sets the last repository as default in case multiple repositories exist for the same project + Repository.connection.select_values("SELECT r.id FROM #{Repository.table_name} r" + + " WHERE r.id = (SELECT max(r1.id) FROM #{Repository.table_name} r1 WHERE r1.project_id = r.project_id)").each do |i| + Repository.update_all(["is_default = ?", true], ["id = ?", i]) + end + end + + def self.down + Repository.update_all(["is_default = ?", false]) + end +end |