summaryrefslogtreecommitdiffstats
path: root/lib/puppet/rails/database
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/rails/database')
-rw-r--r--lib/puppet/rails/database/001_add_created_at_to_all_tables.rb16
-rw-r--r--lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb16
-rw-r--r--lib/puppet/rails/database/003_add_environment_to_host.rb12
-rw-r--r--lib/puppet/rails/database/schema.rb198
4 files changed, 121 insertions, 121 deletions
diff --git a/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb b/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb
index 65432a6b7..22dffb854 100644
--- a/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb
+++ b/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb
@@ -1,13 +1,13 @@
class AddCreatedAtToAllTables < ActiveRecord::Migration
- def self.up
- ActiveRecord::Base.connection.tables.each do |t|
- add_column t.to_s, :created_at, :datetime unless ActiveRecord::Base.connection.columns(t).collect {|c| c.name}.include?("created_at")
- end
+ def self.up
+ ActiveRecord::Base.connection.tables.each do |t|
+ add_column t.to_s, :created_at, :datetime unless ActiveRecord::Base.connection.columns(t).collect {|c| c.name}.include?("created_at")
end
+ end
- def self.down
- ActiveRecord::Base.connection.tables.each do |t|
- remove_column t.to_s, :created_at unless ActiveRecord::Base.connection.columns(t).collect {|c| c.name}.include?("created_at")
- end
+ def self.down
+ ActiveRecord::Base.connection.tables.each do |t|
+ remove_column t.to_s, :created_at unless ActiveRecord::Base.connection.columns(t).collect {|c| c.name}.include?("created_at")
end
+ end
end
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
index c1e60db14..021889df7 100644
--- 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
@@ -1,13 +1,13 @@
class RemoveDuplicatedIndexOnAllTables < ActiveRecord::Migration
- def self.up
- ActiveRecord::Base.connection.tables.each do |t|
- remove_index t.to_s, :id if ActiveRecord::Base.connection.indexes(t).collect {|c| c.columns}.include?("id")
- end
+ def self.up
+ ActiveRecord::Base.connection.tables.each do |t|
+ remove_index t.to_s, :id if ActiveRecord::Base.connection.indexes(t).collect {|c| c.columns}.include?("id")
end
+ end
- def self.down
- ActiveRecord::Base.connection.tables.each do |t|
- add_index t.to_s, :id, :integer => true unless ActiveRecord::Base.connection.indexes(t).collect {|c| c.columns}.include?("id")
- end
+ def self.down
+ ActiveRecord::Base.connection.tables.each do |t|
+ add_index t.to_s, :id, :integer => true unless ActiveRecord::Base.connection.indexes(t).collect {|c| c.columns}.include?("id")
end
+ end
end
diff --git a/lib/puppet/rails/database/003_add_environment_to_host.rb b/lib/puppet/rails/database/003_add_environment_to_host.rb
index 95f036d11..5c06bb8c0 100644
--- a/lib/puppet/rails/database/003_add_environment_to_host.rb
+++ b/lib/puppet/rails/database/003_add_environment_to_host.rb
@@ -1,9 +1,9 @@
class AddEnvironmentToHost < ActiveRecord::Migration
- def self.up
- add_column :hosts, :environment, :string unless ActiveRecord::Base.connection.columns(:hosts).collect {|c| c.name}.include?("environment")
- end
+ def self.up
+ add_column :hosts, :environment, :string unless ActiveRecord::Base.connection.columns(:hosts).collect {|c| c.name}.include?("environment")
+ end
- def self.down
- remove_column :hosts, :environment if ActiveRecord::Base.connection.columns(:hosts).collect {|c| c.name}.include?("environment")
- end
+ def self.down
+ remove_column :hosts, :environment if ActiveRecord::Base.connection.columns(:hosts).collect {|c| c.name}.include?("environment")
+ end
end
diff --git a/lib/puppet/rails/database/schema.rb b/lib/puppet/rails/database/schema.rb
index 8cb7350eb..8b389d773 100644
--- a/lib/puppet/rails/database/schema.rb
+++ b/lib/puppet/rails/database/schema.rb
@@ -1,114 +1,114 @@
class Puppet::Rails::Schema
- def self.init
- oldout = nil
- Puppet::Util.benchmark(Puppet, :notice, "Initialized database") do
- # We want to rewrite stdout, so we don't get migration messages.
- oldout = $stdout
- $stdout = File.open("/dev/null", "w")
- ActiveRecord::Schema.define do
- create_table :resources do |t|
- t.column :title, :text, :null => false
- t.column :restype, :string, :null => false
- t.column :host_id, :integer
- t.column :source_file_id, :integer
- t.column :exported, :boolean
- t.column :line, :integer
- t.column :updated_at, :datetime
- t.column :created_at, :datetime
- end
- add_index :resources, :host_id, :integer => true
- add_index :resources, :source_file_id, :integer => true
+ def self.init
+ oldout = nil
+ Puppet::Util.benchmark(Puppet, :notice, "Initialized database") do
+ # We want to rewrite stdout, so we don't get migration messages.
+ oldout = $stdout
+ $stdout = File.open("/dev/null", "w")
+ ActiveRecord::Schema.define do
+ create_table :resources do |t|
+ t.column :title, :text, :null => false
+ t.column :restype, :string, :null => false
+ t.column :host_id, :integer
+ t.column :source_file_id, :integer
+ t.column :exported, :boolean
+ t.column :line, :integer
+ t.column :updated_at, :datetime
+ t.column :created_at, :datetime
+ end
+ add_index :resources, :host_id, :integer => true
+ add_index :resources, :source_file_id, :integer => true
- # Thanks, mysql! MySQL requires a length on indexes in text fields.
- # So, we provide them for mysql and handle everything else specially.
- # Oracle doesn't index on CLOB fields, so we skip it
- if Puppet[:dbadapter] == "mysql"
- execute "CREATE INDEX typentitle ON resources (restype,title(50));"
- elsif Puppet[:dbadapter] != "oracle_enhanced"
- add_index :resources, [:title, :restype]
- end
+ # Thanks, mysql! MySQL requires a length on indexes in text fields.
+ # So, we provide them for mysql and handle everything else specially.
+ # Oracle doesn't index on CLOB fields, so we skip it
+ if Puppet[:dbadapter] == "mysql"
+ execute "CREATE INDEX typentitle ON resources (restype,title(50));"
+ elsif Puppet[:dbadapter] != "oracle_enhanced"
+ add_index :resources, [:title, :restype]
+ end
- create_table :source_files do |t|
- t.column :filename, :string
- t.column :path, :string
- t.column :updated_at, :datetime
- t.column :created_at, :datetime
- end
- add_index :source_files, :filename
+ create_table :source_files do |t|
+ t.column :filename, :string
+ t.column :path, :string
+ t.column :updated_at, :datetime
+ t.column :created_at, :datetime
+ end
+ add_index :source_files, :filename
- create_table :resource_tags do |t|
- t.column :resource_id, :integer
- t.column :puppet_tag_id, :integer
- t.column :updated_at, :datetime
- t.column :created_at, :datetime
- end
- add_index :resource_tags, :resource_id, :integer => true
- add_index :resource_tags, :puppet_tag_id, :integer => true
+ create_table :resource_tags do |t|
+ t.column :resource_id, :integer
+ t.column :puppet_tag_id, :integer
+ t.column :updated_at, :datetime
+ t.column :created_at, :datetime
+ end
+ add_index :resource_tags, :resource_id, :integer => true
+ add_index :resource_tags, :puppet_tag_id, :integer => true
- create_table :puppet_tags do |t|
- t.column :name, :string
- t.column :updated_at, :datetime
- t.column :created_at, :datetime
- end
+ create_table :puppet_tags do |t|
+ t.column :name, :string
+ t.column :updated_at, :datetime
+ t.column :created_at, :datetime
+ end
- # Oracle automatically creates a primary key index
- add_index :puppet_tags, :id, :integer => true if Puppet[:dbadapter] != "oracle_enhanced"
+ # Oracle automatically creates a primary key index
+ add_index :puppet_tags, :id, :integer => true if Puppet[:dbadapter] != "oracle_enhanced"
- create_table :hosts do |t|
- t.column :name, :string, :null => false
- t.column :ip, :string
- t.column :environment, :text
- t.column :last_compile, :datetime
- t.column :last_freshcheck, :datetime
- t.column :last_report, :datetime
- #Use updated_at to automatically add timestamp on save.
- t.column :updated_at, :datetime
- t.column :source_file_id, :integer
- t.column :created_at, :datetime
- end
- add_index :hosts, :source_file_id, :integer => true
- add_index :hosts, :name
+ create_table :hosts do |t|
+ t.column :name, :string, :null => false
+ t.column :ip, :string
+ t.column :environment, :text
+ t.column :last_compile, :datetime
+ t.column :last_freshcheck, :datetime
+ t.column :last_report, :datetime
+ #Use updated_at to automatically add timestamp on save.
+ t.column :updated_at, :datetime
+ t.column :source_file_id, :integer
+ t.column :created_at, :datetime
+ end
+ add_index :hosts, :source_file_id, :integer => true
+ add_index :hosts, :name
- create_table :fact_names do |t|
- t.column :name, :string, :null => false
- t.column :updated_at, :datetime
- t.column :created_at, :datetime
- end
- add_index :fact_names, :name
+ create_table :fact_names do |t|
+ t.column :name, :string, :null => false
+ t.column :updated_at, :datetime
+ t.column :created_at, :datetime
+ end
+ add_index :fact_names, :name
- create_table :fact_values do |t|
- t.column :value, :text, :null => false
- t.column :fact_name_id, :integer, :null => false
- t.column :host_id, :integer, :null => false
- t.column :updated_at, :datetime
- t.column :created_at, :datetime
- end
- add_index :fact_values, :fact_name_id, :integer => true
- add_index :fact_values, :host_id, :integer => true
+ create_table :fact_values do |t|
+ t.column :value, :text, :null => false
+ t.column :fact_name_id, :integer, :null => false
+ t.column :host_id, :integer, :null => false
+ t.column :updated_at, :datetime
+ t.column :created_at, :datetime
+ end
+ add_index :fact_values, :fact_name_id, :integer => true
+ add_index :fact_values, :host_id, :integer => true
- create_table :param_values do |t|
- t.column :value, :text, :null => false
- t.column :param_name_id, :integer, :null => false
- t.column :line, :integer
- t.column :resource_id, :integer
- t.column :updated_at, :datetime
- t.column :created_at, :datetime
- end
- add_index :param_values, :param_name_id, :integer => true
- add_index :param_values, :resource_id, :integer => true
+ create_table :param_values do |t|
+ t.column :value, :text, :null => false
+ t.column :param_name_id, :integer, :null => false
+ t.column :line, :integer
+ t.column :resource_id, :integer
+ t.column :updated_at, :datetime
+ t.column :created_at, :datetime
+ end
+ add_index :param_values, :param_name_id, :integer => true
+ add_index :param_values, :resource_id, :integer => true
- create_table :param_names do |t|
- t.column :name, :string, :null => false
- t.column :updated_at, :datetime
- t.column :created_at, :datetime
- end
- add_index :param_names, :name
- end
+ create_table :param_names do |t|
+ t.column :name, :string, :null => false
+ t.column :updated_at, :datetime
+ t.column :created_at, :datetime
end
- ensure
- $stdout.close
- $stdout = oldout if oldout
- oldout = nil
+ add_index :param_names, :name
+ end
end
+ ensure
+ $stdout.close
+ $stdout = oldout if oldout
+ oldout = nil
+ end
end