From dc739cc18982b7ec79b6681260b133b3161ba028 Mon Sep 17 00:00:00 2001 From: Jez Caudle Date: Sat, 11 Jun 2022 21:13:32 +0100 Subject: [PATCH] Added the priciples, sub principles and the groups. --- app/models/subprinciple.rb | 3 ++ app/models/subprincipleitem.rb | 3 ++ app/models/subprincipleitemgroup.rb | 3 ++ db/migrate/20220611182950_principle.rb | 4 --- .../20220611190503_create_subprinciples.rb | 12 +++++++ ...611192407_create_subprincipalitemgroups.rb | 10 ++++++ ...20220611194255_create_subprincipalitems.rb | 11 +++++++ db/schema.rb | 32 ++++++++++++++++++- test/fixtures/subprincipalitemgroups.yml | 9 ++++++ test/fixtures/subprincipalitems.yml | 11 +++++++ test/fixtures/subprinciples.yml | 11 +++++++ test/models/subprincipalitem_test.rb | 7 ++++ test/models/subprincipalitemgroup_test.rb | 7 ++++ test/models/subprinciple_test.rb | 7 ++++ 14 files changed, 125 insertions(+), 5 deletions(-) create mode 100644 app/models/subprinciple.rb create mode 100644 app/models/subprincipleitem.rb create mode 100644 app/models/subprincipleitemgroup.rb delete mode 100644 db/migrate/20220611182950_principle.rb create mode 100644 db/migrate/20220611190503_create_subprinciples.rb create mode 100644 db/migrate/20220611192407_create_subprincipalitemgroups.rb create mode 100644 db/migrate/20220611194255_create_subprincipalitems.rb create mode 100644 test/fixtures/subprincipalitemgroups.yml create mode 100644 test/fixtures/subprincipalitems.yml create mode 100644 test/fixtures/subprinciples.yml create mode 100644 test/models/subprincipalitem_test.rb create mode 100644 test/models/subprincipalitemgroup_test.rb create mode 100644 test/models/subprinciple_test.rb diff --git a/app/models/subprinciple.rb b/app/models/subprinciple.rb new file mode 100644 index 0000000..9e9fb39 --- /dev/null +++ b/app/models/subprinciple.rb @@ -0,0 +1,3 @@ +class Subprinciple < ApplicationRecord + belongs_to :principle +end diff --git a/app/models/subprincipleitem.rb b/app/models/subprincipleitem.rb new file mode 100644 index 0000000..004e872 --- /dev/null +++ b/app/models/subprincipleitem.rb @@ -0,0 +1,3 @@ +class Subprincipleitem < ApplicationRecord + belongs_to :subprincipleitemgroup +end diff --git a/app/models/subprincipleitemgroup.rb b/app/models/subprincipleitemgroup.rb new file mode 100644 index 0000000..398731e --- /dev/null +++ b/app/models/subprincipleitemgroup.rb @@ -0,0 +1,3 @@ +class Subprincipleitemgroup < ApplicationRecord + belongs_to :subprinciple +end diff --git a/db/migrate/20220611182950_principle.rb b/db/migrate/20220611182950_principle.rb deleted file mode 100644 index 10247f9..0000000 --- a/db/migrate/20220611182950_principle.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Principle < ActiveRecord::Migration[7.0] - def change - end -end diff --git a/db/migrate/20220611190503_create_subprinciples.rb b/db/migrate/20220611190503_create_subprinciples.rb new file mode 100644 index 0000000..ad3bfd7 --- /dev/null +++ b/db/migrate/20220611190503_create_subprinciples.rb @@ -0,0 +1,12 @@ +class CreateSubprinciples < ActiveRecord::Migration[7.0] + def change + create_table :subprinciples do |t| + t.references :principle, null: false, foreign_key: true + t.string :name + t.text :description + + t.timestamps + end + add_index :subprinciples, :name + end +end diff --git a/db/migrate/20220611192407_create_subprincipalitemgroups.rb b/db/migrate/20220611192407_create_subprincipalitemgroups.rb new file mode 100644 index 0000000..2ff6c35 --- /dev/null +++ b/db/migrate/20220611192407_create_subprincipalitemgroups.rb @@ -0,0 +1,10 @@ +class CreateSubprincipalitemgroups < ActiveRecord::Migration[7.0] + def change + create_table :subprincipleitemgroups do |t| + t.references :subprinciple, null: false, foreign_key: true + t.string :type + + t.timestamps + end + end +end diff --git a/db/migrate/20220611194255_create_subprincipalitems.rb b/db/migrate/20220611194255_create_subprincipalitems.rb new file mode 100644 index 0000000..910bd71 --- /dev/null +++ b/db/migrate/20220611194255_create_subprincipalitems.rb @@ -0,0 +1,11 @@ +class CreateSubprincipalitems < ActiveRecord::Migration[7.0] + def change + create_table :subprinciplitems do |t| + t.references :subprincipleitemgroup, null: false, foreign_key: true + t.text :description + t.boolean :affirmative + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index f92d193..ff0a104 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2022_06_11_183116) do +ActiveRecord::Schema[7.0].define(version: 2022_06_11_194255) do create_table "action_text_rich_texts", charset: "latin1", force: :cascade do |t| t.string "name", null: false t.text "body", size: :long @@ -81,6 +81,33 @@ ActiveRecord::Schema[7.0].define(version: 2022_06_11_183116) do t.index ["name"], name: "index_principles_on_name" end + create_table "subprincipleitemgroups", charset: "latin1", force: :cascade do |t| + t.bigint "subprinciple_id", null: false + t.string "type" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["subprinciple_id"], name: "index_subprincipleitemgroups_on_subprinciple_id" + end + + create_table "subprinciples", charset: "latin1", force: :cascade do |t| + t.bigint "principle_id", null: false + t.string "name" + t.text "description" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["name"], name: "index_subprinciples_on_name" + t.index ["principle_id"], name: "index_subprinciples_on_principle_id" + end + + create_table "subprinciplitems", charset: "latin1", force: :cascade do |t| + t.bigint "subprincipleitemgroup_id", null: false + t.text "description" + t.boolean "affirmative" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["subprincipleitemgroup_id"], name: "index_subprinciplitems_on_subprincipleitemgroup_id" + end + create_table "users", charset: "latin1", force: :cascade do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false @@ -107,4 +134,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_06_11_183116) do add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" add_foreign_key "cafs", "companies" add_foreign_key "principles", "cafs" + add_foreign_key "subprincipleitemgroups", "subprinciples" + add_foreign_key "subprinciples", "principles" + add_foreign_key "subprinciplitems", "subprincipleitemgroups" end diff --git a/test/fixtures/subprincipalitemgroups.yml b/test/fixtures/subprincipalitemgroups.yml new file mode 100644 index 0000000..53e3721 --- /dev/null +++ b/test/fixtures/subprincipalitemgroups.yml @@ -0,0 +1,9 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + subprinciple: one + type: + +two: + subprinciple: two + type: diff --git a/test/fixtures/subprincipalitems.yml b/test/fixtures/subprincipalitems.yml new file mode 100644 index 0000000..590ade7 --- /dev/null +++ b/test/fixtures/subprincipalitems.yml @@ -0,0 +1,11 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + subprincipleitemgroup: one + description: MyText + affirmative: false + +two: + subprincipleitemgroup: two + description: MyText + affirmative: false diff --git a/test/fixtures/subprinciples.yml b/test/fixtures/subprinciples.yml new file mode 100644 index 0000000..43cbcf7 --- /dev/null +++ b/test/fixtures/subprinciples.yml @@ -0,0 +1,11 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + principle: one + name: MyString + description: MyText + +two: + principle: two + name: MyString + description: MyText diff --git a/test/models/subprincipalitem_test.rb b/test/models/subprincipalitem_test.rb new file mode 100644 index 0000000..b03869b --- /dev/null +++ b/test/models/subprincipalitem_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class SubprincipalitemTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/subprincipalitemgroup_test.rb b/test/models/subprincipalitemgroup_test.rb new file mode 100644 index 0000000..62e79d6 --- /dev/null +++ b/test/models/subprincipalitemgroup_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class SubprincipalitemgroupTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/subprinciple_test.rb b/test/models/subprinciple_test.rb new file mode 100644 index 0000000..78819cf --- /dev/null +++ b/test/models/subprinciple_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class SubprincipleTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end