-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs #10055 - Initial model bindings for OSTREE CRUD
- Loading branch information
Showing
12 changed files
with
219 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module Katello | ||
class OstreeBranch < Katello::Model | ||
belongs_to :repository, :class_name => "Katello::Repository", :inverse_of => :ostree_branches | ||
validates :name, presence: true, uniqueness: {scope: :repository_id} | ||
validates :repository_id, :presence => true | ||
validate :ensure_ostree_repository | ||
|
||
def ensure_ostree_repository | ||
unless self.repository.ostree? | ||
errors.add(:base, _("Branch cannot be created since it does not belong to an RPM OSTree repository.")) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
class AddOstreeBranches < ActiveRecord::Migration | ||
def up | ||
create_table :katello_ostree_branches do |t| | ||
t.string :name, :null => false | ||
t.references :repository, :null => false | ||
t.timestamps | ||
end | ||
|
||
add_index :katello_ostree_branches, [:repository_id], | ||
:name => :index_branches_on_repository | ||
|
||
add_foreign_key :katello_ostree_branches, | ||
:katello_repositories, | ||
:column => "repository_id", | ||
:name => "katello_ostree_branches_repository_id_fk" | ||
|
||
add_index :katello_ostree_branches, [:repository_id, :name], | ||
:name => :katello_ostree_branches_repo_branch, :unique => true | ||
end | ||
|
||
def down | ||
remove_foreign_key :katello_ostree_branches, :name => "katello_ostree_branches_repository_id_fk" | ||
drop_table :katello_ostree_branches | ||
end | ||
end |
Oops, something went wrong.