From c7e2c4a72f6179814d5f5c0975b6e87506b9e0d5 Mon Sep 17 00:00:00 2001 From: Tricia Jenkins Date: Thu, 30 Apr 2020 18:07:47 -0600 Subject: [PATCH 1/5] add migration to fix concatenated subjects (part 1) This will take a subject like ["Cat, Dog, Rabbit"] and make it ["Cat", "Dog", "Rabbit"] in a new deconcatenated_subject column. We're doing this in two parts to make data cleanup a little more sane than edits in production. This assumes that at some point in the future this new column will be reviewed and replace the Item's subject. --- CHANGELOG.md | 1 + ...econcatenate_subject_in_item_and_thesis.rb | 21 + db/migrate/ERA_subject_issue.txt | 628 ++++++++++++++++++ db/schema.rb | 4 +- 4 files changed, 653 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20200430205827_deconcatenate_subject_in_item_and_thesis.rb create mode 100644 db/migrate/ERA_subject_issue.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d977a545..0d64be0f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and releases in Jupiter project adheres to [Semantic Versioning](http://semver.o - Thesis ingest rewrite [PR#1670](https://github.com/ualbertalib/jupiter/pull/1670) - Rails 6 sidekiq queues - Add stylelint to Jupiter [#1120](https://github.com/ualbertalib/jupiter/issues/1430 +- migration to fix concatenated subjects (part 1) [#1449](https://github.com/ualbertalib/jupiter/issues/1449) ### Changed - bump rubocop-rails to 2.4.1 Rails/FilePath default changed to slashes [PR#1398](https://github.com/ualbertalib/jupiter/pull/1398) diff --git a/db/migrate/20200430205827_deconcatenate_subject_in_item_and_thesis.rb b/db/migrate/20200430205827_deconcatenate_subject_in_item_and_thesis.rb new file mode 100644 index 000000000..9ea2e6f5b --- /dev/null +++ b/db/migrate/20200430205827_deconcatenate_subject_in_item_and_thesis.rb @@ -0,0 +1,21 @@ +class DeconcatenateSubjectInItemAndThesis < ActiveRecord::Migration[6.0] + + def change + add_column :items, :deconcatenated_subject, :json + add_column :theses, :deconcatenated_subject, :json + + concatenated_subject_ids = File.readlines('db/migrate/ERA_subject_issue.txt').collect(&:strip) + report = Logger.new('log/concatenatedsubjects.log') + (Item.all + Thesis.all).each do |item| + item.deconcatenated_subject = if concatenated_subject_ids.include? item.id + deconcatenated_subject = item.subject.map { |subject| subject.split(%r{,\s*}) }.flatten + report.info("#{item.id}, \"#{item.title}\", #{item.subject}, #{deconcatenated_subject}") + deconcatenated_subject + else + item.subject + end + item.save! + end + end + +end diff --git a/db/migrate/ERA_subject_issue.txt b/db/migrate/ERA_subject_issue.txt new file mode 100644 index 000000000..ba611eb24 --- /dev/null +++ b/db/migrate/ERA_subject_issue.txt @@ -0,0 +1,628 @@ +c7b69f61-2404-4eb9-9b4f-ca0e971bde3 +a6de3cc1-9b66-4d29-b287-9ade9a6e8714 +e2306501-bf3b-4ccb-9d07-fdd8520695dd +e2306501-bf3b-4ccb-9d07-fdd8520695dd +39d68f48-556c-437d-92fb-164063b7a1e3 +06d3cfb9-f30a-49c5-b3e5-d2d84c6502fc +4cdc962c-8680-4343-a397-525c21bebcde +3e4c904f-6381-4748-a3e1-6bd9b61f57c3 +fd8a6b18-b1cf-4e75-8151-3e058d16132d +e09f6ca5-3a87-41b3-9eba-5f9b60acb845 +7b416312-7d12-4fec-b080-46efd5816c67 +544eed05-55ed-44c4-993e-4104ebbf4717 +1509c801-9ee2-4572-9db4-009480156439 +5c755f81-3721-45a5-98a2-0c749aad741d +4f1e114f-cfad-4ac9-8e81-dc6327238f4d +5d591ebe-39df-4af2-979f-23270aff45fd +1c41e1da-99bc-458f-bcd3-a250e6a2e5c9 +b3855e50-434d-4c46-a0f1-a6c277bda047 +1ca18ec6-3d4d-43ad-8791-52b0b1f5f77a +622b97e9-d984-4371-9255-8400c74ba76a +680b0d84-33cf-4235-9461-23490e82e780 +6f239e24-adfe-4cd0-8279-1178f04cdbb8 +db8c424e-817b-403f-a884-9e279b8cce79 +569cabf8-7c0b-479f-9bfc-a430c5cdca33 +357ac655-1d3c-41c0-856d-293c6faa50b9 +070c8f21-8411-45e2-acec-eb1e9a05ba9d +c55d4fc5-0ae5-48bc-9dba-70237b5afd93 +07e48311-379e-4dd3-a1be-54ddee728c08 +85a965b7-d124-4b1a-a700-ba5b3ff21b13 +7b25779c-baec-42da-943f-13e264449978 +7bb20a40-e257-490f-8947-bd1b28cf11fd +1df14139-7f3e-4f90-be32-49d84fcd00da +30690cb1-2555-4c63-baf4-ab32d9098a6d +bbcc059d-7b86-4be3-bb99-1b1cbeb4c44f +0d588fc1-74fc-4744-b94f-2b071ee1c6dc +3002fd33-9c3b-4232-bbf3-363221ec4fc7 +32069b4e-18c9-4be2-8473-416d51d57e71 +2ab9e0f8-46aa-44d4-ab10-26003e13f713 +672dddb0-2d26-4fd9-aa96-4b4d716f66be +a11848cd-21c3-405a-875b-0737db00da63 +385f8fed-0973-4429-9220-94f7f15ef70c +381225b6-9893-4178-bb9e-5587e291d4fd +38ac07da-4bca-4830-b5a3-3c7189f5bf9e +814145a2-1cb2-4c52-98e2-71874bb7e4e9 +38b45415-8c8e-4134-b78e-0819e7890c3b +384d5384-c3a6-4a94-89f4-a3a9b591a459 +732b0d5a-44aa-4907-bf49-a854b4455352 +7334d32f-b588-4616-b551-a95ab8adf96b +739169de-addf-4cd9-9040-2e88a75e1c0a +73cda2f9-82fc-41f1-af30-67e565348083 +73af6cd9-f58d-4649-866c-1974dc40e656 +3b42c83f-b5e8-435a-9350-7b9b782a4c2e +73baf8db-5e86-4816-93d8-f8685372a8ec +087cace6-a269-40c0-b736-3cf0c4d29614 +08327822-fdc5-4dc1-8e0c-af96c4ba3caf +08f2b72e-685f-4e1c-8b6f-ed7155c3bd88 +caaf058c-2a9d-45ac-aa91-3e47891e18d6 +08efefe2-806b-4ded-9681-fb2901f954c4 +1b9e7aff-349d-4b6d-9f7e-a5550720930c +63a8df9f-2db6-4f5c-b19c-5a3da0a1a9fa +b20a0dfc-c697-4c0e-a69c-38ce0c334f3e +8c713294-0541-4895-9d7a-7bcfa2fde402 +9f549018-abd5-4a85-8120-41c46579c5b7 +5bde8ae3-2c39-4aee-93b8-7703dd0700e7 +ece17cb6-8f6f-497a-bf86-024bb3225736 +d1415b0c-fb44-435c-8550-f83b922ddc71 +d14c25aa-c2b4-4299-9e5f-3e9731d20a50 +8003ca46-3837-4737-83e5-dc85a9e27a72 +5e62f233-e4e0-497d-952b-a357d3a58275 +44092a93-2d77-4867-a69e-6a098a56818f +84992b09-13a5-4d0b-9641-ba94bb359b7b +a7111ab9-2b1c-4f4f-a407-f1a9421da77f +e49509e2-9949-4c33-9a85-271fad7b8533 +a759f7eb-e709-4988-afc6-84dfc46d921b +0c827f8e-0356-41dd-bcd8-729d5b23479e +a758a144-c965-42a1-990b-a79295fa82dc +a7288f44-22ff-4dcf-abee-91eb90299e6b +641b9a81-6e12-42ba-a4fb-e969419bb44f +c66decaa-6622-416c-97b2-2b723abc616e +c6419d00-b8dc-44db-b507-9730fc8aee6a +c6b109bc-335d-450c-a3cc-0585d285bf44 +c6b14d26-3e40-44c5-8c3d-743bac9ecae1 +c68cc6ae-a664-4336-998a-f6f50ed67147 +2ef024d3-f520-4fd3-ad0b-f2baa3ef4d09 +318a93aa-e9a2-4e8d-9377-93df415fb549 +f12c8e4b-9bae-466c-a9be-68439472f55f +31df1cac-d364-4479-a420-c43fccce79c3 +316ebe19-5bbe-496a-bb2e-d4b83574efbb +e6d2a941-008c-4540-8394-fc4af066aee0 +25559e54-165d-4075-8a62-b63c2fc980b4 +be0c0f14-ae89-42de-b66c-45a6f125250b +2529e08e-f86e-42e3-b617-75eaedda8fd2 +25721b14-1228-490b-bf3d-6cccb56bb735 +25d7b742-3498-4dcb-a260-8db2295bf086 +4661f346-e350-4d1c-9fc9-e382fb0be047 +9a67acaa-8563-4998-97cc-7776de1f164d +1fcd27a7-ef7a-4f13-9f1d-e602b39ec46b +95c73a10-49cc-487b-9fbb-a75d9ff15133 +ad861ca5-d535-4161-9871-61fd1619a317 +8912dc58-c60f-4833-84d2-a1d89545bb45 +447d63c8-49c2-4319-bab2-c57ca0171f99 +c1e83cfd-2daf-4b3f-ba3d-1f9e29035c62 +89a2a399-e041-425d-950d-7ff05167660f +0bee5b13-4208-41f7-8b46-c3f0b0d9f584 +0007b2c2-95c3-477f-9602-801dc6dd0dc7 +1e2207ca-57e8-40bc-ab5a-61b0d5625dbd +1ea39156-0c7b-43b6-beae-0991a225bee8 +70cbb166-f23b-43cd-a2a6-86beba78abfa +66c0be2e-892b-4656-bc32-04d929f12806 +66c6ad58-d43b-4b24-9b3a-8007bfad0ce1 +83083024-68b3-471d-978a-99cd6defbc6c +e50d1872-2411-48e4-b95c-bb6ade3b541d +2827153c-91aa-4615-8641-4dd12ecab234 +66bff155-f1d2-441b-a9de-cb8f1b1dd2b2 +90d5b06c-e508-45b3-8526-3509bceb930e +cc28e61c-4c33-4ea2-b372-97c4adb7df3b +9a4b6d09-eba4-4d1c-ab73-4b8d76de8c22 +cc025e18-3f9a-4a3e-bb41-1f6a30f4e8c4 +6e67c496-e294-4711-823d-b9a3f723f805 +479734c9-f95b-43c2-91fd-a17e4a318ca1 +e024fafb-2842-45a4-b6d3-d1254cc268b5 +58064fb5-1112-4c4a-973e-b6525a64e8ca +0d9000f4-3c7e-4221-9f26-f5faf0a1d1bb +82029824-3371-4c6b-87e6-9ef8721be4c4 +ce0c14b5-c5f7-48cf-a8b3-14cd903254d7 +bfd448da-363b-465c-8c1e-6c664dfcd3a4 +0dcf457c-7946-44a4-900d-75e5b99bdf12 +950a9128-f010-4967-a6f1-1c5340ef94de +aded0c42-97e0-4532-a0af-216d76597a82 +841cccfa-a390-4c85-af67-16516599745c +729e1b74-c88c-46ac-afcd-657a3d7a3334 +72a543d0-6e0b-4956-b507-7c07eae97b36 +8469e83c-4696-4bc4-b51b-f104ac5ab747 +e7fa80eb-15d0-46aa-8ea9-3ee5a4620b7e +223682fd-60ec-41e6-b5cb-a308648a218f +2282d2eb-cb2f-4476-8f1d-35d387d2461b +e3a5c8ca-8a64-4ee3-bd0f-cd8e10adfd89 +5cc74c66-f747-4c66-960b-c124d3299501 +2228516c-0856-4d17-b9b2-e264cfcf6fe1 +71305aaa-8ef2-426b-8fc3-40480932308c +7acc3499-05b9-4139-85ea-b94def8e3fbd +062c4767-80b0-4d8b-8b3e-4a0d28b97529 +e04a1590-2239-4370-b1f9-8217e8149285 +e0ac359c-0a70-4f67-8c5c-e8849d883947 +7681508c-0b0f-4217-a16e-685eab116567 +69c96b9a-3309-4838-b23e-48b38d6ee2cb +3fce2766-0d73-4a92-8556-6e0476796944 +902e22e6-d19e-46b7-9b1b-3dc754894c7c +db1a2de2-ce0d-427c-9f3f-5a321c0ccf42 +fe337ecd-3d59-4cb6-be55-fd1cf5cf3c92 +908925e4-04cd-41dd-bff9-eeab5d959802 +a3267506-bc62-430a-ac1c-72500713841c +a37d1744-ac4c-4db9-a641-2666be10f154 +a37dd506-4295-4cc7-8d8e-fb28560e0a5e +a3e2b299-2f67-4e3d-826c-e6d44bf0eff3 +a35893ff-09ac-4e61-9bd6-f4762211573a +f694c8e1-63b5-418f-a67d-733c8324d374 +2462ebf1-bc8d-4a27-b16e-323631a5dfea +a0269448-05f2-4a80-942d-96103dbdcbe8 +1d613236-53f9-4930-8757-3ab94fe5bb29 +1d43020a-9eda-4da7-bb99-862a8dd331ea +6abd54c8-dc12-417c-b37d-bc1b6d8c8248 +1df25826-d366-4c23-8513-70d3869702a6 +0007c436-44d6-4966-96a9-330016a46af9 +1dd1157f-c262-4eef-ab6d-a7e7a06db808 +1d330167-e5db-4d78-9888-e4405a3d9d26 +7a4cab33-8fea-44e0-ad19-4891aa75166e +48471753-39f2-469f-b49d-43d29c7d9ebd +c2e5d01e-fc1c-4ebd-9583-a5fbd0bea74e +48d5a915-fbf9-4a66-8faa-28a4a168ccce +489c0395-45a1-4290-a1ad-210a543d6d25 +488d7590-75f3-44f0-8e18-be41f0174d33 +4810c715-e50e-4f61-bdc8-b4ec7608538f +7418ecc6-e4e7-4916-a90e-ced7cec58671 +744e075c-d20b-4c88-ab31-d611d5ffabfb +83a99966-b443-49d3-a2b8-47892b9e20aa +2f9589d0-6bc8-406a-8df3-cc5f1b344896 +2f8ce94f-4964-4184-86b3-f2236057e215 +3d413094-f82d-483c-8886-57022da94d67 +f155f205-1ac9-4c33-9154-c9de8b8642cc +54bcb1f5-e558-4e22-884f-3e5169cd8eff +1697a6d6-937d-46b9-9dee-3bba0ef18331 +54999f4d-b89f-4c21-94bf-db6afd1a0f35 +20e06daf-c8c2-42cb-94b5-33165d1b64e2 +fcc8b2e7-3462-4693-ae72-59c651d90bf9 +6eef459d-21b3-4c59-9438-f9697264817b +0b87c639-9d32-4415-b7fc-ea7db7b77ecd +cf522384-0f10-4a65-a512-50a7f23a0267 +d24a4ba2-48fe-4c67-9d26-b8bc7fadcee6 +fbf1bddd-b478-44c6-b708-c09b2c1582f5 +851bf4fc-445f-46f2-8e91-df6f1be95317 +0e967017-d8df-4fd8-800a-f433b76c87d5 +e9799fee-c525-4483-a719-696d7ac78cf8 +d9e1d77c-9088-4695-8d77-0893cde44190 +3474e341-6034-4b60-85c4-776ec7aa6454 +6a0e3441-cfe6-48e1-bceb-19f7ca8025af +0fa04354-84bd-4372-9e43-a990a21e7e55 +6a3e10a4-319d-4df9-b208-5217aa5c9c4a +6afbff5c-06b8-4265-b101-07ed497cc31a +c00362fb-956a-4654-a282-66afa9b39830 +b4558cf4-559f-42d9-8adf-15a8782d6ae0 +a1e460ad-5009-456a-ab7f-5ae1f007e66d +b49882a3-e386-47c8-8549-18cd01c1a982 +e15b8b8e-3ae2-4645-9e80-c10f9be90b61 +5d11b162-3d97-4a71-ad2e-d06d76b6a70f +e181961a-0e3f-4c0e-820f-ebe6d8817828 +4e0d90ee-6dbe-424f-be7e-747727c48466 +ff6ebe0a-677b-4b41-882e-0cf53b1639cf +ff34c97a-3e6d-4610-ba84-5af46ad498ea +017371a2-a39e-4431-8363-c48886db144f +2666e9a4-ec9d-4e0d-a37f-7165a69b8434 +72078c56-f989-45e3-9198-9760ad6fb738 +26d9df97-06de-41c7-9a11-33359efa725e +4edd79b0-eb0d-429c-9bdb-0398358c99d9 +96d1a6a4-13ee-48e5-bbcf-4e30dfcf0cd9 +62f2cb82-a2ab-467d-b448-95a245abb302 +7a9fd82e-6360-40b4-9644-e96f08695090 +b9b449bf-035e-448f-83ba-42a99ae20928 +9dfdff92-1282-4944-9456-c50de5785e6a +b9ca959c-fbca-4f6d-b03f-bb3a81723794 +6176eb4c-fbf1-4daf-a055-e2b6b04f229b +b92cfd36-fc0b-44bf-abab-c675470ee6fe +cf046d5e-d56f-4276-932c-efdd95758c1e +4f316a8b-7e90-4c38-b796-78b442beff51 +4f38ab93-226b-4cc9-b7ba-6be62f0981c0 +4f2e3e77-1791-4893-843b-a75012c61674 +4f70cf86-47d4-42bf-bc8c-919ee440810a +52f76c51-8cba-4b86-87d2-f93faa1798aa +3a4612b8-c577-4f05-900b-6caf0036c3ba +2c09019d-9e85-47e4-8342-359b07a74d91 +2ccb56b6-74d9-4232-9673-5e9865f42522 +33d064c0-647d-4262-9876-f37ff252edfa +3ac59350-5e66-4261-a8ed-c44a90bc19eb +f48b1ce3-5f3b-48e1-bc13-fbb882e15f69 +f48b1ce3-5f3b-48e1-bc13-fbb882e15f69 +f4a715dc-329c-4c9a-9490-591d4735be7e +da611ad8-1051-451d-bd99-16910e899e12 +e3ca4334-a0c4-430a-a2f4-1fb9deb80866 +f4cdaed6-3dcd-4535-a8b8-45f9df8d1ed9 +f4012ed0-762f-4988-aa80-b5c60b22e933 +c8c57003-5148-4825-b83a-4f15cc4ddc48 +81ac1a49-833d-4edc-bec1-734e434cf7a9 +81b47dc8-b615-45e8-97c2-fc4b2e43d866 +fdcddbb6-3f1f-4911-9e7a-5da824523990 +81d059b6-c448-428e-b501-1fcdeef68ad7 +8137a5f9-8563-4e99-9317-ebd9d2f88e46 +20766212-dc98-42a8-a0ea-05736a56aae2 +193f61d2-dac5-4adf-877e-d236abc1dbf9 +0bcc754d-4053-4baf-aa16-dd2f0b124668 +19db5d1a-0a08-427a-a8be-3f626cd1a1f3 +e5e4d8ee-2eae-4d78-b398-4c288e008bb0 +ee879c4b-8548-4570-912e-7477947c60f9 +cef02516-1d3f-438d-b5e4-613706dc0de4 +039192a3-51e2-4342-806a-f352e18eac61 +2efb3c37-3cbf-4ee6-8306-7a4cca9c4882 +55b4ebbf-4ae3-469a-a5b7-4a54f896a964 +550d2b1d-0ec8-4604-8bb4-bb2f5106ecb9 +469e378c-27fc-42ef-831f-bc1f5b4e33a1 +db9998d5-0ae2-41b4-b657-8b82f2e339af +db9d533e-dff6-4edc-b938-dd9b8a7b6f9f +7dfebca7-f652-4d61-aa02-57d4fee54d40 +db314ce0-56b4-4894-b193-5ae5cce8a5c6 +dbf8ed78-5c34-472c-b65a-e71cacbbb819 +dbf8ed78-5c34-472c-b65a-e71cacbbb819 +dbf8ed78-5c34-472c-b65a-e71cacbbb819 +34c72e40-ac42-43d5-8f82-0ad3161a02fe +21588a9e-ca25-4bb4-a5ad-f12c6ada89bf +8c2101f6-bb2f-4b6f-8414-7b8b0252dff3 +8f599357-4ffc-494e-9c8b-f27e90ea2f14 +01c45fd9-6ed8-4ea9-8584-af03fdd8f55c +f9f4986f-98ff-483c-824d-a169b23c1e09 +991db118-a926-4a1e-9246-2a793ee3c43d +0c6e7d22-037d-4c1f-8b00-37e07a70f85a +5dfb8ce6-9214-4a4d-a6e9-df128659397c +5dfb8ce6-9214-4a4d-a6e9-df128659397c +5dfb8ce6-9214-4a4d-a6e9-df128659397c +c96eaf69-3276-41b1-804d-52cad49b0569 +daa06320-acfe-49ed-8645-36dc7f49e8d8 +f3ab7fbf-9817-483f-8d7e-1e32146fc571 +f8bce972-f747-40a2-a610-0ec8c83801f0 +70a8acf7-ff3e-4b79-b3b4-f6decae6121a +36a73314-684b-4c91-b85d-27cb20081937 +369ab3d6-f4a2-4476-873b-52758b54bacb +365ac02d-252c-4459-b5f4-513c0e354b0a +ac8db8d4-c13b-41b3-bc5d-4c932e0d1e61 +935d43ad-1a72-484f-9cf3-154d9326adcc +7f611636-999c-4aec-b26a-1cd6e48eed63 +ec1e13ea-545d-4e17-b7b8-25a6dae6ca49 +f5918f81-9013-487c-961c-1df701d9f2a2 +5a043d04-b944-4ca9-a505-d65d16d812a6 +53ec0fdc-2ea0-4613-9c21-358201a766d5 +5ac3d9ba-870c-4f6d-aef0-c640339eb512 +504e3344-d31e-4c08-8ad9-dd276e79c1bb +ebdbecc7-1072-4a22-9917-6743d32ed380 +5a9fbf5a-eee3-49c4-8446-8a6f46b5bf23 +dcca8d14-131b-4fe6-a4f8-383f06ba403b +b8bb677c-3f39-467a-a480-1f985d919f81 +f3b3533b-f3b1-483d-8a20-6f65c655e255 +56aa8754-e7a9-4e9c-a80a-62cd697e23c7 +02275b03-4b0a-4eab-a9fa-708d403391c2 +8ab82b77-ce3e-4ef3-a9ec-03a3582c902d +d8e18331-365d-4e41-966a-4bb5c9b886ef +d83cf297-2071-4fc8-ae67-ad093c72777c +18030dab-1f1a-4098-be18-c7f330596b1b +1844ac04-7ccf-4fb0-82a0-60a7340a8f7f +1066d3e3-e32d-4cb9-a867-c666e5efaa9a +183adc06-687f-40e6-8c80-17933e83e8c8 +18b9ad30-ccfb-4243-8de6-7cbff8653134 +d493aa64-f125-4cbc-abd8-e1ff210ed1f8 +02dceac8-a8b5-4ebe-857f-f52d0ad0236a +be3bc1f4-438c-4cc2-8c99-996cccbca6a2 +aa592098-6986-4c5a-91e7-b80325887100 +aa14dcb7-253d-4d62-ae9a-0a1a057c0ca8 +3a7f99ad-d2f3-4f5a-b42a-fb0b0b43e160 +a9cce3e1-f0ab-49be-a01b-4c990c15923f +3d6b31c2-686c-4c62-a598-eda1cf159125 +a5575ac7-faee-4db1-89e5-20c94327d079 +8cad4798-7b94-4e9e-bc75-a408f78627de +e482ac72-7bad-4e5f-95b7-547df580b22f +1b49ace7-e95c-4d91-92fe-162b7d69924e +1b3e3afa-8065-4d13-8dea-fa7629e2aca6 +3fed1567-8be1-4dbd-9e62-801373aedb26 +ecb2db70-a74d-4d42-a49d-f876d7e9a7d8 +414009a4-72da-4487-99b7-357c9d9afa3e +ab50c96a-71b2-439c-8665-f27c44695e73 +c1114ced-feb1-4576-834c-1f7b15767e89 +c1902f90-0442-40b3-b77f-1edd9003165f +cb0e0e3b-09a6-47dd-b04d-6f29bc264fef +8f7d2250-ae9a-49ee-b2db-b1924adb1525 +c45b733d-1896-4202-8b9c-79a2507d69e7 +8f5aae19-56d5-482a-92b9-0c514835ed98 +869d2173-bce1-46e2-8732-798e34b8a27d +cf5144ad-64dc-4065-8963-abca0ea5abb1 +80bbd647-f9ab-4ec5-abd1-7752c006e9d6 +8ec21525-7dc5-4237-8857-5042e18cee90 +c0ed35c4-e55f-4bfa-bf8e-2a355544ceb3 +32398753-0ed5-4350-ba88-68bcf6d11800 +ebb74a1f-77e4-4a0c-b763-405ad505e847 +2b1242a4-0b0c-4d81-b255-5127fc75088c +f2481789-c38e-4209-be8d-847ba6c24c87 +281659bb-f5b0-47f5-90d3-b45ea8ae385c +9ad78f8e-7be3-41e8-a0fb-e1102de7ff88 +fc7eb837-8bd8-4899-bec9-53efc01fd75f +287dae7c-9bd2-469a-9c4a-b0c16bd6db4d +23f27c28-f77f-454c-8eca-753a57709d45 +284954cf-20d7-4ec2-9897-3bfda58406fd +96430153-cf57-4f47-8c82-d7fdeadeda45 +9e34445c-9c8d-497a-873d-4f08d598d510 +79c52f98-9ff9-4828-a6f4-2d0a238c22a3 +e76b170c-1e1f-4f85-8794-8d9654123a2c +0297e53f-9fb4-4243-8ffc-1f97fd7ae80d +4ac9543f-f10a-4747-b319-3f617c44d8f5 +4acd2a0c-7d5d-4f4f-acae-4982042b03e6 +4aeaa9c8-364c-46b5-b1da-294201be948c +9d4d07b9-a62c-4b04-8d0d-30c9d7933ffe +9dfcb32e-1436-40fd-bed5-96ef18b29f8e +09dda2a6-60ea-4222-b8ba-c661ceab4d2c +093575ee-35b9-40b1-81db-ba5486de89e5 +bfdb021d-5e81-4bc5-a2ef-0c5ae27ffbff +ba9042db-d5d3-436e-9392-e1bad236ada9 +7503d30a-f3f8-4bca-89d3-87a70d3b3e4c +0c79188b-eba2-492a-8c3b-4fb6dfa7cc2d +8066671b-ea33-4a99-98fa-3a6c8cd2dfe5 +e57bbdd9-0eb2-4da7-88bc-7c4e7d6c64b1 +164790e8-2bed-4435-a81b-e650348afda7 +f5069237-5309-4a30-af61-b3d9baa54e3c +d58cc6b1-ba38-44ce-b486-b9abfb1bde4f +a5a975e2-27cb-4727-a76f-73b9c5517a96 +d0e6a21f-b4ed-480f-8b1b-a4f9f52558e0 +117ac3a3-87c4-44c6-b56c-944b4b013280 +4e9298c0-c74e-4d75-9fd0-5f87cc1a29fd +dedcd799-5012-4e1f-8725-71023a16386d +06e3fd74-dde4-450b-a67b-ca86c3883eda +a9fcb101-3ae1-4ba4-84c9-01584601a650 +29942e1b-b2c9-4116-a2b2-e3b4fb7cf218 +fa579bde-1b44-4af7-b761-4c439b9131b3 +13b7e3cd-be27-40d5-92e8-dcd8065a8298 +1321beb4-f625-4043-87a3-fe206564e364 +23339418-a932-4f02-a055-ad58970161d1 +6cc31add-527e-4471-8680-a7fe3e30b762 +5f884060-e94a-41e8-97e9-93709cde6383 +ad7412ad-832c-46d3-9318-413a96bd90ae +9427fcd8-9b7d-4f9d-9554-829f1016d13c +94ebd992-fdec-4be4-bf39-12f42e6fe5e8 +33d28a3d-df74-43f1-8bf3-ac6a584ac819 +33e90f45-2434-4452-bc47-27f452e332f2 +9b31c138-cc9c-4228-a48a-bcaf7f2f2ce9 +b6f63541-a795-4ff6-b92b-b36eeb10323d +cda6f78a-5967-42b4-b41c-211dfc2511b9 +c0867789-e528-4103-b443-305001be3f98 +d63ecd91-d34b-40fe-aeda-f1a6aad45923 +d63ecd91-d34b-40fe-aeda-f1a6aad45923 +d63ecd91-d34b-40fe-aeda-f1a6aad45923 +d63ecd91-d34b-40fe-aeda-f1a6aad45923 +d63ecd91-d34b-40fe-aeda-f1a6aad45923 +bd14deb7-3c34-4c0f-b3b9-a1f4109bec10 +fc7ef555-ecef-4f1f-8529-74bbae53024e +430f94d1-a3ea-48e1-81ef-318f05e2922f +8a26521d-d1b7-4ae9-88e1-b7da07f442f6 +2083a420-ff55-4359-a746-33467e15527c +508c58df-bc07-4ea5-8870-769518845821 +ca49d2f1-c4a9-431f-b136-99fa48ab380f +85361c8b-648c-48ce-9844-929a16f3e436 +5701156f-c678-4bd1-a273-17d271802137 +53f52101-902e-400e-92e7-460a61ef26bc +8d1f9e80-df86-4125-9bd8-bf1723aca3c6 +041baa0f-ef49-4146-bb72-f6f2218c8367 +53b41892-aebb-4070-9e32-fbc283353e57 +7e596c97-b798-4888-a48a-eedf9e363297 +bc676e51-5acc-4461-b63f-bc6f72ca916d +bc66dd3c-9097-4a0b-9626-942dfa416768 +bc51c1fc-64b2-4d67-a921-0d8cb82448d5 +6b862e65-0034-45b3-bd5d-8669b16d4562 +bfc7c84d-80b7-40fe-a7ad-3b9e1f10656f +02f54606-8fba-46ae-9331-7954713e8717 +7fc5180a-52f9-404f-893c-5e6c306ebf5e +91c708fe-fe93-4fec-9620-f9465ebe158e +4bbf18bf-6ae1-48bd-9c86-e65362ab4e9a +86178db9-5e8a-42b0-9082-c2c939a44e4b +facba5c2-c192-4b50-a285-2b58ee128bdb +7c67afa9-e9b7-4c18-941a-9427b3cddda3 +d6e33c46-9eff-4ccf-ad29-62fdc6022a8e +06ba647d-5ead-4b3b-b561-073ffe0b658f +e31eff3a-eb09-4460-9be3-c649f4834f57 +cd93c4e8-74e5-4440-a4d1-30bad3f7359e +cd93c4e8-74e5-4440-a4d1-30bad3f7359e +348f3938-ee52-45f7-a2b2-bdeb4f48bbd3 +34423ffc-ea5c-4497-a34c-d43acb09d929 +f3246024-63c8-4911-9382-a0c1910eb687 +7618f77d-34af-4b61-91ab-cd03cca896d7 +c0a2c3e6-3ca9-45cb-83e0-44066fd6dd52 +60afc7a9-d5b4-4c6b-b80e-50ff99d9cb42 +a276581c-baa3-47bd-8196-90228bb78340 +8dc6801f-38ca-42c1-80d8-e7cb21fd9600 +8a97b789-b5b9-44bb-8e96-61fd629b8727 +4da95ece-2cd4-4efd-93a9-a83bc5f9069b +a04bcaad-286f-4998-a6cd-2136d9f7c2dc +bb1cc972-ece2-4421-93df-4a52d1ac1ecd +a8c09ba3-fc76-491b-bce4-3aa2c9ee1e02 +53b65d90-5d32-4ca9-8d8d-d61fc6053c82 +59cf9be2-8ccc-41b3-ad6b-ed913c233f43 +39c4b4c2-0f11-4890-a5a2-33087525b63a +64a74e82-b78c-4058-8003-5fff33239554 +0007b857-565c-4d6a-9c16-a1e4ef1fc44b +5126d130-a46a-4fbc-9620-360b3ff3ac36 +511a12a0-5734-4541-b1ec-b41ba516f232 +77c36eeb-1708-4d19-b69f-1d3bb61da93e +4995d8be-fd4c-40ec-8ac5-08c60a96f141 +625a97da-5ceb-4906-992f-c0fe9b0f7020 +7e71eb35-de19-441a-a1c5-9e8200eac3ae +7e0f52e0-66a3-4904-9a27-24f0adb69098 +fa2f2b9d-73e6-466a-8637-d7a9e90d8160 +7e3098e1-66d2-4b6c-97a0-10577fd80736 +75226600-5922-4a5d-a22d-9b4867d388fe +ddfb1c75-cb65-41a5-890e-04fb6bcd2d5d +86af7796-2b12-4ae6-8ae0-5d806a6e0ce6 +29132845-f20a-4dec-b20b-38000f40c3be +88560da8-52e5-4d29-975d-2883708bf1ff +29fcd8d1-9cae-4058-b92c-cc16cbd706ab +29ddc5e3-f2b6-4311-9887-0690aa3b95a6 +52e1f13b-d7cd-451f-a241-684075d57afc +52e2d638-cff5-4535-85fb-e4681e27a40d +df7309ff-994c-4671-b323-a6db7f80a25d +c4c391ed-a81e-4919-a6be-0302f72e5d6d +976c7653-1378-4c18-b0b0-9a38d34677e8 +c4d8e1c0-ca60-43cc-b75d-07aa9acf7b8a +a94a7e5c-4760-4148-841c-a7059fd2da73 +21df9a0a-828a-4855-b0a9-54f7f94a219d +2d55ad1d-6781-467c-bbce-f0b40a86c907 +cd4b908d-3cff-49a2-a59d-f5acea8bfcd3 +61bba94e-6486-40b7-b8f2-8ea656ed1794 +dae8b502-3634-42ce-81d6-0dba66f14646 +dad1d280-08c7-4928-ad57-077c5c660b98 +dad1d280-08c7-4928-ad57-077c5c660b98 +06016c56-66e6-4636-a2d8-288e58a43bc7 +3c683968-2df0-42f6-aa18-cc9dd0f6d5d1 +ddca0676-719a-445d-940b-7ffab61c9b28 +6b08b744-86c7-469e-9b77-84b354325294 +8bbfd1da-60eb-4308-a846-efdfce5e482e +e3a3eb67-625c-4337-aafe-ccd147388544 +4d09f28c-6bd1-430d-95e8-822571cbb5d3 +4d09f28c-6bd1-430d-95e8-822571cbb5d3 +4d5671fe-e125-42bd-8c1f-4ca469c391bc +884e0229-45ab-496d-9571-2230f83dddd8 +6d8c93f9-5742-4e0e-be01-b3bba0eb2029 +9ab8ab60-cb8f-4d7d-9551-3c602956b0ad +fa2d0fd8-2726-4f35-b518-3ff7f738ac27 +91313dd3-fb17-4ab2-b023-50974bdad7bd +1680262d-4cc9-42f1-b277-42399570576f +394cb821-fd29-498b-a977-22326738c4ee +5905cee6-2f78-4436-aba2-65d619e81953 +39d1c7bb-c762-4c88-80b0-2f429c55b7d4 +64f9a1de-f117-4c68-9a99-523d65ef8c80 +64a64c08-fdea-40d2-9004-33f3aa30e36d +d24fac9f-2a9e-4aeb-a938-dc601b1897dc +f1a694fa-9567-4d76-a9ec-e201d994d3f3 +97a2833f-f941-442f-8b3f-49fbc3cb6998 +e63d1504-8875-4d7e-98ae-cb4f1a6b74a9 +8c4b3d35-8b23-424b-9380-b510bb1d202d +f192f7bf-9af9-424e-b764-b1bc2178972f +88fa2a34-2b22-4d2b-a450-0e1aceae9ed9 +fc661b2d-649a-48ea-b699-1ce19a813fcb +fc66c8dd-f357-4b98-b84e-99ea48e56c13 +fc4f1080-7177-4d52-8892-8d662610e1c8 +ed637c70-2d14-4825-93d9-bebf3b6c7cdf +5efc0723-728c-4a06-a3b8-4ccb3882cbad +10c22cc6-726f-4bff-8415-ba29edf25976 +401acaf6-956c-46d1-981c-a21fe78d1f1d +97e4be9f-a48e-4763-86fb-dcebcb0f2504 +a0388e70-1d12-4d0f-b5f3-2256ca51d2ea +6d4428ae-908f-4d33-b5e8-c0e046cdc3ee +5b59d653-be0c-440a-91fa-9a546f964977 +d2c9a865-ae99-462b-97f6-ad90626776b8 +d2779b9d-2d81-4edc-aa4f-5d7c23da57eb +bfc5191c-ed54-491f-9563-a83f3939abb6 +bfad8a01-4384-4816-9992-a7a80c62b7ec +86b4d007-b099-4ee0-9a83-0653786632b3 +2af583d2-5494-4029-b073-27b0641e53ab +2ac2173a-02e3-444d-ac78-8e40c15bc02a +0246eb08-ccf0-4ede-aaf6-adfc3886bd3e +b13166c1-c08b-4b80-b4e3-85231d9a0c2e +02c06d86-8153-4751-9ffd-f6b87b9b7053 +023e513c-59db-43d0-b012-7d14dd15281a +5ddc7acf-928a-4fa2-ad4d-a55c3269365a +167e9432-85c5-4d14-a9f6-a6afb6cfb2bc +16e98daf-45a9-46da-8d4c-e8348266693d +8d2e9ede-8f88-43ec-9bef-6e2f06b202c7 +b1f5e658-57b0-403a-a649-958cd1aca197 +ac847d12-7f50-42a3-9266-447d4a781b55 +425b1a2b-f6fd-4e10-8e4e-4f9130bd358b +12fc0cb8-c990-4759-8fa1-5e12af33116a +f17fcced-4df3-4708-8ea9-5e121c968263 +9b104823-e834-42e7-b12b-6e0fcecb8a23 +57c0302d-7ef2-40a3-9628-a2d87871d582 +c7693e7f-a1b3-4e28-88e1-b398a965fdd1 +57e9847d-9b66-453e-a5bd-fdd9ac6c5045 +457f8150-56fb-452d-9f26-ce08b19b8260 +401c2c9e-fd7b-4c14-b4f0-d96913850e26 +3203fa2b-4e07-4422-a603-252a777cd368 +b6747b91-0ba4-406f-952d-da8504e88650 +047f3c18-5929-4c17-a019-f82e9c23dcc3 +a14c43ad-d872-4ccf-8b25-44a34e6a6ebf +b54a5768-7138-4417-80f1-8907e28d9b73 +5eca2554-84be-46e9-a8de-84624206c5b5 +8defd4d4-8145-4811-8da5-d1b3701874fe +c89b7eb3-640e-474c-8380-812437deae65 +30927c0a-e183-4b78-8887-22ddd4e275cd +7d9a2ead-b772-4576-804d-e93b04cddd8f +04f2125c-c815-4e59-ad03-ce67be7fece8 +578bb8cb-3c43-4d3e-836e-3848187add52 +ebef783e-da83-478b-8467-d5cc99709272 +f44e4332-a503-48cc-a415-c1cb98e96765 +cfd58fa4-72cf-4036-9b44-e371da3739dc +ab1e1209-eadf-4517-93c1-6351ca8a3487 +453de708-8779-4fc6-9ba3-55d3665f4d07 +8ae6d801-6dca-4d1a-b844-986a9f7f6017 +335ea771-10f6-41cf-898a-4adfbcd9fd08 +be7d39d9-9561-4485-a6f2-0f69f8084f83 +7bf20131-3764-439d-91b3-a418b3346244 +7f9b1521-fba1-425a-8af7-308645c8855e +fa1235da-fb0a-466c-a3fe-874d09e9c1ff +9c840025-74c8-4db1-b1d5-dd570dd11e88 +fcc2a413-2fcb-4603-90c4-4420dfb48840 +2fa1b862-dd70-4fb6-a9cb-1a33ba32381e +f8fb83f0-bf52-498d-aa69-646f485a0147 +13a259d2-934a-4f8f-ad92-d36513044309 +57c59690-4f72-4e81-b006-bceae375fe4f +f2015a6e-ea8b-4d5c-9c4e-0bf9409f4168 +b665e9a7-5d1e-4a0c-b6a8-f217498684eb +e47b0ecf-fe57-440f-80a1-bca04a2d59c8 +07f98c62-409d-40e0-897a-a9b5eb10baee +e20773d5-e98e-479a-8cb6-bc97c5239072 +8a914e39-6430-45af-9156-69a80943f5f4 +c8ee3377-7501-4954-aff5-c92e01f7cf95 +580fa313-d9b7-4b32-a0f6-18017ce9c32a +b1d9d52d-c628-465f-a74a-2d8a67857a94 +b1d9d52d-c628-465f-a74a-2d8a67857a94 +e98a33a6-6b1e-4500-837b-2ac80c765598 +4ffc6dc3-8903-4467-9387-0741b4e92f33 +fef38a2c-2830-4ee0-afa3-4c645de257c8 +82811161-df7e-41ec-8c2e-a3c9bbaba773 +c132fc69-6b79-4823-8c91-b4661291f1fe +f5b1aa38-41e2-474c-917d-806b2a43056c +eaf3a575-537b-467c-9369-8174fdf3f9ce +2aca2dff-e993-4e26-a51c-d855385c311c +9ecbb262-6d4b-4644-9acc-6c295743c225 +b2d6e47d-5430-45a4-b70e-4e0f5dba6966 +9fad8da3-9b63-4d79-a448-e87879952110 +ff6d25a3-fe5c-4957-ab42-dbb5190aa3b1 +be290561-9fd3-41c3-98ae-65581b2d7e71 +1bcfa63f-15d6-478b-bfb2-b5160da52d4a +c132fc69-6b79-4823-8c91-b4661291f1fe +83d296d5-14e7-47b2-9444-2bd69a843ac8 +bfe4f92a-7f5d-4d84-a44c-3aa30e14bf0b +6c026b1e-9390-4f73-ad95-0c5a3c1d69d5 +df63f4ef-aa09-4d7b-9306-04a61f7b5cd4 +35e80746-edc4-4ecb-bb71-65534e0feca1 +7a5949f6-72c0-41e2-b937-203cc4f74631 +d63ecd91-d34b-40fe-aeda-f1a6aad45923 +f09b4b2d-0879-4cfe-bbeb-b9b2e27526fb +4b79b361-4199-4a6b-af92-e4ce86971428 +06ef1b48-1eac-45ba-9578-bd09b1460489 +ebc28a49-2ac6-4ed3-9192-2a38fb4ce8e0 +212392da-916d-4e36-86b8-c43857cb766d +f746180e-f832-488d-910f-124f160934cd +610f0c17-6653-44b7-873a-fd1ef5daf65e +f1480aa2-c8c1-48cd-90b9-54318ee9f95b +6f6a3f86-dae5-4710-91c9-b3676b000893 +89c80fa3-6d1c-4385-91eb-92088148c9b1 +9240c35d-5eff-4f45-b250-b670fbba00f3 +1c139e50-bf9b-4831-8128-3a68d8a15c88 +070c8f21-8411-45e2-acec-eb1e9a05ba9d +075590cf-f73c-41e5-8b88-85e6eabb771d +876c9b59-9e43-4602-83e5-6b05e105e89e +73fd1b47-a741-49ff-8245-a57acdac132a +f0cff5a4-d446-407b-9315-e8b64d53b1f2 +b2d6e47d-5430-45a4-b70e-4e0f5dba6966 +048fea6e-a512-435c-8d42-f5630e2b6f43 +32e2eec9-0fc3-4828-839f-e0d1ff745afa +2405afd3-874e-477b-b518-ae8fdbd71e22 +26a4f01c-3811-49d5-8324-726a001359cd +56425281-46a6-4ae6-891e-330569b0a0b8 +183e7234-1a3a-4ae6-bd70-9baae352443b +97c31b37-de2c-48ac-b3a9-bc29f687da03 +595ab3e8-e341-4509-99d5-180f7de90123 +9b3a0453-6c7d-40e2-b2fa-6c8be2a55a9a +9b3a0453-6c7d-40e2-b2fa-6c8be2a55a9a +9b3a0453-6c7d-40e2-b2fa-6c8be2a55a9a \ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb index 0a3ade196..863ede1af 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.define(version: 2020_04_28_061736) do +ActiveRecord::Schema.define(version: 2020_04_30_205827) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" @@ -229,6 +229,7 @@ t.string "aasm_state" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.json "deconcatenated_subject" t.index ["logo_id"], name: "index_items_on_logo_id" t.index ["owner_id"], name: "index_items_on_owner_id" end @@ -289,6 +290,7 @@ t.string "aasm_state" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.json "deconcatenated_subject" t.index ["logo_id"], name: "index_theses_on_logo_id" t.index ["owner_id"], name: "index_theses_on_owner_id" end From 3b15b7dad7e13744d9fa08c75950c3cbd4c6d7cd Mon Sep 17 00:00:00 2001 From: Tricia Jenkins Date: Fri, 1 May 2020 14:37:55 -0600 Subject: [PATCH 2/5] address pr feedback - better path handling of files - use find_each to batch which would reduce memory use - added headings to the report log --- ...subject_issue.txt => ERA_subject_issue.txt | 0 ...econcatenate_subject_in_item_and_thesis.rb | 32 +++++++++++++------ 2 files changed, 22 insertions(+), 10 deletions(-) rename db/migrate/ERA_subject_issue.txt => ERA_subject_issue.txt (100%) diff --git a/db/migrate/ERA_subject_issue.txt b/ERA_subject_issue.txt similarity index 100% rename from db/migrate/ERA_subject_issue.txt rename to ERA_subject_issue.txt diff --git a/db/migrate/20200430205827_deconcatenate_subject_in_item_and_thesis.rb b/db/migrate/20200430205827_deconcatenate_subject_in_item_and_thesis.rb index 9ea2e6f5b..3bbbbf70f 100644 --- a/db/migrate/20200430205827_deconcatenate_subject_in_item_and_thesis.rb +++ b/db/migrate/20200430205827_deconcatenate_subject_in_item_and_thesis.rb @@ -4,18 +4,30 @@ def change add_column :items, :deconcatenated_subject, :json add_column :theses, :deconcatenated_subject, :json - concatenated_subject_ids = File.readlines('db/migrate/ERA_subject_issue.txt').collect(&:strip) - report = Logger.new('log/concatenatedsubjects.log') - (Item.all + Thesis.all).each do |item| - item.deconcatenated_subject = if concatenated_subject_ids.include? item.id - deconcatenated_subject = item.subject.map { |subject| subject.split(%r{,\s*}) }.flatten - report.info("#{item.id}, \"#{item.title}\", #{item.subject}, #{deconcatenated_subject}") - deconcatenated_subject - else - item.subject - end + @concatenated_subject_ids = File.readlines(Rails.root.join('ERA_subject_issue.txt')).collect(&:strip) + @report = Logger.new(Rails.root.join('log/concatenated_subjects.log')) + + Item.find_each do |item| + item.deconcatenated_subject = deconcatenated_subject(item) + item.save! + end + + Thesis.find_each do |item| + item.deconcatenated_subject = deconcatenated_subject(item) item.save! end end + def deconcatenated_subject(item) + return item.subject unless @concatenated_subject_ids.include? item.id + + deconcatenated_subject = item.subject.map { |subject| subject.split(%r{,\s*}) }.flatten + @report.info( + "id: #{item.id}, title: \"#{item.title}\", subject: #{item.subject},"\ + " deconcatenated subject: #{deconcatenated_subject}" + ) + + deconcatenated_subject + end + end From f83fa72abe6deb738ad52a4f974512fb819df401 Mon Sep 17 00:00:00 2001 From: Tricia Jenkins Date: Fri, 1 May 2020 15:21:27 -0600 Subject: [PATCH 3/5] further cleanup - missed array: true for the new columns - save directly to the database to bypass validations (some objects might need this exception to save) --- ...27_deconcatenate_subject_in_item_and_thesis.rb | 15 ++++----------- db/schema.rb | 4 ++-- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/db/migrate/20200430205827_deconcatenate_subject_in_item_and_thesis.rb b/db/migrate/20200430205827_deconcatenate_subject_in_item_and_thesis.rb index 3bbbbf70f..4779730d2 100644 --- a/db/migrate/20200430205827_deconcatenate_subject_in_item_and_thesis.rb +++ b/db/migrate/20200430205827_deconcatenate_subject_in_item_and_thesis.rb @@ -1,21 +1,14 @@ class DeconcatenateSubjectInItemAndThesis < ActiveRecord::Migration[6.0] def change - add_column :items, :deconcatenated_subject, :json - add_column :theses, :deconcatenated_subject, :json + add_column :items, :deconcatenated_subject, :json, array: true + add_column :theses, :deconcatenated_subject, :json, array: true @concatenated_subject_ids = File.readlines(Rails.root.join('ERA_subject_issue.txt')).collect(&:strip) @report = Logger.new(Rails.root.join('log/concatenated_subjects.log')) - Item.find_each do |item| - item.deconcatenated_subject = deconcatenated_subject(item) - item.save! - end - - Thesis.find_each do |item| - item.deconcatenated_subject = deconcatenated_subject(item) - item.save! - end + Item.find_each {|item| item.update_column deconcatenated_subject: deconcatenated_subject(item) } + Thesis.find_each {|item| item.update_column deconcatenated_subject: deconcatenated_subject(item) } end def deconcatenated_subject(item) diff --git a/db/schema.rb b/db/schema.rb index 863ede1af..01c5c608d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -229,7 +229,7 @@ t.string "aasm_state" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.json "deconcatenated_subject" + t.json "deconcatenated_subject", array: true t.index ["logo_id"], name: "index_items_on_logo_id" t.index ["owner_id"], name: "index_items_on_owner_id" end @@ -290,7 +290,7 @@ t.string "aasm_state" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.json "deconcatenated_subject" + t.json "deconcatenated_subject", array: true t.index ["logo_id"], name: "index_theses_on_logo_id" t.index ["owner_id"], name: "index_theses_on_owner_id" end From 1b48292de83311d84429d3f0a3284947d22e3f91 Mon Sep 17 00:00:00 2001 From: Tricia Jenkins Date: Thu, 11 Jun 2020 18:05:44 -0600 Subject: [PATCH 4/5] fix typo update_column takes (key,value) while update_columns takes parameters in the form (key: value) --- ...20200430205827_deconcatenate_subject_in_item_and_thesis.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/migrate/20200430205827_deconcatenate_subject_in_item_and_thesis.rb b/db/migrate/20200430205827_deconcatenate_subject_in_item_and_thesis.rb index 4779730d2..842b5f1bc 100644 --- a/db/migrate/20200430205827_deconcatenate_subject_in_item_and_thesis.rb +++ b/db/migrate/20200430205827_deconcatenate_subject_in_item_and_thesis.rb @@ -7,8 +7,8 @@ def change @concatenated_subject_ids = File.readlines(Rails.root.join('ERA_subject_issue.txt')).collect(&:strip) @report = Logger.new(Rails.root.join('log/concatenated_subjects.log')) - Item.find_each {|item| item.update_column deconcatenated_subject: deconcatenated_subject(item) } - Thesis.find_each {|item| item.update_column deconcatenated_subject: deconcatenated_subject(item) } + Item.find_each {|item| item.update_columns deconcatenated_subject: deconcatenated_subject(item) } + Thesis.find_each {|item| item.update_columns deconcatenated_subject: deconcatenated_subject(item) } end def deconcatenated_subject(item) From 8fe0ad8bc320e92354d1d6fa38625ed4630ab0da Mon Sep 17 00:00:00 2001 From: Tricia Jenkins Date: Thu, 9 Jul 2020 12:01:28 -0600 Subject: [PATCH 5/5] add some error handling We want to wrap this in the ability to catch an exception if the file doesn't exist, and then not do the rest of the migration and carry on. That way we can delete the file ERA_subject_issue.txt once this is all fixed instead of having to keep it around forever to avoid breaking migrations. --- ...200430205827_deconcatenate_subject_in_item_and_thesis.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/db/migrate/20200430205827_deconcatenate_subject_in_item_and_thesis.rb b/db/migrate/20200430205827_deconcatenate_subject_in_item_and_thesis.rb index 842b5f1bc..c9d8d3490 100644 --- a/db/migrate/20200430205827_deconcatenate_subject_in_item_and_thesis.rb +++ b/db/migrate/20200430205827_deconcatenate_subject_in_item_and_thesis.rb @@ -4,7 +4,11 @@ def change add_column :items, :deconcatenated_subject, :json, array: true add_column :theses, :deconcatenated_subject, :json, array: true - @concatenated_subject_ids = File.readlines(Rails.root.join('ERA_subject_issue.txt')).collect(&:strip) + @concatenated_subject_ids = if File.exist?(Rails.root.join('ERA_subject_issue.txt')) + File.readlines(Rails.root.join('ERA_subject_issue.txt')).collect(&:strip) + else + [] + end @report = Logger.new(Rails.root.join('log/concatenated_subjects.log')) Item.find_each {|item| item.update_columns deconcatenated_subject: deconcatenated_subject(item) }