diff options
Diffstat (limited to 'lib/puppet/rails/database')
-rw-r--r-- | lib/puppet/rails/database/01_puppet_initialize.rb | 45 | ||||
-rw-r--r-- | lib/puppet/rails/database/schema_init.rb | 64 |
2 files changed, 45 insertions, 64 deletions
diff --git a/lib/puppet/rails/database/01_puppet_initialize.rb b/lib/puppet/rails/database/01_puppet_initialize.rb new file mode 100644 index 000000000..485634004 --- /dev/null +++ b/lib/puppet/rails/database/01_puppet_initialize.rb @@ -0,0 +1,45 @@ +class PuppetInitialize < ActiveRecord::Migration + require 'sqlite3' + + def self.up + if ActiveRecord::Migration.respond_to?(:verbose) + ActiveRecord::Migration.verbose = false + end + + # 'type' cannot be a column name, apparently + create_table :rails_resources do |table| + table.column :title, :string, :null => false + table.column :restype, :string, :null => false + table.column :tags, :string + table.column :file, :string + table.column :line, :integer + table.column :host_id, :integer + table.column :exported, :boolean + end + + create_table :rails_parameters do |table| + table.column :name, :string, :null => false + table.column :value, :string, :null => false + table.column :file, :string + table.column :line, :integer + table.column :rails_resource_id, :integer + end + + create_table :hosts do |table| + table.column :name, :string, :null => false + table.column :ip, :string + table.column :facts, :string + table.column :connect, :date + table.column :success, :date + table.column :classes, :string + end + end + + def self.down + drop_table :rails_resources + drop_table :rails_parameters + drop_table :hosts + end +end + +# $Id$ diff --git a/lib/puppet/rails/database/schema_init.rb b/lib/puppet/rails/database/schema_init.rb deleted file mode 100644 index 9151bee46..000000000 --- a/lib/puppet/rails/database/schema_init.rb +++ /dev/null @@ -1,64 +0,0 @@ -class Puppet::Rails::Schema - -def self.init - ActiveRecord::Schema.define do - create_table :resources do |t| - t.column :title, :string, :null => false - t.column :type, :string - t.column :host_id, :integer - t.column :source_file_id, :integer - t.column :exported, :boolean - end - - create_table :source_files do |t| - t.column :filename, :string - t.column :path, :string - end - - create_table :puppet_classes do |t| - t.column :name, :string - t.column :host_id, :integer - t.column :source_file_id, :integer - end - - create_table :hosts do |t| - t.column :name, :string, :null => false - t.column :ip, :string - t.column :connect, :date - #Use updated_at to automatically add timestamp on save. - t.column :updated_at, :date - t.column :source_file_id, :integer - end - - create_table :fact_names do |t| - t.column :name, :string, :null => false - t.column :host_id, :integer, :null => false - end - - create_table :fact_values do |t| - t.column :value, :string, :null => false - t.column :fact_name_id, :integer, :null => false - end - - create_table :param_values do |t| - t.column :value, :string, :null => false - t.column :param_name_id, :integer, :null => false - end - - create_table :param_names do |t| - t.column :name, :string, :null => false - t.column :resource_id, :integer - end - - create_table :tags do |t| - t.column :name, :string - end - - create_table :taggings do |t| - t.column :tag_id, :integer - t.column :taggable_id, :integer - t.column :taggable_type, :string - end - end -end -end |