diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-03-21 22:12:25 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-03-21 22:12:25 +0000 |
commit | 4c357d84960bc3cbaf26db8d9a94eccbf95f9a34 (patch) | |
tree | 57cd4875f0a7231bd041eef0c2b0648243d7672e /lib/puppet/rails/database | |
parent | 5ad9bf49296d35bcaf527476fa6b700c23e13ee5 (diff) | |
download | puppet-4c357d84960bc3cbaf26db8d9a94eccbf95f9a34.tar.gz puppet-4c357d84960bc3cbaf26db8d9a94eccbf95f9a34.tar.xz puppet-4c357d84960bc3cbaf26db8d9a94eccbf95f9a34.zip |
Adding a migration to create indexes
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2342 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/rails/database')
-rw-r--r-- | lib/puppet/rails/database/001_add_indexes.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/puppet/rails/database/001_add_indexes.rb b/lib/puppet/rails/database/001_add_indexes.rb new file mode 100644 index 000000000..456501e52 --- /dev/null +++ b/lib/puppet/rails/database/001_add_indexes.rb @@ -0,0 +1,38 @@ +class AddIndexes < ActiveRecord::Migration + INDEXES = { + :resources => [[:title, :restype], :host_id, :exported], + :source_files => [:filename, :path], + :puppet_classes => [:name, :host_id], + :hosts => [:name, :ip, :updated_at], + :fact_names => [:name, :host_id], + #:fact_values => [:value, :fact_name_id], + #:param_values => [:value, :param_name_id], + :param_names => [:name, :resource_id], + :tags => [:name, :updated_at], + :taggings => [:tag_id, :taggable_id, :taggable_type] + } + + def self.up + puts "trying" + # Add all of our initial indexes + INDEXES.each do |table, indexes| + indexes.each do |index| + if index.to_s =~ /_id/ + add_index table, index, :integer => true + else + add_index table, index + end + end + end + end + + def self.down + INDEXES.each do |table, indexes| + indexes.each do |index| + remove_index table, index + end + end + end +end + +# $Id$ |