-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[webui] Add migrations for Kiwi Packages
We got the needed attributes found in: - https://doc.opensuse.org/projects/kiwi/schema-doc/ - https://doc.opensuse.org/projects/kiwi/doc/#sec.description.packages We also introduced the needed validations in the models. Pair-programmed by @DavidKang and @Ana06.
- Loading branch information
Showing
8 changed files
with
118 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class Kiwi::Package < ApplicationRecord | ||
belongs_to :package_group | ||
|
||
validates :name, presence: true | ||
end | ||
|
||
# == Schema Information | ||
# | ||
# Table name: kiwi_packages | ||
# | ||
# id :integer not null, primary key | ||
# name :string(255) not null | ||
# arch :string(255) | ||
# replaces :string(255) | ||
# bootinclude :boolean | ||
# bootdelete :boolean | ||
# package_group_id :integer indexed | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
# Indexes | ||
# | ||
# index_kiwi_packages_on_package_group_id (package_group_id) | ||
# |
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,27 @@ | ||
class Kiwi::PackageGroup < ApplicationRecord | ||
has_many :packages | ||
belongs_to :image | ||
|
||
# we need to add a prefix, to avoid generating class methods that already | ||
# exist in Active Record, such as "delete" | ||
enum kiwi_type: %i[bootstrap delete docker image iso lxc oem pxe split testsuite vmx], _prefix: :type | ||
|
||
validates :kiwi_type, presence: true, inclusion: { in: kiwi_types.keys } | ||
end | ||
|
||
# == Schema Information | ||
# | ||
# Table name: kiwi_package_groups | ||
# | ||
# id :integer not null, primary key | ||
# kiwi_type :integer not null | ||
# profiles :string(255) | ||
# pattern_type :string(255) | ||
# image_id :integer indexed | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
# Indexes | ||
# | ||
# index_kiwi_package_groups_on_image_id (image_id) | ||
# |
12 changes: 12 additions & 0 deletions
12
src/api/db/migrate/20170710133627_create_kiwi_package_groups.rb
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,12 @@ | ||
class CreateKiwiPackageGroups < ActiveRecord::Migration[5.1] | ||
def change | ||
create_table :kiwi_package_groups do |t| | ||
t.integer :kiwi_type, null: false | ||
t.string :profiles | ||
t.string :pattern_type | ||
t.belongs_to :image, index: true | ||
|
||
t.timestamps | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class CreateKiwiPackages < ActiveRecord::Migration[5.1] | ||
def change | ||
create_table :kiwi_packages do |t| | ||
t.string :name, null: false | ||
t.string :arch | ||
t.string :replaces | ||
t.boolean :bootinclude | ||
t.boolean :bootdelete | ||
t.belongs_to :package_group, index: true | ||
|
||
t.timestamps | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe Kiwi::PackageGroup, type: :model do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe Kiwi::Package, type: :model do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
end |