From dda03a1a9a0469cddd0a299ffd229efd02371df5 Mon Sep 17 00:00:00 2001 From: Jez Caudle Date: Thu, 26 Jan 2023 06:19:48 +0000 Subject: [PATCH] It is PRINCIPLES - truths; not PRINCIPALS - people in charge of schools or racing teams. By deleteing the dev database, recreating it from migrations and then preparing the test database; the foreign key contraints now work. Also the database tables are now uft8mb4 instead of lantin1. May be an idea to do this every time there is a rails update until going live. --- Gemfile.lock | 4 +- config/credentials.yml.enc | 2 +- ...11192407_create_subprincipleitemgroups.rb} | 2 +- ...0220611194255_create_subprincipleitems.rb} | 4 +- db/schema.rb | 42 +++++++++---------- db/seeds.rb | 7 ++++ test/fixtures/cafs.yml | 20 ++++----- test/fixtures/companies.yml | 10 ++--- test/fixtures/principles.yml | 20 ++++----- test/fixtures/subprincipalitems.yml | 11 ----- ...mgroups.yml => subprincipleitemgroups.yml} | 14 +++---- test/fixtures/subprincipleitems.yml | 11 +++++ test/fixtures/subprinciples.yml | 20 ++++----- test/fixtures/users.yml | 10 ++--- test/models/company_test.rb | 2 +- 15 files changed, 93 insertions(+), 86 deletions(-) rename db/migrate/{20220611192407_create_subprincipalitemgroups.rb => 20220611192407_create_subprincipleitemgroups.rb} (74%) rename db/migrate/{20220611194255_create_subprincipalitems.rb => 20220611194255_create_subprincipleitems.rb} (63%) delete mode 100644 test/fixtures/subprincipalitems.yml rename test/fixtures/{subprincipalitemgroups.yml => subprincipleitemgroups.yml} (53%) create mode 100644 test/fixtures/subprincipleitems.yml diff --git a/Gemfile.lock b/Gemfile.lock index 96e78c5..3c64644 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: https://github.com/puma/puma - revision: 3f4e3c8ca689e39218459836b939c39fa81e2692 + revision: b67e6d594a473d5e0ab6317efb034ee5009570fe branch: master specs: puma (6.0.2) @@ -105,7 +105,7 @@ GEM warden (~> 1.2.3) erubi (1.12.0) ffi (1.15.5) - globalid (1.0.1) + globalid (1.1.0) activesupport (>= 5.0) i18n (1.12.0) concurrent-ruby (~> 1.0) diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc index 96661de..6464627 100644 --- a/config/credentials.yml.enc +++ b/config/credentials.yml.enc @@ -1 +1 @@ -0wlK+j+11NIKe85Pfu3w0OdiLVM6fawzZlFSWnvy5fUqRC0A6dVV90yDOfPJh5QEFcvH0Yxe6KcWElZE3ZnYgHWJS9UspLfICs6W+hvNfoUoHW8jyO7fkwcj85RknNrjV+j+XavDFhSRk8wFhQDdLyH4DZrwVRJlCACikuBNcZKvrhe7OvgXvpzKukV4w8lm2MAV0onBSmqBNYv4/24blLb9rIJ17EJVS7TLTccq+fHcQzHT6qZHxRqT/AaRXWaCdoa356j35pmQcwjcaX0gfss9fQVf4zuk7BZqsGrQY7rxgyFsnmdaM6uaK6E8R9tiZjQweJkBOGqlTSZRfEIzdhNwY6FpCZF2xRjOscFOP74Qlbdt5CYNBRMZZM1Dfb3unfeiPj+TOqxKCvYrgqxINwkwe2R8FduyFej4--AYr+gbb69YPkX87U--cM9+bFKTYD1vwbH5k0gnYQ== \ No newline at end of file +0wlK+j+11NIKe85Pfu3w0OdiLVM6fawzZlFSWnvy5fUqRC0A6dVV90yDOfPJh5QEFcvH0Yxe6KcWElZE3ZnYgHWJS9UspLfICs6W+hvNfoUoHW8jyO7fkwcj85RknNrjV+j+XavDFhSRk8wFhQDdLyH4DZrwVRJlCACikuBNcZKvrhe7OvgXvpzKukV4w8lm2MAV0onBSmqBNYv4/24blLb9rIJ17EJVS7TLTccq+fHcQzHT6qZHxRqT/AaRXWaCdoa356j35pmQcwjcaX0gfss9fQVf4zuk7BZqsGrQY7rxgyFsnmdaM6uaK6E8R9tiZjQweJkBOGqlTSZRfEIzdhNwY6FpCZF2xRjOscFOP74Qlbdt5CYNBRMZZM1Dfb3unfeiPj+TOqxKCvYrgqxINwkwe2R8FduyFej4--AYr+gbb69YPkX87U--cM9+bFKTYD1vwbH5k0gnYQ== diff --git a/db/migrate/20220611192407_create_subprincipalitemgroups.rb b/db/migrate/20220611192407_create_subprincipleitemgroups.rb similarity index 74% rename from db/migrate/20220611192407_create_subprincipalitemgroups.rb rename to db/migrate/20220611192407_create_subprincipleitemgroups.rb index 2ff6c35..eab0644 100644 --- a/db/migrate/20220611192407_create_subprincipalitemgroups.rb +++ b/db/migrate/20220611192407_create_subprincipleitemgroups.rb @@ -1,4 +1,4 @@ -class CreateSubprincipalitemgroups < ActiveRecord::Migration[7.0] +class CreateSubprincipleitemgroups < ActiveRecord::Migration[7.0] def change create_table :subprincipleitemgroups do |t| t.references :subprinciple, null: false, foreign_key: true diff --git a/db/migrate/20220611194255_create_subprincipalitems.rb b/db/migrate/20220611194255_create_subprincipleitems.rb similarity index 63% rename from db/migrate/20220611194255_create_subprincipalitems.rb rename to db/migrate/20220611194255_create_subprincipleitems.rb index 910bd71..b99cdfd 100644 --- a/db/migrate/20220611194255_create_subprincipalitems.rb +++ b/db/migrate/20220611194255_create_subprincipleitems.rb @@ -1,6 +1,6 @@ -class CreateSubprincipalitems < ActiveRecord::Migration[7.0] +class CreateSubprincipleitems < ActiveRecord::Migration[7.0] def change - create_table :subprinciplitems do |t| + create_table :subprincipleitems do |t| t.references :subprincipleitemgroup, null: false, foreign_key: true t.text :description t.boolean :affirmative diff --git a/db/schema.rb b/db/schema.rb index ff0a104..8c037f2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # It's strongly recommended that you check this file into your version control system. ActiveRecord::Schema[7.0].define(version: 2022_06_11_194255) do - create_table "action_text_rich_texts", charset: "latin1", force: :cascade do |t| + create_table "action_text_rich_texts", charset: "utf8mb4", force: :cascade do |t| t.string "name", null: false t.text "body", size: :long t.string "record_type", null: false @@ -21,7 +21,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_06_11_194255) do t.index ["record_type", "record_id", "name"], name: "index_action_text_rich_texts_uniqueness", unique: true end - create_table "active_storage_attachments", charset: "latin1", force: :cascade do |t| + create_table "active_storage_attachments", charset: "utf8mb4", force: :cascade do |t| t.string "name", null: false t.string "record_type", null: false t.bigint "record_id", null: false @@ -31,7 +31,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_06_11_194255) do t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true end - create_table "active_storage_blobs", charset: "latin1", force: :cascade do |t| + create_table "active_storage_blobs", charset: "utf8mb4", force: :cascade do |t| t.string "key", null: false t.string "filename", null: false t.string "content_type" @@ -43,13 +43,13 @@ ActiveRecord::Schema[7.0].define(version: 2022_06_11_194255) do t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true end - create_table "active_storage_variant_records", charset: "latin1", force: :cascade do |t| + create_table "active_storage_variant_records", charset: "utf8mb4", force: :cascade do |t| t.bigint "blob_id", null: false t.string "variation_digest", null: false t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true end - create_table "cafs", charset: "latin1", force: :cascade do |t| + create_table "cafs", charset: "utf8mb4", force: :cascade do |t| t.bigint "company_id", null: false t.string "name" t.text "description" @@ -58,20 +58,20 @@ ActiveRecord::Schema[7.0].define(version: 2022_06_11_194255) do t.index ["company_id"], name: "index_cafs_on_company_id" end - create_table "companies", charset: "latin1", force: :cascade do |t| + create_table "companies", charset: "utf8mb4", force: :cascade do |t| t.string "name" t.datetime "created_at", null: false t.datetime "updated_at", null: false end - create_table "companies_users", id: false, charset: "latin1", force: :cascade do |t| + create_table "companies_users", id: false, charset: "utf8mb4", force: :cascade do |t| t.bigint "user_id" t.bigint "company_id" t.index ["company_id"], name: "index_companies_users_on_company_id" t.index ["user_id"], name: "index_companies_users_on_user_id" end - create_table "principles", charset: "latin1", force: :cascade do |t| + create_table "principles", charset: "utf8mb4", force: :cascade do |t| t.bigint "caf_id", null: false t.string "name" t.text "description" @@ -81,7 +81,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_06_11_194255) do t.index ["name"], name: "index_principles_on_name" end - create_table "subprincipleitemgroups", charset: "latin1", force: :cascade do |t| + create_table "subprincipleitemgroups", charset: "utf8mb4", force: :cascade do |t| t.bigint "subprinciple_id", null: false t.string "type" t.datetime "created_at", null: false @@ -89,7 +89,16 @@ ActiveRecord::Schema[7.0].define(version: 2022_06_11_194255) do t.index ["subprinciple_id"], name: "index_subprincipleitemgroups_on_subprinciple_id" end - create_table "subprinciples", charset: "latin1", force: :cascade do |t| + create_table "subprincipleitems", charset: "utf8mb4", 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_subprincipleitems_on_subprincipleitemgroup_id" + end + + create_table "subprinciples", charset: "utf8mb4", force: :cascade do |t| t.bigint "principle_id", null: false t.string "name" t.text "description" @@ -99,16 +108,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_06_11_194255) do 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| + create_table "users", charset: "utf8mb4", force: :cascade do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false t.string "reset_password_token" @@ -135,6 +135,6 @@ ActiveRecord::Schema[7.0].define(version: 2022_06_11_194255) do add_foreign_key "cafs", "companies" add_foreign_key "principles", "cafs" add_foreign_key "subprincipleitemgroups", "subprinciples" + add_foreign_key "subprincipleitems", "subprincipleitemgroups" add_foreign_key "subprinciples", "principles" - add_foreign_key "subprinciplitems", "subprincipleitemgroups" end diff --git a/db/seeds.rb b/db/seeds.rb index bc25fce..48c0de6 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -5,3 +5,10 @@ # # movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }]) # Character.create(name: "Luke", movie: movies.first) + +# admin_user = User.create(email: "here@there.com", password: "longandverystrongplease", role: 1000) + + + +subprincipleitemgroups +subprincipalitemgroups diff --git a/test/fixtures/cafs.yml b/test/fixtures/cafs.yml index 681c294..1b865e5 100644 --- a/test/fixtures/cafs.yml +++ b/test/fixtures/cafs.yml @@ -1,11 +1,11 @@ # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -one: - company: one - name: MyString - description: MyText - -two: - company: two - name: MyString - description: MyText +# +# one: +# company: one +# name: MyString1 +# description: MyText1 +# +# two: +# company: two +# name: MyString2 +# description: MyText2 diff --git a/test/fixtures/companies.yml b/test/fixtures/companies.yml index def1a54..a7ee960 100644 --- a/test/fixtures/companies.yml +++ b/test/fixtures/companies.yml @@ -1,7 +1,7 @@ # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html -one: - name: HiddenAgendaLtd - -two: - name: CaudleMotorsports +# one: +# name: HiddenAgendaLtd +# +# two: +# name: CaudleMotorsports diff --git a/test/fixtures/principles.yml b/test/fixtures/principles.yml index f1d3711..dbc8ab3 100644 --- a/test/fixtures/principles.yml +++ b/test/fixtures/principles.yml @@ -1,11 +1,11 @@ # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -one: - caf: one - name: MyString - description: MyText - -two: - caf: two - name: MyString - description: MyText +# +# one: +# caf: one +# name: MyString +# description: MyText +# +# two: +# caf: two +# name: MyString +# description: MyText diff --git a/test/fixtures/subprincipalitems.yml b/test/fixtures/subprincipalitems.yml deleted file mode 100644 index 590ade7..0000000 --- a/test/fixtures/subprincipalitems.yml +++ /dev/null @@ -1,11 +0,0 @@ -# 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/subprincipalitemgroups.yml b/test/fixtures/subprincipleitemgroups.yml similarity index 53% rename from test/fixtures/subprincipalitemgroups.yml rename to test/fixtures/subprincipleitemgroups.yml index 53e3721..3863b26 100644 --- a/test/fixtures/subprincipalitemgroups.yml +++ b/test/fixtures/subprincipleitemgroups.yml @@ -1,9 +1,9 @@ # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html -one: - subprinciple: one - type: - -two: - subprinciple: two - type: +# one: +# subprinciple: one +# type: +# +# two: +# subprinciple: two +# type: diff --git a/test/fixtures/subprincipleitems.yml b/test/fixtures/subprincipleitems.yml new file mode 100644 index 0000000..43e24df --- /dev/null +++ b/test/fixtures/subprincipleitems.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 index 43cbcf7..71c35f3 100644 --- a/test/fixtures/subprinciples.yml +++ b/test/fixtures/subprinciples.yml @@ -1,11 +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 +# +# one: +# principle: one +# name: MyString +# description: MyText +# +# two: +# principle: two +# name: MyString +# description: MyText diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index d7a3329..b9346e6 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -4,8 +4,8 @@ # model remove the "{}" from the fixture names and add the columns immediately # below each fixture, per the syntax in the comments below # -one: {} -# column: value -# -two: {} -# column: value +# one: {} +# # column: value +# # +# two: {} +# # column: value diff --git a/test/models/company_test.rb b/test/models/company_test.rb index 9bbdc6e..aa825b3 100644 --- a/test/models/company_test.rb +++ b/test/models/company_test.rb @@ -1,7 +1,7 @@ require "test_helper" class CompanyTest < ActiveSupport::TestCase - test "compnay name can not be blank" do + test "company name can not be blank" do c = Company.new assert !c.save end