From 0b5276a3160fb5c262bbf46ad4cf62226a63a279 Mon Sep 17 00:00:00 2001 From: Ben Anderson Date: Sat, 6 Jan 2024 10:45:47 +1300 Subject: [PATCH 1/3] Send deprecation notices to the rails log (#241) Prior to this change, messages were being sent to the ActiveSupport::Notifications system in production (as per the Rails default) which doesn't appear to have any active listeners, meaning these notices were just being sent into the void. Send the messages to the log instead, so that we can see them. --- config/environments/production.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index a0951a24..e8b7beea 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -49,7 +49,7 @@ config.i18n.fallbacks = true # Send deprecation notices to registered listeners - config.active_support.deprecation = :notify + config.active_support.deprecation = :log # Compress JavaScript and CSS config.assets.compress = true From b084e51ec878bb3ff0fbacbade4fbc456f97ba14 Mon Sep 17 00:00:00 2001 From: Ben Anderson Date: Sat, 6 Jan 2024 10:46:26 +1300 Subject: [PATCH 2/3] Commit updated db/schema.rb (#225) Rails 4.2 introduced `force: :cascade` and uses that by default when dumping the schema[1] to make it possible to reload a schema when foreign keys are in place, so we now get a slightly different dump format. There are also other trivial differences. Commit this new version to reduce diff's when the schema is dumped. Note that there are additional differences when dumping databases created pre-4.2 (to do with `limit: 255`, see #225 for discussion), but they will be addressed separately. [1] https://guides.rubyonrails.org/v4.2/4_2_release_notes.html#active-record-notable-changes --- db/schema.rb | 82 ++++++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 29dea819..a096daf6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -16,7 +16,7 @@ # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" - create_table "contest_relations", force: true do |t| + create_table "contest_relations", force: :cascade do |t| t.integer "user_id" t.integer "contest_id" t.datetime "started_at" @@ -40,7 +40,7 @@ add_index "contest_relations", ["contest_id", "user_id"], name: "index_contest_relations_on_contest_id_and_user_id", unique: true, using: :btree add_index "contest_relations", ["user_id", "started_at"], name: "index_contest_relations_on_user_id_and_started_at", using: :btree - create_table "contest_scores", force: true do |t| + create_table "contest_scores", force: :cascade do |t| t.integer "contest_relation_id", null: false t.integer "problem_id", null: false t.integer "score" @@ -52,7 +52,7 @@ add_index "contest_scores", ["contest_relation_id", "problem_id"], name: "index_contest_scores_on_contest_relation_id_and_problem_id", using: :btree - create_table "contest_supervisors", force: true do |t| + create_table "contest_supervisors", force: :cascade do |t| t.integer "contest_id" t.integer "user_id" t.string "site_type" @@ -62,7 +62,7 @@ t.datetime "scheduled_start_time" end - create_table "contests", force: true do |t| + create_table "contests", force: :cascade do |t| t.string "name" t.datetime "start_time" t.datetime "end_time" @@ -80,13 +80,13 @@ t.boolean "only_rank_official_contestants", default: false end - create_table "entities", force: true do |t| + create_table "entities", force: :cascade do |t| t.string "name" t.integer "entity_id" t.string "entity_type" end - create_table "evaluators", force: true do |t| + create_table "evaluators", force: :cascade do |t| t.string "name", null: false t.text "description", default: "", null: false t.text "source", default: "", null: false @@ -95,7 +95,7 @@ t.datetime "updated_at" end - create_table "file_attachments", force: true do |t| + create_table "file_attachments", force: :cascade do |t| t.string "name" t.string "file_attachment" t.integer "owner_id" @@ -103,7 +103,7 @@ t.datetime "updated_at", null: false end - create_table "filelinks", force: true do |t| + create_table "filelinks", force: :cascade do |t| t.integer "root_id" t.integer "file_attachment_id" t.datetime "created_at" @@ -115,7 +115,7 @@ add_index "filelinks", ["file_attachment_id"], name: "index_filelinks_on_file_attachment_id", using: :btree add_index "filelinks", ["root_id", "filepath"], name: "index_filelinks_on_root_id_and_filepath", using: :btree - create_table "group_contests", force: true do |t| + create_table "group_contests", force: :cascade do |t| t.integer "group_id" t.integer "contest_id" end @@ -123,13 +123,13 @@ add_index "group_contests", ["contest_id", "group_id"], name: "index_group_contests_on_contest_id_and_group_id", using: :btree add_index "group_contests", ["group_id", "contest_id"], name: "index_group_contests_on_group_id_and_contest_id", using: :btree - create_table "group_memberships", force: true do |t| + create_table "group_memberships", force: :cascade do |t| t.integer "group_id" t.integer "member_id" t.datetime "created_at" end - create_table "group_problem_sets", force: true do |t| + create_table "group_problem_sets", force: :cascade do |t| t.integer "group_id" t.integer "problem_set_id" t.string "name" @@ -138,7 +138,7 @@ add_index "group_problem_sets", ["group_id", "problem_set_id"], name: "index_group_problem_sets_on_group_id_and_problem_set_id", using: :btree add_index "group_problem_sets", ["problem_set_id", "group_id"], name: "index_group_problem_sets_on_problem_set_id_and_group_id", using: :btree - create_table "groups", force: true do |t| + create_table "groups", force: :cascade do |t| t.string "name" t.datetime "created_at" t.datetime "updated_at" @@ -147,7 +147,7 @@ t.integer "membership", default: 0, null: false end - create_table "item_histories", force: true do |t| + create_table "item_histories", force: :cascade do |t| t.integer "item_id" t.boolean "active" t.integer "action" @@ -158,7 +158,7 @@ t.datetime "updated_at" end - create_table "items", force: true do |t| + create_table "items", force: :cascade do |t| t.integer "product_id" t.integer "owner_id" t.integer "organisation_id" @@ -170,7 +170,7 @@ t.integer "scan_token" end - create_table "language_groups", force: true do |t| + create_table "language_groups", force: :cascade do |t| t.string "identifier" t.string "name" t.integer "current_language_id" @@ -180,7 +180,7 @@ add_index "language_groups", ["identifier"], name: "index_language_groups_on_identifier", unique: true, using: :btree - create_table "languages", force: true do |t| + create_table "languages", force: :cascade do |t| t.string "identifier" t.string "compiler" t.boolean "interpreted" @@ -201,17 +201,17 @@ add_index "languages", ["identifier"], name: "index_languages_on_identifier", unique: true, using: :btree - create_table "organisations", force: true do |t| + create_table "organisations", force: :cascade do |t| end - create_table "problem_series", force: true do |t| + create_table "problem_series", force: :cascade do |t| t.string "name" t.string "identifier" t.string "importer_type" t.text "index_yaml" end - create_table "problem_set_problems", force: true do |t| + create_table "problem_set_problems", force: :cascade do |t| t.integer "problem_set_id" t.integer "problem_id" t.integer "problem_set_order" @@ -221,7 +221,7 @@ add_index "problem_set_problems", ["problem_id", "problem_set_id"], name: "index_problem_set_problems_on_problem_id_and_problem_set_id", using: :btree add_index "problem_set_problems", ["problem_set_id", "problem_id"], name: "index_problem_set_problems_on_problem_set_id_and_problem_id", using: :btree - create_table "problem_sets", force: true do |t| + create_table "problem_sets", force: :cascade do |t| t.string "name" t.integer "owner_id" t.datetime "created_at" @@ -229,7 +229,7 @@ t.integer "finalized_contests_count", default: 0 end - create_table "problems", force: true do |t| + create_table "problems", force: :cascade do |t| t.string "name" t.text "statement" t.string "input" @@ -246,44 +246,44 @@ t.integer "test_status", default: 0 end - create_table "products", force: true do |t| + create_table "products", force: :cascade do |t| t.string "name" t.integer "gtin", limit: 8 t.text "description" t.string "image" end - create_table "requests", force: true do |t| + create_table "requests", force: :cascade do |t| t.integer "requester_id" t.integer "subject_id" t.string "subject_type" - t.string "verb", null: false - t.integer "target_id", null: false - t.string "target_type", null: false - t.integer "status", default: 0, null: false + t.string "verb", null: false + t.integer "target_id", null: false + t.string "target_type", null: false + t.integer "status", default: 0, null: false t.integer "requestee_id" - t.datetime "expired_at", default: Infinity, null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "expired_at", default: 'Infinity', null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "roles", force: true do |t| + create_table "roles", force: :cascade do |t| t.string "name" end - create_table "roles_users", id: false, force: true do |t| + create_table "roles_users", id: false, force: :cascade do |t| t.integer "role_id" t.integer "user_id" end - create_table "schools", force: true do |t| + create_table "schools", force: :cascade do |t| t.string "name" t.string "country_code", limit: 2 t.integer "users_count" t.integer "synonym_id" end - create_table "sessions", force: true do |t| + create_table "sessions", force: :cascade do |t| t.string "session_id", null: false t.text "data" t.datetime "created_at" @@ -294,14 +294,14 @@ add_index "sessions", ["session_id"], name: "index_sessions_on_session_id", using: :btree add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at", using: :btree - create_table "settings", force: true do |t| + create_table "settings", force: :cascade do |t| t.string "key" t.string "value" end add_index "settings", ["key"], name: "index_settings_on_key", unique: true, using: :btree - create_table "submissions", force: true do |t| + create_table "submissions", force: :cascade do |t| t.text "source" t.integer "score" t.integer "user_id" @@ -325,7 +325,7 @@ add_index "submissions", ["problem_id", "created_at"], name: "index_submissions_on_problem_id_and_created_at", using: :btree add_index "submissions", ["user_id", "problem_id"], name: "index_submissions_on_user_id_and_problem_id", using: :btree - create_table "test_case_relations", force: true do |t| + create_table "test_case_relations", force: :cascade do |t| t.integer "test_case_id" t.integer "test_set_id" t.datetime "created_at", null: false @@ -335,7 +335,7 @@ add_index "test_case_relations", ["test_case_id"], name: "index_test_case_relations_on_test_case_id", using: :btree add_index "test_case_relations", ["test_set_id"], name: "index_test_case_relations_on_test_set_id", using: :btree - create_table "test_cases", force: true do |t| + create_table "test_cases", force: :cascade do |t| t.text "input" t.text "output" t.string "name" @@ -348,7 +348,7 @@ add_index "test_cases", ["problem_id", "name"], name: "index_test_cases_on_problem_id_and_name", unique: true, using: :btree - create_table "test_sets", force: true do |t| + create_table "test_sets", force: :cascade do |t| t.integer "problem_id" t.integer "points" t.string "name" @@ -360,7 +360,7 @@ add_index "test_sets", ["problem_id", "name"], name: "index_test_sets_on_problem_id_and_name", unique: true, using: :btree - create_table "user_problem_relations", force: true do |t| + create_table "user_problem_relations", force: :cascade do |t| t.integer "problem_id" t.integer "user_id" t.integer "submissions_count" @@ -376,7 +376,7 @@ add_index "user_problem_relations", ["problem_id", "ranked_score"], name: "index_user_problem_relations_on_problem_id_and_ranked_score", using: :btree add_index "user_problem_relations", ["user_id", "problem_id"], name: "index_user_problem_relations_on_user_id_and_problem_id", unique: true, using: :btree - create_table "users", force: true do |t| + create_table "users", force: :cascade do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false t.string "reset_password_token" From 57b299d1f4fff094055d335e5a8abee1f6c535d0 Mon Sep 17 00:00:00 2001 From: Tom Levy Date: Sat, 6 Jan 2024 12:45:29 +1300 Subject: [PATCH 3/3] Add CI check that db/schema.rb matches result of migrations (#247) --- .github/workflows/ci.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 909e1650..66d6b355 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,6 +48,9 @@ jobs: ISOLATE_CGROUPS: false ISOLATE_BRANCH: master + - name: Back up db/schema.rb # it will be overwritten when install.bash runs migrate.bash; back up the original so we can check if it's up to date + run: cp db/schema.rb db/schema.rb.git + - run: AUTOCONFIRM=true script/install.bash env: PGHOST: localhost @@ -57,6 +60,11 @@ jobs: #- run: bundle exec rake db:test:load # not required because script/install.bash runs db:migrate - run: bundle exec rspec + - name: Check that db/schema.rb is up to date + run: | + diff -u db/schema.rb.git db/schema.rb >&2 || + { echo "Error: db/schema.rb is out of date" >&2; exit 1; } + - uses: coverallsapp/github-action@v2 lint: