[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. debian/0.24.6-1-356-g5718585

Brice Figureau brice at daysofwonder.com
Fri Jan 23 14:20:50 UTC 2009


The following commit has been merged in the master branch:
commit 7accb893d8b4a530aac7ccd402756afb0ce599bd
Author: Brice Figureau <brice-puppet at daysofwonder.com>
Date:   Mon Aug 11 15:58:40 2008 +0200

    id column is autogenerated by rails as a primary key, there is no need
    to create an additional index on this column. This changeset contains the
    new schema and a migration.
    
    Signed-off-by: Brice Figureau <brice-puppet at daysofwonder.com>

diff --git a/lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb b/lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
new file mode 100644
index 0000000..3873a13
--- /dev/null
+++ b/lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
@@ -0,0 +1,17 @@
+class RemoveDuplicatedIndexOnAllTables < ActiveRecord::Migration
+    def self.up
+        ActiveRecord::Base.connection.tables.each do |t|
+            if ActiveRecord::Base.connection.indexes(t).collect {|c| c.columns}.include?("id")
+                remove_index t.to_s, :id
+            end
+        end 
+    end
+
+    def self.down
+        ActiveRecord::Base.connection.tables.each do |t|
+            unless ActiveRecord::Base.connection.indexes(t).collect {|c| c.columns}.include?("id")
+                add_index t.to_s, :id, :integer => true
+            end
+        end    
+    end
+end
diff --git a/lib/puppet/rails/database/schema.rb b/lib/puppet/rails/database/schema.rb
index d11d91a..f3ad2c1 100644
--- a/lib/puppet/rails/database/schema.rb
+++ b/lib/puppet/rails/database/schema.rb
@@ -16,7 +16,6 @@ class Puppet::Rails::Schema
                     t.column :updated_at, :datetime
                     t.column :created_at, :datetime
                 end
-                add_index :resources, :id, :integer => true
                 add_index :resources, :host_id, :integer => true
                 add_index :resources, :source_file_id, :integer => true
 
@@ -34,7 +33,6 @@ class Puppet::Rails::Schema
                     t.column :updated_at, :datetime
                     t.column :created_at, :datetime
                 end
-                add_index :source_files, :id, :integer => true
                 add_index :source_files, :filename
 
                 create_table :resource_tags do |t|
@@ -43,7 +41,6 @@ class Puppet::Rails::Schema
                     t.column :updated_at, :datetime
                     t.column :created_at, :datetime
                 end
-                add_index :resource_tags, :id, :integer => true
                 add_index :resource_tags, :resource_id, :integer => true
                 add_index :resource_tags, :puppet_tag_id, :integer => true
 
@@ -65,7 +62,6 @@ class Puppet::Rails::Schema
                     t.column :source_file_id, :integer
                     t.column :created_at, :datetime
                 end
-                add_index :hosts, :id, :integer => true
                 add_index :hosts, :source_file_id, :integer => true
                 add_index :hosts, :name
 
@@ -74,7 +70,6 @@ class Puppet::Rails::Schema
                     t.column :updated_at, :datetime
                     t.column :created_at, :datetime
                 end
-                add_index :fact_names, :id, :integer => true
                 add_index :fact_names, :name
 
                 create_table :fact_values do |t| 
@@ -84,7 +79,6 @@ class Puppet::Rails::Schema
                     t.column :updated_at, :datetime
                     t.column :created_at, :datetime
                 end 
-                add_index :fact_values, :id, :integer => true
                 add_index :fact_values, :fact_name_id, :integer => true
                 add_index :fact_values, :host_id, :integer => true
 
@@ -96,7 +90,6 @@ class Puppet::Rails::Schema
                     t.column :updated_at, :datetime
                     t.column :created_at, :datetime
                 end
-                add_index :param_values, :id, :integer => true
                 add_index :param_values, :param_name_id, :integer => true
                 add_index :param_values, :resource_id, :integer => true
          
@@ -105,7 +98,6 @@ class Puppet::Rails::Schema
                     t.column :updated_at, :datetime
                     t.column :created_at, :datetime
                 end
-                add_index :param_names, :id, :integer => true
                 add_index :param_names, :name
             end 
         end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list