From ba8e4e22b9f367f88637805a9966c94f415a6bc9 Mon Sep 17 00:00:00 2001 From: Oriol Gual Date: Thu, 13 May 2021 12:48:06 +0200 Subject: [PATCH] Don't migrate data, just schema --- ...7_add_scope_id_to_census_authorizations.rb | 24 ++++++++-------- ..._all_sessions_for_deleted_users.decidim.rb | 2 +- ...encrypt_authorization_metadatas.decidim.rb | 18 ++++++------ ...w_public_access_to_static_pages.decidim.rb | 18 ++++++------ ..._groups.decidim_participatory_processes.rb | 28 +++++++++---------- ...pe_and_url_to_meetings.decidim_meetings.rb | 10 +++---- ..._proposals_after_copy.decidim_proposals.rb | 16 +++++------ ...llowable_counter_cache_to_users.decidim.rb | 16 +++++------ ...ocesses.decidim_participatory_processes.rb | 16 +++++------ ..._cache_to_assemblies.decidim_assemblies.rb | 16 +++++------ ...nter_cache_to_meetings.decidim_meetings.rb | 16 +++++------ ..._for_copied_proposals.decidim_proposals.rb | 20 ++++++------- ...le_counter_cache_to_blogs.decidim_blogs.rb | 16 +++++------ ...ache_to_initiatives.decidim_initiatives.rb | 16 +++++------ ...blueprint_areas.decidim_navigation_maps.rb | 8 +++--- 15 files changed, 120 insertions(+), 120 deletions(-) diff --git a/db/migrate/20210217110107_add_scope_id_to_census_authorizations.rb b/db/migrate/20210217110107_add_scope_id_to_census_authorizations.rb index ba0dba9a7d..0d238ac592 100644 --- a/db/migrate/20210217110107_add_scope_id_to_census_authorizations.rb +++ b/db/migrate/20210217110107_add_scope_id_to_census_authorizations.rb @@ -1,17 +1,17 @@ class AddScopeIdToCensusAuthorizations < ActiveRecord::Migration[5.2] def up - scopes = Decidim::Scope.all - scopes_by_name = scopes.map{ |scope| [scope.name["ca"], scope.id] }.to_h - - Decidim::Authorization.where(name: "census_authorization_handler").find_each do |auth| - scope_name = cleanup_scope_name(auth.metadata["scope"]) - scope_id = scopes_by_name[scope_name] - - raise "ERROR: #{scope_name} scope not found for auth #{auth.id}" unless scope_id rescue byebug - auth.metadata["scope"] = scope_name - auth.metadata["scope_id"] = scope_id - auth.save - end + # scopes = Decidim::Scope.all + # scopes_by_name = scopes.map{ |scope| [scope.name["ca"], scope.id] }.to_h + # + # Decidim::Authorization.where(name: "census_authorization_handler").find_each do |auth| + # scope_name = cleanup_scope_name(auth.metadata["scope"]) + # scope_id = scopes_by_name[scope_name] + # + # raise "ERROR: #{scope_name} scope not found for auth #{auth.id}" unless scope_id rescue byebug + # auth.metadata["scope"] = scope_name + # auth.metadata["scope_id"] = scope_id + # auth.save + # end end def down; end diff --git a/db/migrate/20210303083722_invalidate_all_sessions_for_deleted_users.decidim.rb b/db/migrate/20210303083722_invalidate_all_sessions_for_deleted_users.decidim.rb index b4acff929e..98865e0d04 100644 --- a/db/migrate/20210303083722_invalidate_all_sessions_for_deleted_users.decidim.rb +++ b/db/migrate/20210303083722_invalidate_all_sessions_for_deleted_users.decidim.rb @@ -5,7 +5,7 @@ class InvalidateAllSessionsForDeletedUsers < ActiveRecord::Migration[5.2] def up Decidim::User.reset_column_information - Decidim::User.where.not(deleted_at: nil).find_each(&:invalidate_all_sessions!) + # Decidim::User.where.not(deleted_at: nil).find_each(&:invalidate_all_sessions!) end def down; end diff --git a/db/migrate/20210304082058_encrypt_authorization_metadatas.decidim.rb b/db/migrate/20210304082058_encrypt_authorization_metadatas.decidim.rb index 0985fef2bb..e3ccfba718 100644 --- a/db/migrate/20210304082058_encrypt_authorization_metadatas.decidim.rb +++ b/db/migrate/20210304082058_encrypt_authorization_metadatas.decidim.rb @@ -3,15 +3,15 @@ class EncryptAuthorizationMetadatas < ActiveRecord::Migration[5.2] def up - Decidim::Authorization.find_each do |auth| - # Re-setting these values will internally convert the hash values to - # encypted values - p "#{auth.name}: #{auth.id}" - auth.update!( - metadata: auth.metadata, - verification_metadata: auth.verification_metadata - ) - end + # Decidim::Authorization.find_each do |auth| + # # Re-setting these values will internally convert the hash values to + # # encypted values + # p "#{auth.name}: #{auth.id}" + # auth.update!( + # metadata: auth.metadata, + # verification_metadata: auth.verification_metadata + # ) + # end end def down diff --git a/db/migrate/20210304082059_add_allow_public_access_to_static_pages.decidim.rb b/db/migrate/20210304082059_add_allow_public_access_to_static_pages.decidim.rb index 5ca91ad021..6301ecc26f 100644 --- a/db/migrate/20210304082059_add_allow_public_access_to_static_pages.decidim.rb +++ b/db/migrate/20210304082059_add_allow_public_access_to_static_pages.decidim.rb @@ -5,14 +5,14 @@ class AddAllowPublicAccessToStaticPages < ActiveRecord::Migration[5.2] def change add_column :decidim_static_pages, :allow_public_access, :boolean, null: false, default: false - reversible do |direction| - direction.up do - # rubocop:disable Rails/SkipsModelValidations - Decidim::StaticPage.where(slug: "terms-and-conditions").update_all( - allow_public_access: true - ) - # rubocop:enable Rails/SkipsModelValidations - end - end + # reversible do |direction| + # direction.up do + # # rubocop:disable Rails/SkipsModelValidations + # Decidim::StaticPage.where(slug: "terms-and-conditions").update_all( + # allow_public_access: true + # ) + # # rubocop:enable Rails/SkipsModelValidations + # end + # end end end diff --git a/db/migrate/20210304082067_rename_name_column_to_title_in_decidim_participatory_process_groups.decidim_participatory_processes.rb b/db/migrate/20210304082067_rename_name_column_to_title_in_decidim_participatory_process_groups.decidim_participatory_processes.rb index 3efa4e7172..d6f92ef1ef 100644 --- a/db/migrate/20210304082067_rename_name_column_to_title_in_decidim_participatory_process_groups.decidim_participatory_processes.rb +++ b/db/migrate/20210304082067_rename_name_column_to_title_in_decidim_participatory_process_groups.decidim_participatory_processes.rb @@ -4,20 +4,20 @@ class RenameNameColumnToTitleInDecidimParticipatoryProcessGroups < ActiveRecord::Migration[5.2] def up rename_column :decidim_participatory_process_groups, :name, :title - PaperTrail::Version.where(item_type: "Decidim::ParticipatoryProcessGroup").each do |version| - # rubocop:disable Rails/SkipsModelValidations - version.update_attribute(:object_changes, version.object_changes.gsub(/^name:/, "title:")) if version.object_changes.present? - # rubocop:enable Rails/SkipsModelValidations - - next unless version.object.present? && version.object.has_key?("name") - - object = version.object - object["title"] = object.delete("name") - - # rubocop:disable Rails/SkipsModelValidations - version.update_attribute(:object, object) - # rubocop:enable Rails/SkipsModelValidations - end + # PaperTrail::Version.where(item_type: "Decidim::ParticipatoryProcessGroup").each do |version| + # # rubocop:disable Rails/SkipsModelValidations + # version.update_attribute(:object_changes, version.object_changes.gsub(/^name:/, "title:")) if version.object_changes.present? + # # rubocop:enable Rails/SkipsModelValidations + # + # next unless version.object.present? && version.object.has_key?("name") + # + # object = version.object + # object["title"] = object.delete("name") + # + # # rubocop:disable Rails/SkipsModelValidations + # version.update_attribute(:object, object) + # # rubocop:enable Rails/SkipsModelValidations + # end end def down diff --git a/db/migrate/20210304082073_add_registration_type_and_url_to_meetings.decidim_meetings.rb b/db/migrate/20210304082073_add_registration_type_and_url_to_meetings.decidim_meetings.rb index 42bf6d9652..25856107dd 100644 --- a/db/migrate/20210304082073_add_registration_type_and_url_to_meetings.decidim_meetings.rb +++ b/db/migrate/20210304082073_add_registration_type_and_url_to_meetings.decidim_meetings.rb @@ -11,10 +11,10 @@ def change add_column :decidim_meetings_meetings, :registration_type, :string, null: false, default: "registration_disabled" add_column :decidim_meetings_meetings, :registration_url, :string - Meetings.reset_column_information - Meetings.find_each do |meeting| - meeting.registration_type = "on_this_platform" if meeting.decidim_author_type == "Decidim::Organization" - meeting.save(validate: false) - end + # Meetings.reset_column_information + # Meetings.find_each do |meeting| + # meeting.registration_type = "on_this_platform" if meeting.decidim_author_type == "Decidim::Organization" + # meeting.save(validate: false) + # end end end diff --git a/db/migrate/20210304082074_fix_answered_proposals_after_copy.decidim_proposals.rb b/db/migrate/20210304082074_fix_answered_proposals_after_copy.decidim_proposals.rb index 93105d84b8..991fe32cb5 100644 --- a/db/migrate/20210304082074_fix_answered_proposals_after_copy.decidim_proposals.rb +++ b/db/migrate/20210304082074_fix_answered_proposals_after_copy.decidim_proposals.rb @@ -3,13 +3,13 @@ class FixAnsweredProposalsAfterCopy < ActiveRecord::Migration[5.2] def change - proposals_after_copy = Decidim::ResourceLink.where(from_type: "Decidim::Proposals::Proposal").pluck(:from_id) - - result = Decidim::Proposals::Proposal.where.not(state_published_at: nil).where(state: nil, id: proposals_after_copy) - - result.find_each do |proposal| - proposal.state_published_at = nil - proposal.save! - end + # proposals_after_copy = Decidim::ResourceLink.where(from_type: "Decidim::Proposals::Proposal").pluck(:from_id) + # + # result = Decidim::Proposals::Proposal.where.not(state_published_at: nil).where(state: nil, id: proposals_after_copy) + # + # result.find_each do |proposal| + # proposal.state_published_at = nil + # proposal.save! + # end end end diff --git a/db/migrate/20210319080608_add_followable_counter_cache_to_users.decidim.rb b/db/migrate/20210319080608_add_followable_counter_cache_to_users.decidim.rb index 1f0e0029b7..b7035b4f21 100644 --- a/db/migrate/20210319080608_add_followable_counter_cache_to_users.decidim.rb +++ b/db/migrate/20210319080608_add_followable_counter_cache_to_users.decidim.rb @@ -5,13 +5,13 @@ class AddFollowableCounterCacheToUsers < ActiveRecord::Migration[5.2] def change add_column :decidim_users, :follows_count, :integer, null: false, default: 0, index: true - reversible do |dir| - dir.up do - Decidim::User.reset_column_information - Decidim::User.find_each do |record| - record.class.reset_counters(record.id, :follows) - end - end - end + # reversible do |dir| + # dir.up do + # Decidim::User.reset_column_information + # Decidim::User.find_each do |record| + # record.class.reset_counters(record.id, :follows) + # end + # end + # end end end diff --git a/db/migrate/20210319080609_add_followable_counter_cache_to_participatory_processes.decidim_participatory_processes.rb b/db/migrate/20210319080609_add_followable_counter_cache_to_participatory_processes.decidim_participatory_processes.rb index 188adcdf03..d2d5809336 100644 --- a/db/migrate/20210319080609_add_followable_counter_cache_to_participatory_processes.decidim_participatory_processes.rb +++ b/db/migrate/20210319080609_add_followable_counter_cache_to_participatory_processes.decidim_participatory_processes.rb @@ -5,13 +5,13 @@ class AddFollowableCounterCacheToParticipatoryProcesses < ActiveRecord::Migratio def change add_column :decidim_participatory_processes, :follows_count, :integer, null: false, default: 0, index: true - reversible do |dir| - dir.up do - Decidim::ParticipatoryProcess.reset_column_information - Decidim::ParticipatoryProcess.find_each do |record| - record.class.reset_counters(record.id, :follows) - end - end - end + # reversible do |dir| + # dir.up do + # Decidim::ParticipatoryProcess.reset_column_information + # Decidim::ParticipatoryProcess.find_each do |record| + # record.class.reset_counters(record.id, :follows) + # end + # end + # end end end diff --git a/db/migrate/20210319080610_add_followable_counter_cache_to_assemblies.decidim_assemblies.rb b/db/migrate/20210319080610_add_followable_counter_cache_to_assemblies.decidim_assemblies.rb index f56e5f345f..6d88ba49e8 100644 --- a/db/migrate/20210319080610_add_followable_counter_cache_to_assemblies.decidim_assemblies.rb +++ b/db/migrate/20210319080610_add_followable_counter_cache_to_assemblies.decidim_assemblies.rb @@ -5,13 +5,13 @@ class AddFollowableCounterCacheToAssemblies < ActiveRecord::Migration[5.2] def change add_column :decidim_assemblies, :follows_count, :integer, null: false, default: 0, index: true - reversible do |dir| - dir.up do - Decidim::Assembly.reset_column_information - Decidim::Assembly.find_each do |record| - record.class.reset_counters(record.id, :follows) - end - end - end + # reversible do |dir| + # dir.up do + # Decidim::Assembly.reset_column_information + # Decidim::Assembly.find_each do |record| + # record.class.reset_counters(record.id, :follows) + # end + # end + # end end end diff --git a/db/migrate/20210319080611_add_followable_counter_cache_to_meetings.decidim_meetings.rb b/db/migrate/20210319080611_add_followable_counter_cache_to_meetings.decidim_meetings.rb index fa6d92436f..f57efe25a1 100644 --- a/db/migrate/20210319080611_add_followable_counter_cache_to_meetings.decidim_meetings.rb +++ b/db/migrate/20210319080611_add_followable_counter_cache_to_meetings.decidim_meetings.rb @@ -5,13 +5,13 @@ class AddFollowableCounterCacheToMeetings < ActiveRecord::Migration[5.2] def change add_column :decidim_meetings_meetings, :follows_count, :integer, null: false, default: 0, index: true - reversible do |dir| - dir.up do - Decidim::Meetings::Meeting.reset_column_information - Decidim::Meetings::Meeting.find_each do |record| - record.class.reset_counters(record.id, :follows) - end - end - end + # reversible do |dir| + # dir.up do + # Decidim::Meetings::Meeting.reset_column_information + # Decidim::Meetings::Meeting.find_each do |record| + # record.class.reset_counters(record.id, :follows) + # end + # end + # end end end diff --git a/db/migrate/20210319080614_fix_counters_for_copied_proposals.decidim_proposals.rb b/db/migrate/20210319080614_fix_counters_for_copied_proposals.decidim_proposals.rb index 505c8efd47..96a1010f98 100644 --- a/db/migrate/20210319080614_fix_counters_for_copied_proposals.decidim_proposals.rb +++ b/db/migrate/20210319080614_fix_counters_for_copied_proposals.decidim_proposals.rb @@ -3,16 +3,16 @@ class FixCountersForCopiedProposals < ActiveRecord::Migration[5.2] def up - copies_ids = Decidim::ResourceLink.where( - name: "copied_from_component", - from_type: "Decidim::Proposals::Proposal", - to_type: "Decidim::Proposals::Proposal" - ).pluck(:to_id) - - Decidim::Proposals::Proposal.where(id: copies_ids).find_each do |record| - record.class.reset_counters(record.id, :follows) - record.update_comments_count - end + # copies_ids = Decidim::ResourceLink.where( + # name: "copied_from_component", + # from_type: "Decidim::Proposals::Proposal", + # to_type: "Decidim::Proposals::Proposal" + # ).pluck(:to_id) + # + # Decidim::Proposals::Proposal.where(id: copies_ids).find_each do |record| + # record.class.reset_counters(record.id, :follows) + # record.update_comments_count + # end end def down; end diff --git a/db/migrate/20210319080617_add_followable_counter_cache_to_blogs.decidim_blogs.rb b/db/migrate/20210319080617_add_followable_counter_cache_to_blogs.decidim_blogs.rb index 6542c75575..0e7b05bc4d 100644 --- a/db/migrate/20210319080617_add_followable_counter_cache_to_blogs.decidim_blogs.rb +++ b/db/migrate/20210319080617_add_followable_counter_cache_to_blogs.decidim_blogs.rb @@ -5,13 +5,13 @@ class AddFollowableCounterCacheToBlogs < ActiveRecord::Migration[5.2] def change add_column :decidim_blogs_posts, :follows_count, :integer, null: false, default: 0, index: true - reversible do |dir| - dir.up do - Decidim::Blogs::Post.reset_column_information - Decidim::Blogs::Post.find_each do |record| - record.class.reset_counters(record.id, :follows) - end - end - end + # reversible do |dir| + # dir.up do + # Decidim::Blogs::Post.reset_column_information + # Decidim::Blogs::Post.find_each do |record| + # record.class.reset_counters(record.id, :follows) + # end + # end + # end end end diff --git a/db/migrate/20210319080618_add_followable_counter_cache_to_initiatives.decidim_initiatives.rb b/db/migrate/20210319080618_add_followable_counter_cache_to_initiatives.decidim_initiatives.rb index b39688ae5b..f7edb06d9c 100644 --- a/db/migrate/20210319080618_add_followable_counter_cache_to_initiatives.decidim_initiatives.rb +++ b/db/migrate/20210319080618_add_followable_counter_cache_to_initiatives.decidim_initiatives.rb @@ -5,13 +5,13 @@ class AddFollowableCounterCacheToInitiatives < ActiveRecord::Migration[5.2] def change add_column :decidim_initiatives, :follows_count, :integer, null: false, default: 0, index: true - reversible do |dir| - dir.up do - Decidim::Initiative.reset_column_information - Decidim::Initiative.find_each do |record| - record.class.reset_counters(record.id, :follows) - end - end - end + # reversible do |dir| + # dir.up do + # Decidim::Initiative.reset_column_information + # Decidim::Initiative.find_each do |record| + # record.class.reset_counters(record.id, :follows) + # end + # end + # end end end diff --git a/db/migrate/20210422132735_add_area_id_to_decidim_navigation_maps_blueprint_areas.decidim_navigation_maps.rb b/db/migrate/20210422132735_add_area_id_to_decidim_navigation_maps_blueprint_areas.decidim_navigation_maps.rb index 7d8ceea854..8dd3d0f763 100644 --- a/db/migrate/20210422132735_add_area_id_to_decidim_navigation_maps_blueprint_areas.decidim_navigation_maps.rb +++ b/db/migrate/20210422132735_add_area_id_to_decidim_navigation_maps_blueprint_areas.decidim_navigation_maps.rb @@ -9,9 +9,9 @@ class Area < ApplicationRecord def change add_column :decidim_navigation_maps_blueprint_areas, :area_id, :string - Area.find_each do |area| - area.area_id = area.id - area.save! - end + # Area.find_each do |area| + # area.area_id = area.id + # area.save! + # end end end