Skip to content

Commit

Permalink
distros - adding system_template_distribution table
Browse files Browse the repository at this point in the history
  • Loading branch information
lzap committed Oct 31, 2011
1 parent c9be5a1 commit 129f579
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/app/models/system_template.rb
Expand Up @@ -42,6 +42,7 @@ class SystemTemplate < ActiveRecord::Base
has_many :packages, :class_name => "SystemTemplatePackage", :inverse_of => :system_template, :dependent => :destroy
has_many :package_groups, :class_name => "SystemTemplatePackGroup", :inverse_of => :system_template, :dependent => :destroy
has_many :pg_categories, :class_name => "SystemTemplatePgCategory", :inverse_of => :system_template, :dependent => :destroy
has_many :distributions, :class_name => "SystemTemplateDistribution", :inverse_of => :system_template, :dependent => :destroy

attr_accessor :host_group
lazy_accessor :parameters, :initializer => lambda { init_parameters }, :unless => lambda { false }
Expand Down
16 changes: 16 additions & 0 deletions src/app/models/system_template_distribution.rb
@@ -0,0 +1,16 @@
#
# Copyright 2011 Red Hat, Inc.
#
# This software is licensed to you under the GNU General Public
# License as published by the Free Software Foundation; either version
# 2 of the License (GPLv2) or (at your option) any later version.
# There is NO WARRANTY for this software, express or implied,
# including the implied warranties of MERCHANTABILITY,
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
# have received a copy of GPLv2 along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.

class SystemTemplateDistribution < ActiveRecord::Base
belongs_to :system_template, :inverse_of => :distributions
validates_uniqueness_of [:distribution_cp_id], :scope => :system_template_id, :message => _("is already in the template")
end
13 changes: 13 additions & 0 deletions src/db/migrate/20111026133825_add_system_template_distribution.rb
@@ -0,0 +1,13 @@
class AddSystemTemplateDistribution < ActiveRecord::Migration
def self.up
create_table :system_template_distributions do |t|
t.integer :system_template_id, :null => false
t.string :distribution_pulp_id, :null => false
end
add_index :system_template_distributions, :system_template_id
end

def self.down
drop_table :system_template_distributions
end
end

0 comments on commit 129f579

Please sign in to comment.