OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
squash migrations below 15.0
ulferts2b68eb08ad65
diff --git a/.github/dangerfiles/user_references/Dangerfile b/.github/dangerfiles/user_references/Dangerfileindex 7440002c25f..3c49a34ff29 100644--- a/.github/dangerfiles/user_references/Dangerfile+++ b/.github/dangerfiles/user_references/Dangerfile@@ -39,7 +39,10 @@ def files_with_user_referencesfiles = {}# Check migrations- added_or_modified_migrations?.each do |file|+ added_or_modified_migrations?+ # Ignore files that have been removed.+ .select { |file| File.exist?(file) }+ .each do |file|content = File.read(file)if content.match?(USER_REFERENCE_REGEX)files[file] = "migration with user reference"diff --git a/db/migrate/10000000000000_to_v710_aggregated_migrations.rb b/db/migrate/10000000000000_to_v710_aggregated_migrations.rbdeleted file mode 100644index 03584ec3d31..00000000000--- a/db/migrate/10000000000000_to_v710_aggregated_migrations.rb+++ /dev/null@@ -1,213 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--Dir["#{Rails.root.join('db/migrate/tables/*.rb')}"].each { |file| require file }-Dir["#{Rails.root.join('db/migrate/aggregated/*.rb')}"].each { |file| require file }--# This migration aggregates a set of former migrations-class ToV710AggregatedMigrations < ActiveRecord::Migration[5.1]- class IncompleteMigrationsError < ::StandardError- end-- @tables = [- Tables::WorkPackages,- Tables::Users,- Tables::GroupUsers,- Tables::Categories,- Tables::Relations,- Tables::Statuses,- Tables::Projects,- Tables::TimeEntries,- Tables::Sessions,- Tables::Announcements,- Tables::Attachments,- Tables::AuthSources,- Tables::Boards,- Tables::Messages,- Tables::CustomFields,- Tables::CustomFieldsProjects,- Tables::CustomFieldsTypes,- Tables::CustomOptions,- Tables::CustomValues,- Tables::Changesets,- Tables::ChangesetsWorkPackages,- Tables::Journals,- Tables::WorkPackageJournals,- Tables::MessageJournals,- Tables::NewsJournals,- Tables::WikiContentJournals,- Tables::TimeEntryJournals,- Tables::ChangesetJournals,- Tables::AttachmentJournals,- Tables::AttachableJournals,- Tables::CustomizableJournals,- Tables::Comments,- Tables::Changes,- Tables::Repositories,- Tables::Enumerations,- Tables::Roles,- Tables::RolePermissions,- Tables::MemberRoles,- Tables::Members,- Tables::News,- Tables::ProjectTypes,- Tables::PlanningElementTypeColors,- Tables::Reportings,- Tables::AvailableProjectStatuses,- Tables::ProjectAssociations,- Tables::Timelines,- Tables::ProjectsTypes,- Tables::Queries,- Tables::Types,- Tables::Settings,- Tables::Tokens,- Tables::UserPreferences,- Tables::UserPasswords,- Tables::Versions,- Tables::Watchers,- Tables::WikiContentVersions,- Tables::WikiContents,- Tables::WikiPages,- Tables::WikiRedirects,- Tables::Wikis,- Tables::Workflows,- Tables::DelayedJobs,- Tables::MenuItems,- Tables::CustomStyles,- Tables::DesignColors,- Tables::EnterpriseTokens,- Tables::EnabledModules- ]-- def self.tables- @tables- end-- def up- raise_on_incomplete_3_0_migrations- raise_on_incomplete_7_1_migrations-- intersection = aggregated_versions_7_1 & all_versions-- if intersection == aggregated_versions_7_1- remove_applied_migration_entries(intersection)- else- run_aggregated_migrations- end- end-- def down- raise ActiveRecord::IrreversibleMigration, "Use OpenProject v7.4 for the down migrations"- end-- private-- # No migrations that this migration aggregates have already been- # applied. In this case, run the aggregated migration.- def run_aggregated_migrations- create_tables- end-- # All migrations that this migration aggregates have already- # been applied. In this case, remove the information about those- # migrations from the schema_migrations table and we're done.- def remove_applied_migration_entries(intersection)- execute <<-SQL + (intersection.map { |version| <<-CONDITIONS }).join(" OR ")- DELETE FROM- #{quoted_schema_migrations_table_name}- WHERE- SQL- #{version_column_for_comparison} = #{quote_value(version.to_s)}- CONDITIONS- end-- def raise_on_incomplete_3_0_migrations- raise_on_incomplete_migrations(aggregated_versions_3_0, "v2.4.0", "ChiliProject")- end-- def raise_on_incomplete_7_1_migrations- raise_on_incomplete_migrations(aggregated_versions_7_1, "v7.4.0", "OpenProject")- end-- def raise_on_incomplete_migrations(aggregated_versions, version_number, app_name)- intersection = aggregated_versions & all_versions-- if !intersection.empty? && intersection != aggregated_versions-- missing = aggregated_versions - intersection-- # Only a part of the migrations that this migration aggregates- # have already been applied. In this case, fail miserably.- raise IncompleteMigrationsError, <<-MESSAGE.split("\n").map(&:strip!).join(" ") + "\n"- It appears you are migrating from an incompatible version of- #{app_name}. Yourdatabase has only some migrations from #{app_name} <- #{version_number} Please update your database to the schema of #{app_name}- #{version_number} and run the OpenProject migrations again. The following- migrations are missing: #{missing}- MESSAGE- end- end-- def create_tables- self.class.tables.each do |table|- table.create(self)- end- end-- def aggregated_versions_3_0- Aggregated::To_3_0.normalized_migrations- end-- def aggregated_versions_7_1- Aggregated::To_7_1.normalized_migrations- end-- def all_versions- @all_versions ||= ActiveRecord::Base.connection.pool.migration_context.get_all_versions- end-- def schema_migrations_table_name- ActiveRecord::Base.connection.schema_migration.table_name- end-- def quoted_schema_migrations_table_name- ActiveRecord::Base.connection.quote_table_name(schema_migrations_table_name)- end-- def quoted_version_column_name- ActiveRecord::Base.connection.quote_table_name("version")- end-- def version_column_for_comparison- "#{quoted_schema_migrations_table_name}.#{quoted_version_column_name}"- end-- def quote_value(s)- ActiveRecord::Base.connection.quote(s)- end-enddiff --git a/db/migrate/1000015_aggregated_migrations.rb b/db/migrate/1000015_aggregated_migrations.rbnew file mode 100644index 00000000000..3c26a15cafc--- /dev/null+++ b/db/migrate/1000015_aggregated_migrations.rb@@ -0,0 +1,415 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++Dir[Rails.root.join("db/migrate/tables/*.rb").to_s].each { |file| require file }+Dir[Rails.root.join("db/migrate/extensions/*.rb").to_s].each { |file| require file }+require Rails.root.join("db/migrate/migration_utils/squashed_migration").to_s++# This migration aggregates a set of former migrations+class AggregatedMigrations < SquashedMigration+ extensions Extensions::BtreeGist,+ Extensions::PgTrgm,+ Extensions::Unaccent,+ Extensions::VersionNameCollation++ tables Tables::Projects,+ Tables::Colors,+ Tables::Types,+ Tables::Statuses,+ Tables::WorkPackages,+ Tables::Users,+ Tables::GroupUsers,+ Tables::Categories,+ Tables::Relations,+ Tables::WorkPackageHierarchies,+ Tables::Sessions,+ Tables::Announcements,+ Tables::Attachments,+ Tables::LdapAuthSources,+ Tables::Forums,+ Tables::Messages,+ Tables::CustomFieldSections,+ Tables::CustomFields,+ Tables::CustomFieldsProjects,+ Tables::CustomFieldsTypes,+ Tables::CustomOptions,+ Tables::CustomValues,+ Tables::Changesets,+ Tables::ChangesetsWorkPackages,+ Tables::Journals,+ Tables::WorkPackageJournals,+ Tables::ProjectJournals,+ Tables::MessageJournals,+ Tables::NewsJournals,+ Tables::WikiPageJournals,+ Tables::ChangesetJournals,+ Tables::AttachmentJournals,+ Tables::AttachableJournals,+ Tables::CustomizableJournals,+ Tables::Comments,+ Tables::Changes,+ Tables::Repositories,+ Tables::Enumerations,+ Tables::Roles,+ Tables::RolePermissions,+ Tables::MemberRoles,+ Tables::Members,+ Tables::News,+ Tables::ProjectsTypes,+ Tables::Queries,+ Tables::Settings,+ Tables::Tokens,+ Tables::UserPreferences,+ Tables::UserPasswords,+ Tables::Versions,+ Tables::Watchers,+ Tables::WikiPages,+ Tables::WikiRedirects,+ Tables::Wikis,+ Tables::Workflows,+ Tables::Exports,+ Tables::MenuItems,+ Tables::CustomStyles,+ Tables::DesignColors,+ Tables::EnterpriseTokens,+ Tables::EnabledModules,+ Tables::AttributeHelpTexts,+ Tables::CustomActions,+ Tables::CustomActionsProjects,+ Tables::CustomActionsRoles,+ Tables::CustomActionsStatuses,+ Tables::CustomActionsTypes,+ Tables::OAuthApplications,+ Tables::OAuthAccessGrants,+ Tables::OAuthAccessTokens,+ Tables::OrderedWorkPackages,+ Tables::Notifications,+ Tables::NotificationSettings,+ Tables::Views,+ Tables::OAuthClients,+ Tables::OAuthClientTokens,+ Tables::NonWorkingDays,+ Tables::PaperTrailAudits,+ Tables::ProjectCustomFieldProjectMappings,+ Tables::ProjectQueries,+ Tables::GoodJobs,+ Tables::GoodJobProcesses,+ Tables::GoodJobSettings,+ Tables::GoodJobBatches,+ Tables::GoodJobExecutions,+ Tables::Favorites,+ Tables::EmojiReactions,+ Tables::AuthProviders,+ Tables::RemoteIdentities,+ Tables::HierarchicalItems,+ Tables::HierarchicalItemHierarchies++ # rubocop:disable Metrics/CollectionLiteralLength+ squashed_migrations *%w[+ 10000000000000_to_v710_aggregated_migrations+ 20100528100562_aggregated_global_roles_migrations+ 20170703075208_add_attribute_help_texts+ 20170705134348_remove_attribute_visibility+ 20170818063404_add_timeline_labels_to_query+ 20170829095701_generate_wp_closure+ 20171106074835_move_hashed_token_to_core+ 20171129145631_add_fulltext_to_attachments+ 20180105130053_rebuild_dag+ 20180108132929_vacuum_relations+ 20180116065518_add_hierarchy_paths+ 20190301122554_remove_hierarchy_paths+ 20180117065255_remove_timelines_and_reportings+ 20180122135443_add_tsv_columns_to_attachments+ 20180123092002_add_custom_actions+ 20180213155320_add_description_to_custom_actions+ 20180221151038_add_position_to_custom_action+ 20180305130811_remove_wiki_content_versions+ 20180419061910_timestamp_for_caching+ 20180504144320_add_color_to_statuses_and_enumerations+ 20180510184732_rename_planning_elemnt_type_colors_to_colors+ 20180518130559_add_timestamps_to_wiki+ 20180524084654_remove_non_null_container_on_attachments+ 20180524113516_add_consent_timestamp_to_user+ 20180706150714_convert_to_markdown+ 20180717102331_remove_in_aggregation_from_type+ 20180801072018_remove_responsible_and_type_from_project+ 20180830120550_migrate_light_background_themes+ 20180903110212_add_highlighting_to_query+ 20180924141838_add_highlighted_attributes_to_query+ 20181101132712_add_read_only_to_statuses+ 20181112125034_create_doorkeeper_tables+ 20181121174153_create_ordered_work_packages+ 20190124081710_remove_accessibility_mode+ 20190207155607_add_hidden_to_queries+ 20190227163226_add_tls_mode_to_auth_sources+ 20190312083304_rename_boards_to_forums+ 20190411122815_set_timeline_auto_zoom+ 20190502102512_ensure_postgres_index_names+ 20190507132517_add_board_view_to_roles+ 20190509071101_add_default_description_to_types+ 20190527095959_set_manage_board_permission+ 20190603060951_set_assign_versions_permission+ 20190618115620_fix_available_languages+ 20190619143049_add_timestamps_to_query+ 20190716071941_add_display_representation_to_query+ 20190722082648_add_derived_estimated_hours_to_work_packages+ 20190724093332_add_journal_versions_table+ 20190920102446_clean_custom_values+ 20190923111902_add_project_status_reporting+ 20190923123858_simplify_project_active_and_timestamp+ 20191106132533_make_system_user_active+ 20191112111040_fix_system_user_status+ 20191115141154_add_content_orientation_to_custom_fields+ 20191216135213_join_table_for_active_activities+ 20200114091135_add_theme_name_to_custom_styles+ 20200115090742_fix_parent_id_for_wiki_pages+ 20200206101135_add_theme_logo_to_custom_style+ 20200217061622_add_timestamp_to_news+ 20200217155632_rename_tokens+ 20200220171133_rename_bim_module+ 20200302100431_fix_attachable_journals+ 20200325101528_strip_whitespace_from_user_attributes+ 20200326102408_rename_fixed_version+ 20200403105252_add_cron_to_delayed_jobs+ 20200415131633_add_work_package_exports+ 20200427121606_add_filter_to_ldap+ 20200428105404_unique_member_role+ 20200504085933_add_schedule_manually_to_work_packages+ 20200522131255_splash_multi_list_customizable_journals+ 20200522140244_remove_journal_versions_table+ 20200527130633_add_templated_to_project+ 20200625133727_fix_inherited_group_member_roles+ 20200708065116_fix_members_inconsistencies+ 20200803081038_journalize_scheduling_mode+ 20200820140526_remove_summable_setting+ 20200903064009_enable_current_project_custom_fields_columns+ 20200907090753_change_attachment_filesize_to_big_int+ 20200914092212_set_current_timestamp_defaults_for_bcf_viewpoints_and_issues+ 20200924085508_cleanup_orphaned_journal_data+ 20200925084550_members_allow_null_on_project+ 20201005120137_ensure_integer_for_relations_foreign_keys+ 20201005184411_rename_timestamps+ 20201125121949_remove_renamed_cron_job+ 20210221230446_add_group_user_primary_key+ 20210126112238_add_uniqueness_constrain_on_lastname_for_groups_and_placeholder_users+ 20210127134438_alter_user_attributes_max_length.rb+ 20210214205545_replace_invalid_principal_references+ 20210310101840_generalize_exports+ 20210331085058_migrate_sessions_unlogged+ 20210427065703_make_system_user_admin+ 20210510193438_remove_project_setting+ 20210512121322_make_project_identifier_unique+ 20210519141244_remove_reply_from_message_journalizing+ 20210616145324_polymorphic_journal_data+ 20210616191052_create_notifications+ 20210618125430_authors_as_watchers+ 20210618132206_add_notification_settings+ 20210628185054_extend_custom_field_name_length+ 20210701073944_add_digest_setting+ 20210701082511_add_digest_to_notification+ 20210726070813_remove_journal_versions+ 20210802114054_add_notification_setting_options+ 20210825183540_make_user_preferences_json+ 20210902201126_cleanup_user_preferences+ 20210914065555_cleanup_notifications+ 20210915154656_add_user_preference_settings_indices+ 20210917190141_non_work_package_notification_settings+ 20210922123908_notification_foreign_key_constraint+ 20210928133538_add_reminder_workdays+ 20211005080304_tzinfo_time_zones+ 20211005135637_remove_invalid_group_users+ 20211026061420_add_indexes_for_email_reminder_pause+ 20211101152840_redistribute_edit_project_permission+ 20211102161932_remove_custom_field_types+ 20211103120946_clean_emails_footer+ 20211104151329_default_notification_setting+ 20211117195121_remove_destroyed_help_texts+ 20211118203332_clean_hide_mail+ 20211130161501_add_views+ 20211209092519_query_views+ 20220106145037_fix_missing_notification_settings+ 20220202140507_reorder_project_children+ 20220223095355_projects_lft_rgt_index+ 20220302123642_assignable_to_permission+ 20220319211253_add_parent_id_to_wp+ 20220323083000_add_include_subprojects_to_query+ 20220414085531_migrate_team_planner_permissions+ 20220428071221_restore_defaults_on_empty_settings+ 20220426132637_refix_inherited_group_member_roles+ 20220408080838_bigint_primary_key_on_relations+ 20220503093844_create_oauth_client+ 20220511124930_create_week_days+ 20220517113828_create_non_working_days+ 20220518154147_create_oauth_client_tokens+ 20220525154549_add_duration_to_work_packages+ 20220614132200_add_ignore_non_working_days_to_work_packages+ 20220615213015_migrate_log_time_to_log_own_time_in_role_permissions+ 20220620132922_change_duration_default_value+ 20220622151721_drop_project_associations+ 20220629061540_add_paper_trail+ 20220629073727_add_polymorphic_integration_to_oauth_application+ 20220712132505_add_foreign_key_constraint_for_type_color_id+ 20220714145356_migrate_work_package_export_settings+ 20220804112533_remove_notification_cleanup_job+ 20220811061024_rename_work_package_export_limit+ 20220817154403_remove_work_packages_duration_field_active_setting+ 20220818074150_fix_invalid_journals+ 20220818074159_fix_deleted_data_journals+ 20220830074821_add_ignore_non_working_days_to_work_package_journals+ 20220830092057_change_default_for_non_working_days+ 20220831073113_work_package_project_foreign_key+ 20220831081937_migrate_timestamps_to_with_timezone+ 20220909153412_drop_week_days+ 20220911182835_create_default_working_days_setting_entry+ 20220918165443_add_start_date_due_date_and_overdue_to_notification_settings+ 20220922200908_split_involved_notification_setting+ 20220926124435_constrain_work_package_dates+ 20220929114423_add_unique_index_to_ldap_groups_membership+ 20220930133418_set_duration_for_milestone_work_packages+ 20221017073431_remove_orphaned_tokens+ 20221017184204_change_defaults_for_notification_settings+ 20221026132134_bigint_primary_and_foreign_keys+ 20221028070534_change_notification_settings_start_date_due_date_and_overdue_duration_unit_to_days+ 20221027151959_remove_plaintext_tokens+ 20221029194419_add_timestamps_to_queries+ 20221115082403_add_ldap_tls_options+ 20221129074635_remove_activity_type_from_journals_table+ 20221130150352_create_project_journals+ 20221201140825_add_non_null_constraint_on_projects_identifier+ 20221202130039_fill_project_journals_with_existing_data+ 20221213092910_remove_default_values_from_journal_tables_definition+ 20230508150835_copy_project_status_into_projects_and_journals+ 20230105073117_remove_renamed_date_alert_job+ 20230105134940_work_package_date_indices+ 20230130134630_add_index_for_work_package_journals_project_id+ 20230306083203_non_null_data_reference_on_journals+ 20230309104056_unique_index_on_custom_fields_projects+ 20230314093106_add_update_delete_cascade_to_work_packages_project_id+ 20230314165213_add_foreign_keys_to_work_packages+ 20230315103437_add_foreign_keys_to_workflows+ 20230315183431_add_foreign_keys_to_projects_types+ 20230315184533_add_foreign_keys_to_custom_fields_projects+ 20230322135932_merge_wiki_content_into_page+ 20230328154645_add_gin_trgm_index_on_journals_and_custom_values+ 20230531093004_remove_default_from_query_name+ 20230606083221_add_cause_to_journal+ 20230608151123_add_validity_period_to_journals+ 20230613155001_add_export_logo_to_custom_style+ 20230718084649_add_create_user_permission_to_roles+ 20230726061920_rename_auth_source_to_ldap_auth_source+ 20230726112130_remove_type_from_ldap_auth_sources+ 20230803113215_add_indices_to_work_package_journals+ 20230808080001_remove_some_string_length_constraints+ 20230808140921_add_derived_remaining_hours_to_work_packages+ 20230810074642_add_optional_entity_to_members+ 20230829151629_add_copy_work_packages_permission_to_roles+ 20230905090205_add_share_workpackages_permission+ 20230905126002_add_export_cover_to_custom_style+ 20230911093530_remove_news_journals_title_length_constraint+ 20230912185647_add_view_shared_work_packages_permission+ 20231002141527_fix_default_language_value_for_chinese_simplified+ 20231005113307_role_to_project_role+ 20231017093339_add_allow_non_open_versions_to_custom_fields+ 20231024150429_add_shared_to_notification_settings+ 20231026111049_add_public_permissions_to_project_roles+ 20231027102747_rollback_create_meeting_agendas_and_split_edit_meeting_role+ 20231031133334_create_project_custom_field_project_mappings+ 20231105194747_add_data_to_tokens+ 20231123111357_create_custom_field_sections+ 20231128080650_add_work_package_roles+ 20231205143648_add_add_work_package_attachment_permission_to_commenters+ 20231212131603_set_custom_fields_filter_default_true+ 20231227100753_fix_derived_work_and_remaining_work_values+ 20240104172050_add_project_queries+ 20240115112549_fix_spent_time_widget_identifier+ 20240116165933_add_derived_done_ratio_to_work_packages+ 20240123151246_create_good_jobs+ 20240123151247_create_good_job_settings+ 20240123151248_create_index_good_jobs_jobs_on_priority_created_at_when_unfinished+ 20240123151249_create_good_job_batches+ 20240123151250_create_good_job_executions+ 20240123151251_create_good_jobs_error_event+ 20240123151252_recreate_good_job_cron_indexes_with_conditional+ 20240131130134_fix_inherited_group_memberships+ 20240206173841_fix_untranslated_work_package_roles+ 20240207075946_add_status_to_attachment+ 20240208100316_enable_required_project_custom_fields_in_all_projects+ 20240222155909_rename_columns_on_project_queries+ 20240227154544_remove_delayed_jobs+ 20240306083241_change_default_value_of_alternative_color+ 20240306154734_create_good_job_labels+ 20240306154735_create_good_job_labels_index+ 20240306154736_remove_good_job_active_id_index+ 20240306154737_create_index_good_job_jobs_for_candidate_lookup+ 20240206085104_remove_enums+ 20240307094432_change_done_ratio_default_value_to_null+ 20240307102541_reduce_configurable_design_variables+ 20240307190126_rename_portuguese_locale+ 20240311111957_enable_unaccent_extension+ 20240325150312_change_derived_done_ratio_default_value_to_null+ 20240328154805_change_status_default_done_ratio_to_zero+ 20240402065214_remove_ldap_tls_setting+ 20240402072213_update_progress_calculation+ 20240404074025_create_favorite+ 20240408093541_change_default_accent_and_bim_primary_color+ 20240422141623_rename_estimate_and_time_attribute_group+ 20240424093311_add_excluded_from_totals_to_statuses+ 20240424160513_add_settings_to_projects+ 20240430143313_update_default_project_columns+ 20240506091102_remove_totals_from_childless_work_packages+ 20240513135928_extend_oauth_applications+ 20240519123921_add_public_to_project_queries+ 20240522073759_fix_status_excluded_from_totals_changed_journal_cause+ 20240527070439_add_project_query_roles+ 20240611105232_set_watched_notification_setting_to_true+ 20240624103354_create_emoji_reactions+ 20240625075139_add_uniqueness_index_to_project_custom_field_project_mappings+ 20240703131639_add_timestamps_to_user_preferences+ 20240715183144_add_indexes_to_custom_options+ 20240801105918_add_auth_providers+ 20240805104004_rename_visible_to_admin_only_in_custom_fields+ 20240806144333_create_remote_identities+ 20240808125617_populate_remote_identities+ 20240808133947_add_lock_version_to_oauth_client_tokens+ 20240813131647_drop_origin_user_id_from_oauth_client_tokens+ 20240820123011_remove_project_from_notification+ 20240909151818_migrate_legacy_default_theme_to_light_theme+ 20240920152544_set_versions_name_collation+ 20240924114246_create_hierarchical_items+ 20240408132459_rename_delay_to_lag+ 20240410060041_remove_virtual_delay_column+ 20240620115412_add_project_attribute_roles+ 20240917105829_add_primary_key_to_custom_fields_projects+ 20241001205821_add_standard_global_role+ 20241002151949_remove_hide_mail_from_user_preferences+ 20241015081341_remove_obsolete_design_variables+ ]+ # rubocop:enable Metrics/CollectionLiteralLength+enddiff --git a/db/migrate/20100528100562_aggregated_global_roles_migrations.rb b/db/migrate/20100528100562_aggregated_global_roles_migrations.rbdeleted file mode 100644index f143acd730a..00000000000--- a/db/migrate/20100528100562_aggregated_global_roles_migrations.rb+++ /dev/null@@ -1,66 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require Rails.root.join("db/migrate/migration_utils/migration_squasher").to_s-require "open_project/plugins/migration_mapping"-# This migration aggregates the migrations detailed in MIGRATION_FILES-class AggregatedGlobalRolesMigrations < ActiveRecord::Migration[5.0]- MIGRATION_FILES = <<-MIGRATIONS- 001_sti_for_roles.rb- MIGRATIONS-- OLD_PLUGIN_NAME = "redmine_global_roles"-- def up- migration_names = OpenProject::Plugins::MigrationMapping.migration_files_to_migration_names(MIGRATION_FILES, OLD_PLUGIN_NAME)- Migration::MigrationSquasher.squash(migration_names) do- add_column :roles, :type, :string, limit: 30, default: "Role"-- ActiveRecord::Base.connection.execute("UPDATE roles SET type='Role';")-- Role.reset_column_information-- create_table :principal_roles do |t|- t.column :role_id, :integer, null: false- t.column :principal_id, :integer, null: false- t.timestamps- end-- add_index :principal_roles, :role_id- add_index :principal_roles, :principal_id- end- end-- def down- remove_column :roles, :type- remove_index :principal_roles, :role_id- remove_index :principal_roles, :principal_id- drop_table :principal_roles- Role.reset_column_information- end-enddiff --git a/db/migrate/20170705134348_remove_attribute_visibility.rb b/db/migrate/20170705134348_remove_attribute_visibility.rbdeleted file mode 100644index 988df9059e4..00000000000--- a/db/migrate/20170705134348_remove_attribute_visibility.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RemoveAttributeVisibility < ActiveRecord::Migration[5.0]- def change- remove_column :types, :attribute_visibility, :text- end-enddiff --git a/db/migrate/20170818063404_add_timeline_labels_to_query.rb b/db/migrate/20170818063404_add_timeline_labels_to_query.rbdeleted file mode 100644index 1e1aa3ad8f8..00000000000--- a/db/migrate/20170818063404_add_timeline_labels_to_query.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddTimelineLabelsToQuery < ActiveRecord::Migration[5.0]- def change- add_column :queries, :timeline_labels, :text- end-enddiff --git a/db/migrate/20170829095701_generate_wp_closure.rb b/db/migrate/20170829095701_generate_wp_closure.rbdeleted file mode 100644index f131eeb310c..00000000000--- a/db/migrate/20170829095701_generate_wp_closure.rb+++ /dev/null@@ -1,232 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class GenerateWpClosure < ActiveRecord::Migration[5.0]- def up- add_relation_type_column-- update_relation_column_from_relation_type-- invert_from_to_on_follows("relation_type = 'precedes'")-- insert_hierarchy_relation_for_parent-- remove_column :relations, :relation_type-- remove_nested_set_columns- end-- def down- recreate_nested_set_columns-- invert_from_to_on_follows("follows = 1")-- set_parent_id-- remove_hierarchy_relations-- fill_relation_type_column-- remove_relation_type_specific_columns-- rebuild_nested_set- end-- def relation_types- %i(hierarchy relates duplicates blocks follows includes requires)- end-- def add_relation_type_column- change_table :relations do |r|- relation_types.each do |column|- r.column column, :integer, default: 0, null: false- end- end- end-- def remove_nested_set_columns- remove_column :work_packages, :parent_id- remove_column :work_packages, :root_id- remove_column :work_packages, :lft- remove_column :work_packages, :rgt- end-- def recreate_nested_set_columns- add_column :work_packages, :parent_id, :integer- add_column :work_packages, :root_id, :integer- add_column :work_packages, :lft, :integer- add_column :work_packages, :rgt, :integer-- add_index :work_packages, :parent_id- add_index :work_packages, %i(root_id lft rgt)- end-- def remove_hierarchy_relations- ActiveRecord::Base.connection.execute <<-SQL- DELETE FROM relations- WHERE hierarchy > 0- SQL- end-- def invert_from_to_on_follows(condition)- if ActiveRecord::Base.connection.adapter_name == "Mysql2"- ActiveRecord::Base.connection.execute <<-SQL- UPDATE- relations r1,- relations r2- SET- r1.to_id = r1.from_id,- r1.from_id = r2.to_id- WHERE- r1.id = r2.id- AND- r1.#{condition}- SQL- else- ActiveRecord::Base.connection.execute <<-SQL- UPDATE- relations- SET- from_id = to_id,- to_id = from_id- WHERE- #{condition}- SQL- end- end-- def update_relation_column_from_relation_type- ActiveRecord::Base.connection.execute <<-SQL- UPDATE- relations- SET- relates = CASE- WHEN relations.relation_type = 'relates'- THEN 1- ELSE 0- END,- duplicates = CASE- WHEN relations.relation_type = 'duplicates'- THEN 1- ELSE 0- END,- blocks = CASE- WHEN relations.relation_type = 'blocks'- THEN 1- ELSE 0- END,- follows = CASE- WHEN relations.relation_type = 'precedes'- THEN 1- ELSE 0- END,- includes = CASE- WHEN relations.relation_type = 'includes'- THEN 1- ELSE 0- END,- requires = CASE- WHEN relations.relation_type = 'requires'- THEN 1- ELSE 0- END- SQL- end-- def insert_hierarchy_relation_for_parent- ActiveRecord::Base.connection.execute <<-SQL- INSERT INTO relations- (from_id, to_id, hierarchy)- SELECT w1.id, w2.id, 1- FROM work_packages w1- JOIN work_packages w2- ON w1.id = w2.parent_id- SQL- end-- def set_parent_id- ActiveRecord::Base.connection.execute <<-SQL- UPDATE- work_packages- SET- parent_id =- (SELECT from_id- FROM relations- WHERE to_id = work_packages.id- AND relations.hierarchy = 1- AND relations.relates = 0- AND relations.duplicates = 0- AND relations.blocks = 0- AND relations.follows = 0- AND relations.includes = 0- AND relations.requires = 0)- SQL- end-- def fill_relation_type_column- add_column :relations, :relation_type, :string-- ActiveRecord::Base.connection.execute <<-SQL- UPDATE- relations- SET- relation_type = CASE- WHEN relations.relates = 1- THEN 'relates'- WHEN relations.duplicates = 1- THEN 'duplicates'- WHEN relations.duplicates = 1- THEN 'blocks'- WHEN relations.follows = 1- THEN 'precedes'- WHEN relations.includes = 1- THEN 'includes'- WHEN relations.requires = 1- THEN 'requires'- END- SQL- end-- def remove_relation_type_specific_columns- relation_types.each do |column|- remove_column :relations, column- end- end-- def rebuild_nested_set- NestedSetWorkPackage.rebuild_silently!- end-- class NestedSetWorkPackage < ActiveRecord::Base- self.table_name = "work_packages"-- acts_as_nested_set scope: "root_id", dependent: :destroy-- include OpenProject::NestedSet::RebuildPatch- end-enddiff --git a/db/migrate/20171106074835_move_hashed_token_to_core.rb b/db/migrate/20171106074835_move_hashed_token_to_core.rbdeleted file mode 100644index 4ab651afea5..00000000000--- a/db/migrate/20171106074835_move_hashed_token_to_core.rb+++ /dev/null@@ -1,76 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class MoveHashedTokenToCore < ActiveRecord::Migration[5.1]- class OldToken < ApplicationRecord- self.table_name = :plaintext_tokens- end-- def up- rename_table :tokens, :plaintext_tokens- create_tokens_table- migrate_existing_tokens- end-- def down- drop_table :tokens- rename_table :plaintext_tokens, :tokens- end-- private-- def create_tokens_table- create_table :tokens, id: :integer do |t|- t.references :user, index: true- t.string :type- t.string :value, default: "", null: false, limit: 128- t.datetime :created_on, null: false- t.datetime :expires_on, null: true- end- end-- def migrate_existing_tokens- # API tokens- ::Token::API.transaction do- OldToken.where(action: "api").find_each do |token|- result = ::Token::API.create(user_id: token.user_id, value: ::Token::API.hash_function(token.value))- warn "Failed to migrate API token for ##{user.id}" unless result- end- end-- # RSS tokens- ::Token::RSS.transaction do- OldToken.where(action: "feeds").find_each do |token|- result = ::Token::RSS.create(user_id: token.user_id, value: token.value)- warn "Failed to migrate RSS token for ##{user.id}" unless result- end- end-- # We do not migrate the rest, they are short-lived anyway.- end-enddiff --git a/db/migrate/20171129145631_add_fulltext_to_attachments.rb b/db/migrate/20171129145631_add_fulltext_to_attachments.rbdeleted file mode 100644index 6b117a867a0..00000000000--- a/db/migrate/20171129145631_add_fulltext_to_attachments.rb+++ /dev/null@@ -1,34 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddFulltextToAttachments < ActiveRecord::Migration[5.0]- def change- # room for at least 1 million characters / approx. 80 pages of english text- add_column :attachments, :fulltext, :text, limit: 4.megabytes- end-enddiff --git a/db/migrate/20180105130053_rebuild_dag.rb b/db/migrate/20180105130053_rebuild_dag.rbdeleted file mode 100644index c106cca520c..00000000000--- a/db/migrate/20180105130053_rebuild_dag.rb+++ /dev/null@@ -1,171 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++-require_relative "migration_utils/utils"-require_relative "migration_utils/typed_dag"--class RebuildDag < ActiveRecord::Migration[5.0]- include ::Migration::Utils-- def up- Migration::MigrationUtils::TypedDag.configure-- truncate_closure_entries- remove_duplicate_relations-- if index_exists?(:relations, relation_types)- remove_index :relations, relation_types- end-- add_column :relations, :count, :integer, default: 0, null: false-- set_count_to_1-- add_index :relations,- %i(from_id to_id hierarchy relates duplicates blocks follows includes requires),- name: "index_relations_on_type_columns",- unique: true-- say_with_time "Building the directed acyclic graph of all relations. This might take a while." do- Migration::MigrationUtils::TypedDag::WorkPackage.rebuild_dag! 1000- end-- add_count_index-- add_scheduling_indices-- add_non_hierarchy_index- end-- def down- if column_exists? :relations, :count- remove_column :relations, :count- end-- remove_index_if_exists :relations, "index_relations_hierarchy_follows_scheduling"- remove_index_if_exists :relations, "index_relations_only_hierarchy"- remove_index_if_exists :relations, "index_relations_to_from_only_follows"- remove_index_if_exists :relations, "index_relations_direct_non_hierarchy"- remove_index_if_exists :relations, "index_relations_on_type_columns"-- truncate_closure_entries- end-- private-- def add_count_index- # supports finding relations that are to be deleted- add_index :relations, :count, where: "count = 0"- end-- def add_scheduling_indices- # supports relying on fast "Index Only Scan" for finding work packages that need to be rescheduled after a work package- # has been moved- add_index :relations,- %i(to_id hierarchy follows from_id),- name: "index_relations_hierarchy_follows_scheduling",- where: <<-SQL- relations.relates = 0- AND relations.duplicates = 0- AND relations.blocks = 0- AND relations.includes = 0- AND relations.requires = 0- AND (hierarchy + relates + duplicates + follows + blocks + includes + requires > 0)- SQL-- add_index :relations,- %i(from_id to_id hierarchy),- name: "index_relations_only_hierarchy",- where: <<-SQL- relations.relates = 0- AND relations.duplicates = 0- AND relations.follows = 0- AND relations.blocks = 0- AND relations.includes = 0- AND relations.requires = 0- SQL-- add_index :relations,- %i(to_id follows from_id),- name: "index_relations_to_from_only_follows",- where: <<-SQL- hierarchy = 0- AND relates = 0- AND duplicates = 0- AND blocks = 0- AND includes = 0- AND requires = 0- SQL- end-- def add_non_hierarchy_index- # supports finding relations via the api as only non hierarchy relations are returned- add_index :relations,- :from_id,- name: "index_relations_direct_non_hierarchy",- where: "(hierarchy + relates + duplicates + follows + blocks + includes + requires = 1) AND relations.hierarchy = 0"- end-- def set_count_to_1- ActiveRecord::Base.connection.execute <<-SQL- UPDATE- relations- SET- count = 1- SQL- end-- def truncate_closure_entries- ActiveRecord::Base.connection.execute <<-SQL- DELETE FROM relations- WHERE (#{relation_types.join(' + ')} > 1)- OR (#{relation_types.join(' + ')} = 0)- SQL- end-- def remove_duplicate_relations- equal_conditions = relation_types.map do |type|- "r1.#{type} = r2.#{type}"- end.join(" AND ")-- ActiveRecord::Base.connection.execute <<-SQL- DELETE- FROM relations- WHERE id IN (SELECT id FROM (SELECT r1.id- FROM relations r1- JOIN relations r2- ON r1.id > r2.id- AND r1.from_id = r2.from_id- AND r1.to_id = r2.to_id- AND #{equal_conditions}) delete_ids)- SQL- end-- def relation_types- %i(hierarchy relates duplicates blocks follows includes requires)- end-enddiff --git a/db/migrate/20180108132929_vacuum_relations.rb b/db/migrate/20180108132929_vacuum_relations.rbdeleted file mode 100644index 8ed6ebd3407..00000000000--- a/db/migrate/20180108132929_vacuum_relations.rb+++ /dev/null@@ -1,37 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class VacuumRelations < ActiveRecord::Migration[5.0]- disable_ddl_transaction!-- def up- if ActiveRecord::Base.connection.adapter_name == "PostgreSQL"- connection.execute "vacuum relations"- end- end-enddiff --git a/db/migrate/20180116065518_add_hierarchy_paths.rb b/db/migrate/20180116065518_add_hierarchy_paths.rbdeleted file mode 100644index 34e809fc104..00000000000--- a/db/migrate/20180116065518_add_hierarchy_paths.rb+++ /dev/null@@ -1,39 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddHierarchyPaths < ActiveRecord::Migration[5.1]- def change- create_table :hierarchy_paths, id: :integer do |t|- t.belongs_to :work_package, index: { unique: true }- # (255 * 3) = ca 767 bytes is the max length for an index in mysql 5.6 InnoDB- t.string :path, null: false, limit: 255-- t.index :path- end- end-enddiff --git a/db/migrate/20180117065255_remove_timelines_and_reportings.rb b/db/migrate/20180117065255_remove_timelines_and_reportings.rbdeleted file mode 100644index e77290c12e5..00000000000--- a/db/migrate/20180117065255_remove_timelines_and_reportings.rb+++ /dev/null@@ -1,88 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RemoveTimelinesAndReportings < ActiveRecord::Migration[5.0]- def up- drop_table :timelines- drop_table :reportings- drop_table :available_project_statuses-- delete_reported_project_statuses-- remove_column :project_types, :allows_association- end-- def down- create_reportings- create_timelines- create_available_project_statuses-- add_column :project_types, :allows_association, :boolean, default: true, null: false- end-- private-- def create_reportings- create_table(:reportings, id: :integer) do |t|- t.column :reported_project_status_comment, :text-- t.belongs_to :project- t.belongs_to :reporting_to_project- t.belongs_to :reported_project_status-- t.timestamps- end- end-- def create_timelines- create_table :timelines, id: :integer do |t|- t.column :name, :string, null: false- t.column :options, :text-- t.belongs_to :project-- t.timestamps- end- end-- def create_available_project_statuses- create_table(:available_project_statuses, id: :integer) do |t|- t.belongs_to :project_type- t.belongs_to :reported_project_status, index: { name: "index_avail_project_statuses_on_rep_project_status_id" }-- t.timestamps- end- end-- def delete_reported_project_statuses- delete <<-SQL- DELETE FROM enumerations- WHERE type = 'ReportedProjectStatus'- SQL- end-enddiff --git a/db/migrate/20180122135443_add_tsv_columns_to_attachments.rb b/db/migrate/20180122135443_add_tsv_columns_to_attachments.rbdeleted file mode 100644index 5928c150254..00000000000--- a/db/migrate/20180122135443_add_tsv_columns_to_attachments.rb+++ /dev/null@@ -1,59 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddTsvColumnsToAttachments < ActiveRecord::Migration[5.0]- def up- if OpenProject::Database.allows_tsv?- add_column :attachments, :fulltext_tsv, :tsvector- add_column :attachments, :file_tsv, :tsvector-- add_index :attachments, :fulltext_tsv, using: "gin"- add_index :attachments, :file_tsv, using: "gin"- else- warn "Your installation does not support full-text search features. Better use PostgreSQL in version 9.5 or higher."- end- end-- def down- if column_exists? :attachments, :fulltext_tsv- remove_column :attachments, :fulltext_tsv, :tsvector- end-- if column_exists? :attachments, :file_tsv- remove_column :attachments, :file_tsv, :tsvector- end-- if index_exists? :attachments, :fulltext_tsv- remove_index :attachments, :fulltext_tsv- end-- if index_exists? :attachments, :file_tsv- remove_index :attachments, :file_tsv- end- end-enddiff --git a/db/migrate/20180123092002_add_custom_actions.rb b/db/migrate/20180123092002_add_custom_actions.rbdeleted file mode 100644index 714890ae1f3..00000000000--- a/db/migrate/20180123092002_add_custom_actions.rb+++ /dev/null@@ -1,56 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddCustomActions < ActiveRecord::Migration[5.1]- def change- create_table :custom_actions, id: :integer do |t|- t.string :name- t.text :actions- end-- create_table :custom_actions_statuses, id: :integer do |t|- t.belongs_to :status- t.belongs_to :custom_action- end-- create_table :custom_actions_roles, id: :integer do |t|- t.belongs_to :role- t.belongs_to :custom_action- end-- create_table :custom_actions_types, id: :integer do |t|- t.belongs_to :type- t.belongs_to :custom_action- end-- create_table :custom_actions_projects, id: :integer do |t|- t.belongs_to :project- t.belongs_to :custom_action- end- end-enddiff --git a/db/migrate/20180213155320_add_description_to_custom_actions.rb b/db/migrate/20180213155320_add_description_to_custom_actions.rbdeleted file mode 100644index 22b18b39767..00000000000--- a/db/migrate/20180213155320_add_description_to_custom_actions.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddDescriptionToCustomActions < ActiveRecord::Migration[5.0]- def change- add_column :custom_actions, :description, :text- end-enddiff --git a/db/migrate/20180221151038_add_position_to_custom_action.rb b/db/migrate/20180221151038_add_position_to_custom_action.rbdeleted file mode 100644index ec650c88173..00000000000--- a/db/migrate/20180221151038_add_position_to_custom_action.rb+++ /dev/null@@ -1,41 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddPositionToCustomAction < ActiveRecord::Migration[5.0]- def change- add_column :custom_actions, :position, :integer-- reversible do |dir|- dir.up do- CustomAction.order_by_name.each_with_index do |a, i|- a.update_attribute(:position, i)- end- end- end- end-enddiff --git a/db/migrate/20180305130811_remove_wiki_content_versions.rb b/db/migrate/20180305130811_remove_wiki_content_versions.rbdeleted file mode 100644index c6cf8c2cd45..00000000000--- a/db/migrate/20180305130811_remove_wiki_content_versions.rb+++ /dev/null@@ -1,49 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RemoveWikiContentVersions < ActiveRecord::Migration[5.1]- def up- drop_table :wiki_content_versions- end-- def down- create_table :wiki_content_versions, force: true do |t|- t.integer :wiki_content_id, null: false- t.integer :page_id, null: false- t.integer :author_id- t.binary :data, limit: 16.megabytes- t.string :compression, limit: 6, default: ""- t.string :comments, default: ""- t.datetime :updated_on, null: false- t.integer :version, null: false- end-- add_index :wiki_content_versions, [:updated_on], name: "index_wiki_content_versions_on_updated_on"- add_index :wiki_content_versions, [:wiki_content_id], name: "wiki_content_versions_wcid"- end-enddiff --git a/db/migrate/20180504144320_add_color_to_statuses_and_enumerations.rb b/db/migrate/20180504144320_add_color_to_statuses_and_enumerations.rbdeleted file mode 100644index b145361e773..00000000000--- a/db/migrate/20180504144320_add_color_to_statuses_and_enumerations.rb+++ /dev/null@@ -1,39 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddColorToStatusesAndEnumerations < ActiveRecord::Migration[5.1]- def change- change_table :statuses do |t|- t.belongs_to :color, type: :int- end-- change_table :enumerations do |t|- t.belongs_to :color, type: :int- end- end-enddiff --git a/db/migrate/20180510184732_rename_planning_elemnt_type_colors_to_colors.rb b/db/migrate/20180510184732_rename_planning_elemnt_type_colors_to_colors.rbdeleted file mode 100644index 19cb14fcd15..00000000000--- a/db/migrate/20180510184732_rename_planning_elemnt_type_colors_to_colors.rb+++ /dev/null@@ -1,48 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RenamePlanningElemntTypeColorsToColors < ActiveRecord::Migration[5.1]- def up- # Fix existing indexes due to old migration away from timeline_colors- # This hasn't happened automatically in Rails < 4 with the 2013 migration of timelines_colors- if index_name_exists?(:planning_element_type_colors, :timelines_colors_pkey)- rename_index :planning_element_type_colors, :timelines_colors_pkey, :planning_element_type_colors_pkey- end-- rename_table :planning_element_type_colors, :colors- remove_column :colors, :position- end-- def down- rename_table :colors, :planning_element_type_colors-- change_table :planning_element_type_colors do- t.integer :position, default: 1, null: true- end- end-enddiff --git a/db/migrate/20180518130559_add_timestamps_to_wiki.rb b/db/migrate/20180518130559_add_timestamps_to_wiki.rbdeleted file mode 100644index 17550f78ad8..00000000000--- a/db/migrate/20180518130559_add_timestamps_to_wiki.rb+++ /dev/null@@ -1,38 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddTimestampsToWiki < ActiveRecord::Migration[5.1]- def change- add_timestamps :wikis, default: DateTime.now- change_column_default :wikis, :created_at, nil- change_column_default :wikis, :updated_at, nil-- add_column :wiki_pages, :updated_at, :datetime, default: DateTime.now, null: false- change_column_default :wiki_pages, :updated_at, nil- end-enddiff --git a/db/migrate/20180524084654_remove_non_null_container_on_attachments.rb b/db/migrate/20180524084654_remove_non_null_container_on_attachments.rbdeleted file mode 100644index bccbfb1c936..00000000000--- a/db/migrate/20180524084654_remove_non_null_container_on_attachments.rb+++ /dev/null@@ -1,54 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RemoveNonNullContainerOnAttachments < ActiveRecord::Migration[5.1]- def change- change_column_null :attachments, :container_id, true- change_column_null :attachments, :container_type, true-- change_column_default :attachments, :container_id, from: 0, to: nil- change_column_default :attachments, :container_type, from: "", to: nil-- change_column_null :attachment_journals, :container_id, true- change_column_null :attachment_journals, :container_type, true-- change_column_default :attachment_journals, :container_id, from: 0, to: nil- change_column_default :attachment_journals, :container_type, from: "", to: nil-- add_column :attachments, :updated_at, :datetime- rename_column :attachments, :created_on, :created_at-- reversible do |change|- change.up do- execute <<~SQL.squish- Update attachments SET updated_at = created_at- SQL- end- end- end-enddiff --git a/db/migrate/20180524113516_add_consent_timestamp_to_user.rb b/db/migrate/20180524113516_add_consent_timestamp_to_user.rbdeleted file mode 100644index 6a2cefde9ae..00000000000--- a/db/migrate/20180524113516_add_consent_timestamp_to_user.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddConsentTimestampToUser < ActiveRecord::Migration[5.0]- def change- add_column :users, :consented_at, :datetime- end-enddiff --git a/db/migrate/20180706150714_convert_to_markdown.rb b/db/migrate/20180706150714_convert_to_markdown.rbdeleted file mode 100644index 62d675ea472..00000000000--- a/db/migrate/20180706150714_convert_to_markdown.rb+++ /dev/null@@ -1,61 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class ConvertToMarkdown < ActiveRecord::Migration[5.1]- def up- setting = Setting.where(name: "text_formatting").pluck(:value)- return unless setting && setting[0] == "textile"-- if ENV["OPENPROJECT_SKIP_TEXTILE_MIGRATION"].present?- warn <<~WARNING- Your instance is configured with Textile text formatting, this means you have likely been running OpenProject before 8.0.0-- Since you have requested skip the textile migration, your data will NOT be converted. You can do this in a subsequent step:-- $> bundle exec rails runner "OpenProject::TextFormatting::Formats::Markdown::TextileConverter.new.run!"-- or in a packaged installation:-- $> openproject run bundle exec rails runner "OpenProject::TextFormatting::Formats::Markdown::TextileConverter.new.run!"-- For more information, please visit this page: https://www.openproject.org/textile-to-markdown-migration-- WARNING- return- end-- if setting && setting[0] == "textile"- raise <<~ERROR- You appear to be upgrading from an old version of OpenProject using textile text formatters.-- OpenProject version 13.0 no longer provides the migration from Textile to Markdown.- First upgrade to any 12.x version, before performing the upgrade to 13.0- ERROR- end- end-enddiff --git a/db/migrate/20180717102331_remove_in_aggregation_from_type.rb b/db/migrate/20180717102331_remove_in_aggregation_from_type.rbdeleted file mode 100644index d00f718e455..00000000000--- a/db/migrate/20180717102331_remove_in_aggregation_from_type.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RemoveInAggregationFromType < ActiveRecord::Migration[5.1]- def change- remove_column :types, :in_aggregation, :boolean, default: true, null: false- end-enddiff --git a/db/migrate/20180801072018_remove_responsible_and_type_from_project.rb b/db/migrate/20180801072018_remove_responsible_and_type_from_project.rbdeleted file mode 100644index a70530da007..00000000000--- a/db/migrate/20180801072018_remove_responsible_and_type_from_project.rb+++ /dev/null@@ -1,48 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RemoveResponsibleAndTypeFromProject < ActiveRecord::Migration[5.1]- def up- remove_belongs_to :projects, :responsible- remove_belongs_to :projects, :work_packages_responsible- remove_belongs_to :projects, :project_type-- drop_table :project_types- end-- def down- # Recreate project type- Tables::ProjectTypes.create self-- change_table :projects do |t|- t.belongs_to :responsible, type: :int- t.belongs_to :work_packages_responsible, type: :int- t.belongs_to :project_type, type: :int- end- end-enddiff --git a/db/migrate/20180830120550_migrate_light_background_themes.rb b/db/migrate/20180830120550_migrate_light_background_themes.rbdeleted file mode 100644index 0f166498c4d..00000000000--- a/db/migrate/20180830120550_migrate_light_background_themes.rb+++ /dev/null@@ -1,95 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class MigrateLightBackgroundThemes < ActiveRecord::Migration[5.1]- NEW_COLOR_VARIABLES = %w( main-menu-font-color- main-menu-bg-selected-background- main-menu-selected-font-color- main-menu-bg-hover-background- main-menu-hover-font-color- main-menu-border-color ).freeze- def down- # This migration is not revertible.- end-- def up- # This migration is "nice to have". There is no harm if it does not get applied.- return unless apply?-- # Main menu was set to white- if DesignColor.find_by(variable: "main-menu-bg-color")&.hexcode == "#FFFFFF"- set_old_default_menu_colors- end-- # Header is white and main menu was default light grey- if DesignColor.find_by(variable: "header-bg-color")&.hexcode == "#FFFFFF" &&- DesignColor.find_by(variable: "main-menu-bg-color").nil?- set_variable("main-menu-bg-color", "#F8F8F8")- set_old_default_menu_colors- end- end-- def set_old_default_menu_colors- content_link_color = DesignColor.find_by(variable: "content-link-color")&.hexcode ||- DesignColor.find_by(variable: "primary-color-dark")&.hexcode ||- "#175A8E"-- set_variable("main-menu-font-color", "#333333")- set_variable("main-menu-bg-selected-background", "#E9E9E9")- set_variable("main-menu-selected-font-color", content_link_color)- set_variable("main-menu-bg-hover-background", "#F0F0F0")- set_variable("main-menu-hover-font-color", "#333333")- set_variable("main-menu-border-color", "#E7E7E7")- end-- def set_variable(variable_name, hexcode)- DesignColor.create(variable: variable_name, hexcode:)- end-- def apply?- # Future safety: Check that all necessary variables are still in use.- %w( content-link-color- header-bg-color- header-border-bottom-color- main-menu-bg-color- main-menu-font-color- main-menu-bg-selected-background- main-menu-selected-font-color- main-menu-bg-hover-background- main-menu-hover-font-color- main-menu-border-color ).each do |variable_name|- return false unless OpenProject::CustomStyles::Design.customizable_variables.include? variable_name- end-- # Never ever overwrite variables that were already set.- # The existence of one variable is sufficient to better abort this migration.- false if DesignColor.where(variable: NEW_COLOR_VARIABLES).any?-- true- end-enddiff --git a/db/migrate/20180924141838_add_highlighted_attributes_to_query.rb b/db/migrate/20180924141838_add_highlighted_attributes_to_query.rbdeleted file mode 100644index 27cc1f08cbe..00000000000--- a/db/migrate/20180924141838_add_highlighted_attributes_to_query.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddHighlightedAttributesToQuery < ActiveRecord::Migration[5.1]- def change- add_column :queries, :highlighted_attributes, :text- end-enddiff --git a/db/migrate/20181101132712_add_read_only_to_statuses.rb b/db/migrate/20181101132712_add_read_only_to_statuses.rbdeleted file mode 100644index 693e6179ee9..00000000000--- a/db/migrate/20181101132712_add_read_only_to_statuses.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddReadOnlyToStatuses < ActiveRecord::Migration[5.1]- def change- add_column :statuses, :is_readonly, :boolean, default: false- end-enddiff --git a/db/migrate/20181121174153_create_ordered_work_packages.rb b/db/migrate/20181121174153_create_ordered_work_packages.rbdeleted file mode 100644index 834136513ec..00000000000--- a/db/migrate/20181121174153_create_ordered_work_packages.rb+++ /dev/null@@ -1,38 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class CreateOrderedWorkPackages < ActiveRecord::Migration[5.1]- def change- create_table :ordered_work_packages do |t|- t.integer :position, index: true, null: false-- t.references :query, type: :integer, foreign_key: { index: true, on_delete: :cascade }- t.references :work_package, type: :integer, foreign_key: { index: true, on_delete: :cascade }- end- end-enddiff --git a/db/migrate/20190124081710_remove_accessibility_mode.rb b/db/migrate/20190124081710_remove_accessibility_mode.rbdeleted file mode 100644index 2e03204e560..00000000000--- a/db/migrate/20190124081710_remove_accessibility_mode.rb+++ /dev/null@@ -1,43 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RemoveAccessibilityMode < ActiveRecord::Migration[5.2]- def change- remove_column :user_preferences, :impaired- delete_accessibility_mode_from_settings- end-- private-- def delete_accessibility_mode_from_settings- delete <<-SQL.squish- DELETE FROM settings- WHERE name = 'accessibility_mode_for_anonymous'- SQL- end-enddiff --git a/db/migrate/20190129083842_add_project_to_grid.rb b/db/migrate/20190129083842_add_project_to_grid.rbdeleted file mode 100644index 6ccba94b4a1..00000000000--- a/db/migrate/20190129083842_add_project_to_grid.rb+++ /dev/null@@ -1,35 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddProjectToGrid < ActiveRecord::Migration[5.2]- def change- change_table :grids do |t|- t.references :project- end- end-enddiff --git a/db/migrate/20190205090102_add_options_to_grid.rb b/db/migrate/20190205090102_add_options_to_grid.rbdeleted file mode 100644index 4cda8985316..00000000000--- a/db/migrate/20190205090102_add_options_to_grid.rb+++ /dev/null@@ -1,36 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddOptionsToGrid < ActiveRecord::Migration[5.2]- def change- change_table :grids do |t|- t.text :name- t.text :options- end- end-enddiff --git a/db/migrate/20190207155607_add_hidden_to_queries.rb b/db/migrate/20190207155607_add_hidden_to_queries.rbdeleted file mode 100644index c66c87baf6b..00000000000--- a/db/migrate/20190207155607_add_hidden_to_queries.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddHiddenToQueries < ActiveRecord::Migration[5.2]- def change- add_column :queries, :hidden, :boolean, default: false- end-enddiff --git a/db/migrate/20190220080647_migrate_my_page_layout.rb b/db/migrate/20190220080647_migrate_my_page_layout.rbdeleted file mode 100644index 4b7e7fee612..00000000000--- a/db/migrate/20190220080647_migrate_my_page_layout.rb+++ /dev/null@@ -1,156 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class MigrateMyPageLayout < ActiveRecord::Migration[5.2]- def up- UserPreference.transaction do- # Remove all my page grids- ::Grids::MyPage.destroy_all-- user_my_page_prefs.find_each do |pref|- old_layout = pref.others.with_indifferent_access[:my_page_layout]- next unless old_layout-- new_page = migrate_my_page(pref.user_id, old_layout)- raise "Save failed due to #{new_page.errors.full_messages.join('. ')}" unless new_page.save-- remove_old_my_page pref- rescue StandardError => e- warn "Failed to migrate my_page for user##{pref.user_id}: #{e.message}"- end- end- end-- def down- # This migration is not revertible.- end-- private-- ##- # Migrate a single preference entry and remove the my page- def migrate_my_page(user_id, old_layout)- my_page = ::Grids::MyPage.new user_id:, column_count: 4-- # Migrate top- start_row = 1- # Give every widget a fixed height of 4 rows- widget_height = 4- (old_layout["top"] || []).each do |block|- map_widget my_page,- old_name: block,- start_row:,- end_row: start_row + widget_height,- start_column: 1,- end_column: 5-- start_row += widget_height- end-- # Migrate left- left_row = start_row- (old_layout["left"] || []).each do |block|- map_widget my_page,- old_name: block,- start_row: left_row,- end_row: left_row + widget_height,- start_column: 1,- end_column: 3-- left_row += widget_height- end-- # Migrate right- right_row = start_row- (old_layout["right"] || []).each do |block|- map_widget my_page,- old_name: block,- start_row: right_row,- end_row: right_row + widget_height,- start_column: 3,- end_column: 5-- right_row += widget_height- end-- my_page.row_count = [left_row, right_row].max - 1- my_page- end-- ##- # Remove the current my page setting- def remove_old_my_page(pref)- # There are some cases where keys where not symbolized- pref.others.delete(:my_page_layout)- pref.others.delete("my_page_layout")- pref.save- end-- ##- # Get all preferences with my page set that do not have- # a grid- def user_my_page_prefs- pref_table = UserPreference.table_name-- ::UserPreference.where("#{pref_table}.others LIKE '%my_page_layout%'")- end-- ##- # Mapping of old widget names to new widgets- def map_widget(my_page, old_name:, start_row:, end_row:, start_column:, end_column:)- mapping = widget_mapping[old_name.to_sym]-- if mapping.nil?- warn "Skipping unknown block #{old_name}"- return- end-- my_page.widgets << Grids::Widget.new(- identifier: mapping,- start_row:,- end_row:,- start_column:,- end_column:- )- end-- ##- # Widget mapping- def widget_mapping- @widget_mapping ||= {- issuesassignedtome: :work_packages_assigned,- workpackagesresponsiblefor: :work_packages_accountable,- issuesreportedbyme: :work_packages_created,- issueswatched: :work_packages_watched,- news: :news,- calendar: :work_packages_calendar,- timelog: :time_entries_current_user,- documents: :documents- }- end-enddiff --git a/db/migrate/20190227163226_add_tls_mode_to_auth_sources.rb b/db/migrate/20190227163226_add_tls_mode_to_auth_sources.rbdeleted file mode 100644index 4baf5c9fb96..00000000000--- a/db/migrate/20190227163226_add_tls_mode_to_auth_sources.rb+++ /dev/null@@ -1,51 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddTlsModeToAuthSources < ActiveRecord::Migration[5.2]- class MigratingAuthSource < ApplicationRecord- self.table_name = "auth_sources"- end-- def change- add_column :auth_sources, :tls_mode, :integer, default: 0, null: false- MigratingAuthSource.reset_column_information-- reversible do |dir|- dir.up do- MigratingAuthSource.where(tls: true).update_all(tls_mode: 1)- end-- dir.down do- MigratingAuthSource.where(tls_mode: 0).update_all(tls: false)- MigratingAuthSource.where(tls_mode: 1).update_all(tls: true)- end- end-- remove_column :auth_sources, :tls, :boolean, default: false, null: false- end-enddiff --git a/db/migrate/20190301122554_remove_hierarchy_paths.rb b/db/migrate/20190301122554_remove_hierarchy_paths.rbdeleted file mode 100644index 0ff00477f41..00000000000--- a/db/migrate/20190301122554_remove_hierarchy_paths.rb+++ /dev/null@@ -1,69 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require_relative "20180116065518_add_hierarchy_paths"--class RemoveHierarchyPaths < ActiveRecord::Migration[5.2]- def up- AddHierarchyPaths.new.migrate :down-- # Set sort to id, asc where parent sort was used- Query- .where("sort_criteria LIKE '%parent%'")- .find_each do |query|- # Use update_column to ensure that value is saved regardless- # of the overall state of the query- query.update_column(:sort_criteria, query.sort_criteria.map { |criteria| map_parent_to_id(criteria) })- rescue StandardError => e- warn "Failed to migrate parent sort_criteria for query #{query.id}: #{e}"- end- end-- def down- # Will fail to #rebuild_hierarchy_paths! unless restored to correct version- AddHierarchyPaths.new.migrate :up-- # Set sort to parent, asc where query.show_hierarchies is set- # because that is what is implied by the frontend.- Query- .where(show_hierarchies: true)- .update_all(sort_criteria: [%w(parent asc)])- end-- private-- ##- # Map parent sort_criteria to id asc.- def map_parent_to_id(criteria)- if criteria.first.to_s == "parent"- %w[id asc]- else- criteria- end- end-enddiff --git a/db/migrate/20190312083304_rename_boards_to_forums.rb b/db/migrate/20190312083304_rename_boards_to_forums.rbdeleted file mode 100644index a59107c3bc9..00000000000--- a/db/migrate/20190312083304_rename_boards_to_forums.rb+++ /dev/null@@ -1,61 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require_relative "tables/forums"--class RenameBoardsToForums < ActiveRecord::Migration[5.2]- def up- # Create the new table, then copy from the oldt table to ensure indexes are correct- ::Tables::Forums.create(self)-- execute "INSERT INTO forums SELECT * FROM boards"-- rename_column :messages, :board_id, :forum_id- rename_column :message_journals, :board_id, :forum_id-- # Rename string references in DB to forums- EnabledModule.where(name: "boards").update_all(name: "forums")- RolePermission.where(permission: "manage_boards").update_all(permission: "manage_forums")- Watcher.where(watchable_type: "Board").update_all(watchable_type: "Forum")-- # Finally, drop the old table- drop_table :boards- end-- def down- rename_table :forums, :boards-- rename_column :messages, :forum_id, :board_id- rename_column :message_journals, :forum_id, :board_id-- # Rename back items- EnabledModule.where(name: "forums").update_all(name: "boards")- RolePermission.where(permission: "manage_forums").update_all(permission: "manage_boards")- Watcher.where(watchable_type: "Forum").update_all(watchable_type: "Board")- end-enddiff --git a/db/migrate/20190411122815_set_timeline_auto_zoom.rb b/db/migrate/20190411122815_set_timeline_auto_zoom.rbdeleted file mode 100644index cccfb9fe40f..00000000000--- a/db/migrate/20190411122815_set_timeline_auto_zoom.rb+++ /dev/null@@ -1,39 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class SetTimelineAutoZoom < ActiveRecord::Migration[5.2]- def up- Query.where(timeline_zoom_level: :days).update_all(timeline_zoom_level: :auto)- change_column_default :queries, :timeline_zoom_level, 5- end-- def down- Query.where(timeline_zoom_level: :auto).update_all(timeline_zoom_level: :days)- change_column_default :queries, :timeline_zoom_level, 0- end-enddiff --git a/db/migrate/20190502102512_ensure_postgres_index_names.rb b/db/migrate/20190502102512_ensure_postgres_index_names.rbdeleted file mode 100644index 40a7ca9914f..00000000000--- a/db/migrate/20190502102512_ensure_postgres_index_names.rb+++ /dev/null@@ -1,59 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class EnsurePostgresIndexNames < ActiveRecord::Migration[5.2]- disable_ddl_transaction!-- def up- sql = <<~SQL.squish- SELECT- FORMAT('%s_pkey', table_name) as new_name,- constraint_name as old_name- FROM information_schema.table_constraints- WHERE UPPER(constraint_type) = 'PRIMARY KEY'- AND constraint_schema IN (select current_schema())- AND constraint_name != FORMAT('%s_pkey', table_name)- ORDER BY table_name;- SQL-- ActiveRecord::Base.connection.execute(sql).each do |entry|- old_name = entry["old_name"]- new_name = entry["new_name"]-- ActiveRecord::Base.transaction do- execute %(ALTER INDEX "#{old_name}" RENAME TO #{new_name};)- rescue StandardError => e- warn "Failed to rename index #{old_name} to #{new_name}: #{e.message}. Skipping"- end- end- end-- def down- # Nothing to do- end-enddiff --git a/db/migrate/20190507132517_add_board_view_to_roles.rb b/db/migrate/20190507132517_add_board_view_to_roles.rbdeleted file mode 100644index e2c656a5787..00000000000--- a/db/migrate/20190507132517_add_board_view_to_roles.rb+++ /dev/null@@ -1,45 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require "#{Rails.root.join('db/migrate/migration_utils/permission_adder')}"--class AddBoardViewToRoles < ActiveRecord::Migration[5.2]- def up- ::Migration::MigrationUtils::PermissionAdder- .add(:view_work_packages,- :show_board_views)-- if Setting.default_projects_modules_writable? && Setting.default_projects_modules&.exclude?("board_view")- Setting.default_projects_modules = Setting.default_projects_modules + ["board_view"]- end- end-- def down- # Nothing to do- end-enddiff --git a/db/migrate/20190509071101_add_default_description_to_types.rb b/db/migrate/20190509071101_add_default_description_to_types.rbdeleted file mode 100644index 8438f236bec..00000000000--- a/db/migrate/20190509071101_add_default_description_to_types.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddDefaultDescriptionToTypes < ActiveRecord::Migration[5.2]- def change- add_column :types, :description, :text- end-enddiff --git a/db/migrate/20190527095959_set_manage_board_permission.rb b/db/migrate/20190527095959_set_manage_board_permission.rbdeleted file mode 100644index d04477ba5e2..00000000000--- a/db/migrate/20190527095959_set_manage_board_permission.rb+++ /dev/null@@ -1,41 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require "#{Rails.root.join('db/migrate/migration_utils/permission_adder')}"--class SetManageBoardPermission < ActiveRecord::Migration[5.2]- def up- ::Migration::MigrationUtils::PermissionAdder- .add(:manage_public_queries,- :manage_board_views)- end-- def down- # Nothing to do- end-enddiff --git a/db/migrate/20190603060951_set_assign_versions_permission.rb b/db/migrate/20190603060951_set_assign_versions_permission.rbdeleted file mode 100644index 8b36ff6889d..00000000000--- a/db/migrate/20190603060951_set_assign_versions_permission.rb+++ /dev/null@@ -1,41 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require "#{Rails.root.join('db/migrate/migration_utils/permission_adder')}"--class SetAssignVersionsPermission < ActiveRecord::Migration[5.2]- def up- ::Migration::MigrationUtils::PermissionAdder- .add(:edit_work_packages,- :assign_versions)- end-- def down- # nothing to do- end-enddiff --git a/db/migrate/20190618115620_fix_available_languages.rb b/db/migrate/20190618115620_fix_available_languages.rbdeleted file mode 100644index 6bf00dd82d2..00000000000--- a/db/migrate/20190618115620_fix_available_languages.rb+++ /dev/null@@ -1,61 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class FixAvailableLanguages < ActiveRecord::Migration[5.2]- def up- if Setting.where(name: "available_languages").exists? # rubocop:disable Rails/WhereExists- Setting.reset_column_information-- Setting.available_languages = Setting.available_languages.map do |lang|- if lang == "zh"- "zh-CN"- else- lang- end- end- end-- User.where(language: "zh").update_all(language: "zh-CN")- end-- def down- if Setting.where(name: "available_languages").exists? # rubocop:disable Rails/WhereExists- Setting.reset_column_information-- Setting.available_languages = Setting.available_languages.map do |lang|- if lang == "zh-CN"- "zh"- else- lang- end- end- end-- User.where(language: "zh-CN").update_all(language: "zh")- end-enddiff --git a/db/migrate/20190619143049_add_timestamps_to_query.rb b/db/migrate/20190619143049_add_timestamps_to_query.rbdeleted file mode 100644index 8a41355a356..00000000000--- a/db/migrate/20190619143049_add_timestamps_to_query.rb+++ /dev/null@@ -1,36 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddTimestampsToQuery < ActiveRecord::Migration[5.2]- def change- add_column :queries, :created_at, :datetime- add_column :queries, :updated_at, :datetime-- add_index(:queries, :updated_at)- end-enddiff --git a/db/migrate/20190710132957_rename_my_page_widgets.rb b/db/migrate/20190710132957_rename_my_page_widgets.rbdeleted file mode 100644index 084377f736e..00000000000--- a/db/migrate/20190710132957_rename_my_page_widgets.rb+++ /dev/null@@ -1,106 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RenameMyPageWidgets < ActiveRecord::Migration[5.2]- def up- reset_column_information-- Grids::MyPage.eager_load(:widgets, user: :preference).each do |page|- I18n.with_locale(page.user&.language.presence || "en") do- page.widgets.each(&method(:update_widget))- end- rescue I18n::InvalidLocale => e- Rails.logger.warn "Failed to use user locale from #{page.user.inspect}: #{e} #{e.message}. Correcting"- page.widgets.each(&method(:update_widget))- page.user&.update_column(:language, "en")- end- end-- private-- def update_widget(widget)- case widget.identifier- when "work_packages_assigned"- update_table_widget(widget, "assignee")- when "work_packages_accountable"- update_table_widget(widget, "responsible")- when "work_packages_created"- update_table_widget(widget, "author")- when "work_packages_watched"- update_table_widget(widget, "watcher")- when "work_packages_calendar", "news", "documents", "time_entries_current_user"- update_widget_name(widget)- when "work_packages_table"- update_query_widget(widget)- end- end-- def update_table_widget(widget, filter_name)- widget.options = {- name: I18n.t("js.grid.widgets.#{widget.identifier}.title"),- queryProps: {- "columns[]": %w(id project type subject),- filters: JSON.dump([{ status: { operator: "o", values: [] } },- { filter_name => { operator: "=", values: ["me"] } }])- }- }- widget.identifier = "work_packages_table"-- widget.save(validate: false)- end-- def update_widget_name(widget)- widget.options = {- name: I18n.t("js.grid.widgets.#{widget.identifier}.title")- }-- widget.save(validate: false)- end-- def update_query_widget(widget)- query_id = widget.options["queryId"]-- name = Query.where(id: query_id).limit(1).pick(:name) || I18n.t("js.grid.widgets.work_packages_table.title")-- widget.options = {- name:,- queryId: query_id- }-- widget.save(validate: false)- end-- def reset_column_information- # Without this, AR tries to join e.g. verified phone which might not exist yet- User.reset_column_information- end-- def down- Grids::MyPage.destroy_all- end-enddiff --git a/db/migrate/20190716071941_add_display_representation_to_query.rb b/db/migrate/20190716071941_add_display_representation_to_query.rbdeleted file mode 100644index 74e489eafcb..00000000000--- a/db/migrate/20190716071941_add_display_representation_to_query.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddDisplayRepresentationToQuery < ActiveRecord::Migration[5.2]- def change- add_column :queries, :display_representation, :text- end-enddiff --git a/db/migrate/20190722082648_add_derived_estimated_hours_to_work_packages.rb b/db/migrate/20190722082648_add_derived_estimated_hours_to_work_packages.rbdeleted file mode 100644index 4bdc8b09e03..00000000000--- a/db/migrate/20190722082648_add_derived_estimated_hours_to_work_packages.rb+++ /dev/null@@ -1,226 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddDerivedEstimatedHoursToWorkPackages < ActiveRecord::Migration[5.2]- class WorkPackageWithRelations < ApplicationRecord- self.table_name = "work_packages"-- scope :with_children, ->(*_args) do- rel = "relations"- wp = "work_packages"-- query = "EXISTS (SELECT 1 FROM #{rel} WHERE #{rel}.from_id = #{wp}.id AND #{rel}.hierarchy > 0 LIMIT 1)"-- where(query)- end- end-- def change- add_column :work_packages, :derived_estimated_hours, :float- add_column :work_package_journals, :derived_estimated_hours, :float-- reversible do |change|- change.up do- WorkPackage.transaction do- migrate_to_derived_estimated_hours!- end- end-- change.down do- WorkPackage.transaction do- rollback_from_derived_estimated_hours!- end- end- end- end-- # Before this migration all work packages who have children had their- # estimated hours set based on their children through the UpdateAncestorsService.- #- # We move this value to the derived_estimated_hours column and clear- # the estimated_hours column. In the future users can estimate the time- # for parent work packages separately while the UpdateAncestorsService- # only touches the derived_estimated_hours column.- def migrate_to_derived_estimated_hours!- last_id = Journal.order(id: :desc).limit(1).pick(:id) || 0-- work_packages = WorkPackageWithRelations.with_children.where("estimated_hours > ?", 0)- work_packages.update_all("derived_estimated_hours = estimated_hours, estimated_hours = NULL")- work_packages = WorkPackageWithRelations.with_children.where("derived_estimated_hours > ?", 0)-- create_journals_for work_packages- create_work_package_journals(last_id:)- create_customizable_journals(last_id:)- create_attachable_journals(last_id:)-- touch_work_packages work_packages # to invalidate cache- end-- def rollback_from_derived_estimated_hours!- last_id = Journal.order(id: :desc).limit(1).pick(:id) || 0-- work_packages = WorkPackageWithRelations.with_children.where("derived_estimated_hours > ?", 0)- work_packages.update_all("estimated_hours = derived_estimated_hours, derived_estimated_hours = NULL")- work_packages = WorkPackageWithRelations.with_children.where("estimated_hours > ?", 0)-- create_journals_for work_packages, notes: rollback_notes- create_work_package_journals(last_id:)- create_customizable_journals(last_id:)- create_attachable_journals(last_id:)-- touch_work_packages work_packages # to invalidate cache- end-- ##- # Creates a new journal for each work package with the next version.- # The respective work_package journal is created in a separate step.- def create_journals_for(work_packages, author: journal_author, notes: journal_notes)- WorkPackage.connection.execute("- INSERT INTO #{Journal.table_name} (journable_type, journable_id, user_id, notes, created_at, version, activity_type)- SELECT- 'WorkPackage',- parents.id,- #{author.id},- #{WorkPackage.connection.quote(notes)},- NOW(),- (SELECT MAX(version) FROM journals WHERE journable_id = parents.id AND journable_type = 'WorkPackage') + 1,- 'work_packages'- FROM (- #{work_packages.select(:id).to_sql}- ) AS parents- ")- end-- def journal_author- @journal_author ||= User.system- end-- def journal_notes- "_'Estimated hours' changed to 'Derived estimated hours'_"- end-- def rollback_notes- "_'Derived estimated hours' rolled back to 'Estimated hours'_"- end-- ##- # Creates work package journals for the move of estimated_hours to derived_estimated_hours.- #- # For each newly created journal (see above) it inserts the respective work package's- # current estimated_hours (deleted) and derived estimated hours (previously estimated hours).- # All other attributes of the work package journal entry are copied from the previous- # work package journal entry (i.e. the values are not changed).- #- # @param last_id [Integer] The ID of the last journal before the journals for the migration were created.- def create_work_package_journals(last_id:)- journals = "journals"- wp_journals = "work_package_journals"- work_packages = "work_packages"-- WorkPackage.connection.execute("- INSERT INTO #{wp_journals} (- journal_id, type_id, project_id, subject, description, due_date, category_id, status_id,- assigned_to_id, priority_id, fixed_version_id, author_id, done_ratio,- start_date, parent_id, responsible_id, cost_object_id, story_points, remaining_hours,- estimated_hours, derived_estimated_hours- )- SELECT *- FROM (- SELECT- #{journals}.id, #{wp_journals}.type_id, #{wp_journals}.project_id, #{wp_journals}.subject,- #{wp_journals}.description, #{wp_journals}.due_date, #{wp_journals}.category_id, #{wp_journals}.status_id,- #{wp_journals}.assigned_to_id, #{wp_journals}.priority_id, #{wp_journals}.fixed_version_id, #{wp_journals}.author_id,- #{wp_journals}.done_ratio, #{wp_journals}.start_date, #{wp_journals}.parent_id, #{wp_journals}.responsible_id,- #{wp_journals}.cost_object_id, #{wp_journals}.story_points, #{wp_journals}.remaining_hours,- #{work_packages}.estimated_hours, #{work_packages}.derived_estimated_hours- FROM #{journals} -- take the journal ID from here (ID of newly created journals from above)- LEFT JOIN #{work_packages} -- take the current (derived) estimated hours from here- ON #{work_packages}.id = #{journals}.journable_id AND #{journals}.journable_type = 'WorkPackage'- LEFT JOIN #{wp_journals} -- keep everything else the same- ON #{wp_journals}.journal_id = (- SELECT MAX(id)- FROM #{journals}- WHERE journable_id = #{work_packages}.id AND journable_type = 'WorkPackage' AND #{journals}.id <= #{last_id}- -- we are selecting the latest previous (hence <= last_id) work package journal here to copy its values- )- WHERE #{journals}.id > #{last_id} -- make sure to only create entries for the newly created journals- ) AS results- ")- end-- def create_customizable_journals(last_id:)- journals = "journals"- customizable = "customizable_journals"- work_packages = "work_packages"-- WorkPackage.connection.execute("- INSERT INTO #{customizable} (journal_id, custom_field_id, value)- SELECT #{journals}.id, #{customizable}.custom_field_id, #{customizable}.value- FROM #{journals} -- take the journal ID from here (ID of newly created journals from above)- LEFT JOIN #{work_packages}- ON #{work_packages}.id = #{journals}.journable_id AND #{journals}.journable_type = 'WorkPackage'- RIGHT JOIN #{customizable} -- keep everything else the same; there can be multiple customizable journals (custom fields)- ON #{customizable}.journal_id = (- SELECT MAX(id)- FROM #{journals}- WHERE #{journals}.journable_id = #{work_packages}.id AND journable_type = 'WorkPackage' AND #{journals}.id <= #{last_id}- -- we are selecting the latest previous (hence <= last_id) customizable journal here to copy its values- )- WHERE #{journals}.id > #{last_id} -- make sure to only create entries for the newly created journals- ")- end-- def create_attachable_journals(last_id:)- journals = "journals"- attachable = "attachable_journals"- work_packages = "work_packages"-- WorkPackage.connection.execute("- INSERT INTO #{attachable} (journal_id, attachment_id, filename)- SELECT #{journals}.id, #{attachable}.attachment_id, #{attachable}.filename- FROM #{journals} -- take the journal ID from here (ID of newly created journals from above)- LEFT JOIN #{work_packages}- ON #{work_packages}.id = #{journals}.journable_id AND #{journals}.journable_type = 'WorkPackage'- RIGHT JOIN #{attachable} -- keep everything else the same; there can be multiple attachable journals (attachments)- ON #{attachable}.journal_id = (- SELECT MAX(id)- FROM #{journals}- WHERE #{journals}.journable_id = #{work_packages}.id AND journable_type = 'WorkPackage' AND #{journals}.id <= #{last_id}- -- we are selecting the latest previous (hence <= last_id) customizable journal here to copy its values- )- WHERE #{journals}.id > #{last_id} -- make sure to only create entries for the newly created journals- ")- end-- def touch_work_packages(work_packages)- WorkPackage.connection.execute("- UPDATE work_packages SET updated_at = NOW(), lock_version = lock_version + 1- WHERE id IN (#{work_packages.select(:id).to_sql})- ")- end-enddiff --git a/db/migrate/20190724093332_add_journal_versions_table.rb b/db/migrate/20190724093332_add_journal_versions_table.rbdeleted file mode 100644index ab31cd55e1e..00000000000--- a/db/migrate/20190724093332_add_journal_versions_table.rb+++ /dev/null@@ -1,56 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require_relative "migration_utils/utils"--class AddJournalVersionsTable < ActiveRecord::Migration[5.2]- include ::Migration::Utils-- def up- create_table :journal_versions do |t|- t.string :journable_type- t.integer :journable_id- t.integer :version, default: 0- t.index %i[journable_type journable_id version],- name: "unique_journal_version",- unique: true- end-- ActiveRecord::Base.connection.execute <<-SQL.squish- INSERT INTO journal_versions (journable_type, journable_id, version)- (SELECT- journable_type, journable_id, MAX(version)- FROM journals- GROUP BY journable_type, journable_id);- SQL- end-- def down- drop_table :journal_versions- end-enddiff --git a/db/migrate/20190920102446_clean_custom_values.rb b/db/migrate/20190920102446_clean_custom_values.rbdeleted file mode 100644index c70572e8f0e..00000000000--- a/db/migrate/20190920102446_clean_custom_values.rb+++ /dev/null@@ -1,51 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class CleanCustomValues < ActiveRecord::Migration[5.2]- def up- invalid_cv = CustomValue- .joins(:custom_field)- .where("#{CustomField.table_name}.field_format = 'list'")- .where.not(value: "")- .where("value !~ '^[0-9]+$'")-- if invalid_cv.count > 0- warn_string = "Replacing invalid list custom values:\n"- invalid_cv.pluck(:customized_type, :customized_id, :value).each do |customized_type, customized_id, value|- warn_string << "- #{customized_type} ##{customized_id}: Value was #{value.inspect}\n"- end-- warn warn_string- invalid_cv.update_all(value: "")- end- end-- def down- # This migration does not restore data- end-enddiff --git a/db/migrate/20190923111902_add_project_status_reporting.rb b/db/migrate/20190923111902_add_project_status_reporting.rbdeleted file mode 100644index 481b4bb518d..00000000000--- a/db/migrate/20190923111902_add_project_status_reporting.rb+++ /dev/null@@ -1,38 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddProjectStatusReporting < ActiveRecord::Migration[6.0]- def change- create_table :project_statuses do |table|- table.references :project, null: false, foreign_key: true, index: { unique: true }- table.text :explanation- table.integer :code- table.timestamps- end- end-enddiff --git a/db/migrate/20190923123858_simplify_project_active_and_timestamp.rb b/db/migrate/20190923123858_simplify_project_active_and_timestamp.rbdeleted file mode 100644index a6c94e331e3..00000000000--- a/db/migrate/20190923123858_simplify_project_active_and_timestamp.rb+++ /dev/null@@ -1,77 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class SimplifyProjectActiveAndTimestamp < ActiveRecord::Migration[6.0]- STATUS_ACTIVE = 1- STATUS_ARCHIVED = 9-- class Project < ApplicationRecord; end-- def change- change_project_columns-- reversible do |change|- change.up do- fill_active_column- end- change.down do- recreate_status_column_and_information- end- end- end-- private-- def change_project_columns- change_table :projects do |table|- table.rename :created_on, :created_at- table.rename :updated_on, :updated_at- table.rename :is_public, :public- end- end-- def fill_active_column- add_column :projects, :active, :boolean, default: true, null: false- add_index :projects, :active-- Project.reset_column_information- Project.where(status: STATUS_ARCHIVED).update_all(active: false)-- remove_column :projects, :status- end-- def recreate_status_column_and_information- add_column :projects, :status, :integer, default: STATUS_ACTIVE, null: false-- Project.reset_column_information- Project.where(active: true).update_all(status: STATUS_ACTIVE)- Project.where(active: false).update_all(status: STATUS_ARCHIVED)-- remove_column :projects, :active- end-enddiff --git a/db/migrate/20191106132533_make_system_user_active.rb b/db/migrate/20191106132533_make_system_user_active.rbdeleted file mode 100644index 801d1177eaa..00000000000--- a/db/migrate/20191106132533_make_system_user_active.rb+++ /dev/null@@ -1,42 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class MakeSystemUserActive < ActiveRecord::Migration[6.0]- # Remember the integer mapped to previous builtin status- BUILTIN_STATUS = 0-- def up- Principal.where(status: BUILTIN_STATUS).update_all(status: Principal.statuses[:active])- end-- def down- AnonymousUser.update_all(status: BUILTIN_STATUS)- DeletedUser.update_all(status: BUILTIN_STATUS)- SystemUser.update_all(status: Principal.statuses[:locked])- end-enddiff --git a/db/migrate/20191112111040_fix_system_user_status.rb b/db/migrate/20191112111040_fix_system_user_status.rbdeleted file mode 100644index d761b074720..00000000000--- a/db/migrate/20191112111040_fix_system_user_status.rb+++ /dev/null@@ -1,73 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class FixSystemUserStatus < ActiveRecord::Migration[6.0]- def up- # The previous migration was supposed to make the system user active,- # but doesn't since it only touches built-in (0) users while the system user- # used to be locked (3). An oversight on our part.- #- # We also update the anonymous user again. While it was correctly updated- # in the previous migration, newly created anonymous users since have the- # wrong status (0) because we failed to update the on-the-fly- # creation of the anonymous user with the correct status.- active_users.each do |user|- user.update_all status: Principal.statuses[:active]- end-- deleted_user.update_all status: Principal.statuses[:active]- end-- def down- # reset system user to locked which would've been the state before this migration- system_user.update_all status: Principal.statuses[:locked]-- # reset deleted usr to active which he would've been after the previous migration- deleted_user.update_all status: Principal.statuses[:active]-- # There is no need to update the anonymous user since it was supposed to be- # active at this point already anyway. The previous migration then makes it- # built-in (0) again if we rollback even further.- end-- def active_users- [system_user, anonymous_user]- end-- def system_user- SystemUser- end-- def anonymous_user- AnonymousUser- end-- def deleted_user- DeletedUser- end-enddiff --git a/db/migrate/20191115141154_add_content_orientation_to_custom_fields.rb b/db/migrate/20191115141154_add_content_orientation_to_custom_fields.rbdeleted file mode 100644index e74346167ef..00000000000--- a/db/migrate/20191115141154_add_content_orientation_to_custom_fields.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddContentOrientationToCustomFields < ActiveRecord::Migration[6.0]- def change- add_column :custom_fields, :content_right_to_left, :boolean, default: false- end-enddiff --git a/db/migrate/20191216135213_join_table_for_active_activities.rb b/db/migrate/20191216135213_join_table_for_active_activities.rbdeleted file mode 100644index 40495c10f0b..00000000000--- a/db/migrate/20191216135213_join_table_for_active_activities.rb+++ /dev/null@@ -1,144 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class JoinTableForActiveActivities < ActiveRecord::Migration[6.0]- class ActivitiesJoinTable < ApplicationRecord- self.table_name = :time_entry_activities_projects- end-- class TimeEntryActivity < ApplicationRecord- self.table_name = :enumerations- end-- def up- create_join_table- delete_invalid_project_activities- link_time_entries_to_root_activities- fill_new_join_table- delete_inherited_activities- end-- def down- create_project_specific_activities- link_time_entries_to_project_activities-- drop_table :time_entry_activities_projects- end-- def create_join_table- create_table :time_entry_activities_projects do |t|- t.references :activity, null: false, foreign_key: { to_table: :enumerations }, index: true- t.references :project, null: false, foreign_key: true, index: true- t.boolean :active, default: true, index: true- end- add_index :time_entry_activities_projects,- %i[project_id activity_id],- unique: true,- name: "index_teap_on_project_id_and_activity_id"- end-- # Delete all references from enumerations to projects which point to no longer- # existing projects.- def delete_invalid_project_activities- ActiveRecord::Base.connection.exec_query(- <<-SQL.squish- DELETE FROM enumerations- USING enumerations AS enums- LEFT OUTER JOIN projects on enums.project_id = projects.id- WHERE enums.id = enumerations.id AND enums.type = 'TimeEntryActivity' AND projects.id IS NULL AND enums.project_id IS NOT NULL- SQL- )- end-- def link_time_entries_to_root_activities- ActiveRecord::Base.connection.exec_query(- <<-SQL.squish- UPDATE- time_entries te_sink- SET- activity_id = enumerations.parent_id- FROM- time_entries te_source- INNER JOIN enumerations ON te_source.activity_id = enumerations.id AND enumerations.parent_id IS NOT NULL AND enumerations.type = 'TimeEntryActivity'- WHERE- te_sink.id = te_source.id- SQL- )- end-- def link_time_entries_to_project_activities- ActiveRecord::Base.connection.exec_query(- <<-SQL.squish- UPDATE- time_entries te_sink- SET- activity_id = COALESCE(child.id, root.id)- FROM- time_entries te_source- INNER JOIN enumerations root ON te_source.activity_id = root.id AND root.type = 'TimeEntryActivity'- LEFT OUTER JOIN enumerations child ON child.parent_id = root.id- WHERE- te_source.id = te_sink.id- SQL- )- end-- def fill_new_join_table- values = TimeEntryActivity- .where- .not(parent_id: nil)- .pluck(:project_id, :parent_id, :active)- .map { |project_id, parent_id, active| { project_id:, activity_id: parent_id, active: } }-- ActivitiesJoinTable.insert_all(values) if values.present?- end-- def delete_inherited_activities- TimeEntryActivity.where.not(parent_id: nil).delete_all- end-- def create_project_specific_activities- ActiveRecord::Base.connection.exec_query(- <<-SQL.squish- INSERT INTO enumerations (name, is_default, type, position, parent_id, project_id, active, created_at, updated_at)- SELECT- tea.name,- false,- tea.type,- tea.position,- teap.activity_id,- teap.project_id,- teap.active,- NOW(),- NOW()- FROM time_entry_activities_projects teap- JOIN enumerations tea ON tea.id = teap.activity_id AND tea.type = 'TimeEntryActivity'- SQL- )- end-enddiff --git a/db/migrate/20200114091135_add_theme_name_to_custom_styles.rb b/db/migrate/20200114091135_add_theme_name_to_custom_styles.rbdeleted file mode 100644index e1894c1740d..00000000000--- a/db/migrate/20200114091135_add_theme_name_to_custom_styles.rb+++ /dev/null@@ -1,36 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddThemeNameToCustomStyles < ActiveRecord::Migration[6.0]- def change- add_column :custom_styles,- :theme,- :string,- default: OpenProject::CustomStyles::ColorThemes::DEFAULT_THEME_NAME- end-enddiff --git a/db/migrate/20200115090742_fix_parent_id_for_wiki_pages.rb b/db/migrate/20200115090742_fix_parent_id_for_wiki_pages.rbdeleted file mode 100644index 14d09afba2e..00000000000--- a/db/migrate/20200115090742_fix_parent_id_for_wiki_pages.rb+++ /dev/null@@ -1,37 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class FixParentIdForWikiPages < ActiveRecord::Migration[6.0]- class MyWikiPages < ApplicationRecord- self.table_name = "wiki_pages"- end-- def up- MyWikiPages.where(parent_id: 0).update_all(parent_id: nil)- end-enddiff --git a/db/migrate/20200206101135_add_theme_logo_to_custom_style.rb b/db/migrate/20200206101135_add_theme_logo_to_custom_style.rbdeleted file mode 100644index 4d5046b87e7..00000000000--- a/db/migrate/20200206101135_add_theme_logo_to_custom_style.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddThemeLogoToCustomStyle < ActiveRecord::Migration[6.0]- def change- add_column :custom_styles, :theme_logo, :string, default: nil- end-enddiff --git a/db/migrate/20200217061622_add_timestamp_to_news.rb b/db/migrate/20200217061622_add_timestamp_to_news.rbdeleted file mode 100644index b3ddc5ff194..00000000000--- a/db/migrate/20200217061622_add_timestamp_to_news.rb+++ /dev/null@@ -1,38 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddTimestampToNews < ActiveRecord::Migration[6.0]- def change- add_column :news, :updated_at, :datetime- rename_column :news, :created_on, :created_at-- reversible do |change|- change.up { News.update_all("updated_at = created_at") }- end- end-enddiff --git a/db/migrate/20200217155632_rename_tokens.rb b/db/migrate/20200217155632_rename_tokens.rbdeleted file mode 100644index ec27b286592..00000000000--- a/db/migrate/20200217155632_rename_tokens.rb+++ /dev/null@@ -1,42 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RenameTokens < ActiveRecord::Migration[6.0]- class Token < ApplicationRecord- end-- def up- Token.where(type: "Token::Rss").update_all(type: "Token::RSS")- Token.where(type: "Token::Api").update_all(type: "Token::API")- end-- def down- Token.where(type: "Token::RSS").update_all(type: "Token::Rss")- Token.where(type: "Token::API").update_all(type: "Token::Api")- end-enddiff --git a/db/migrate/20200220171133_rename_bim_module.rb b/db/migrate/20200220171133_rename_bim_module.rbdeleted file mode 100644index edb36ed6ea5..00000000000--- a/db/migrate/20200220171133_rename_bim_module.rb+++ /dev/null@@ -1,59 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RenameBimModule < ActiveRecord::Migration[6.0]- # Note: rails 7.1 breaks the class' ancestor chain, when a class with an enum definition- # without a database field is being referenced.- # Re-defining the Project class without the enum to avoid the issue.- class Project < ApplicationRecord; end-- def up- projects_with_bcf = EnabledModule.where(name: "bcf").pluck(:project_id)- # Delete all bcf to avoid duplicates- EnabledModule.where(name: "bcf").delete_all- EnabledModule.where(name: "ifc_models").update_all(name: "bim")-- # Re-enable bim if ifc_models was not active but bcf was- Project.where(id: projects_with_bcf).includes(:enabled_modules).each do |project|- project.enabled_modules.create(name: "bim") unless project.enabled_module_names.include?("bim")- end-- # Rename attachments container- execute "UPDATE attachments SET container_type = 'Bim::Bcf::Viewpoint' WHERE container_type = 'Bcf::Viewpoint'"- execute "UPDATE attachments SET container_type = 'Bim::IfcModels::IfcModel' WHERE container_type = 'IFCModels::IFCModel'"- end-- def down- # We cannot now which module was active, so enable BCF- EnabledModule.where(name: "bim").update_all(name: "bcf")-- # Rename attachments container- execute "UPDATE attachments SET container_type = 'Bcf::Viewpoint' WHERE container_type = 'Bim::Bcf::Viewpoint'"- execute "UPDATE attachments SET container_type = 'IfcModels::IfcModel' WHERE container_type = 'Bim::IFCModels::IFCModel'"- end-enddiff --git a/db/migrate/20200302100431_fix_attachable_journals.rb b/db/migrate/20200302100431_fix_attachable_journals.rbdeleted file mode 100644index ae71bcae69b..00000000000--- a/db/migrate/20200302100431_fix_attachable_journals.rb+++ /dev/null@@ -1,77 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class FixAttachableJournals < ActiveRecord::Migration[6.0]- # Adds attachable_journals to all journals where the- # attachment was created before the journal as long as there- # is no attachable_journal associated to the journal yet.- #- # This does not fix journals where the attachment has been deleted in the meantime as- # we no longer have the necessary information to recreate the journals.- def up- statement = <<~SQL.squish- WITH- existing_attachments AS (- SELECT- id,- created_at,- file,- container_id,- container_type,- author_id- FROM attachments),- existing_attachable_journals AS (- SELECT- journals.id journal_id,- attachable_journals.attachment_id- FROM journals- LEFT OUTER JOIN attachable_journals ON journals.id = attachable_journals.journal_id- LEFT OUTER JOIN attachments ON attachable_journals.attachment_id = attachments.id)-- INSERT INTO attachable_journals (journal_id, attachment_id, filename)- SELECT- journals.id journal_id,- existing_attachments.id attachment_id,- existing_attachments.file filename- FROM journals- JOIN existing_attachments- ON journals.created_at >= existing_attachments.created_at- AND journals.user_id = existing_attachments.author_id- AND journals.journable_id = existing_attachments.container_id- AND journals.journable_type = existing_attachments.container_type- LEFT OUTER JOIN existing_attachable_journals- ON existing_attachments.id = existing_attachable_journals.attachment_id- AND journals.id = existing_attachable_journals.journal_id- WHERE attachment_id IS NULL- SQL-- ActiveRecord::Base.connection.execute statement- end-- # Does not require a down statement as a bug is fixed.-enddiff --git a/db/migrate/20200310092237_add_timestamps_to_bcf.rb b/db/migrate/20200310092237_add_timestamps_to_bcf.rbdeleted file mode 100644index 4b87d81caa2..00000000000--- a/db/migrate/20200310092237_add_timestamps_to_bcf.rb+++ /dev/null@@ -1,34 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddTimestampsToBcf < ActiveRecord::Migration[6.0]- def change- add_timestamps :bcf_issues, default: DateTime.now- add_timestamps :bcf_viewpoints, default: DateTime.now- end-enddiff --git a/db/migrate/20200325101528_strip_whitespace_from_user_attributes.rb b/db/migrate/20200325101528_strip_whitespace_from_user_attributes.rbdeleted file mode 100644index 34a5704fae2..00000000000--- a/db/migrate/20200325101528_strip_whitespace_from_user_attributes.rb+++ /dev/null@@ -1,40 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class StripWhitespaceFromUserAttributes < ActiveRecord::Migration[6.0]- def up- User.update_all("login = TRIM(login), mail = TRIM(mail)")- end-- def down- warn <<~WARNING- We cannot restore leading and trailing white space in user login and mail attributes.- Please ensure you do not have logins with only leading or trailing white space differences.- WARNING- end-enddiff --git a/db/migrate/20200326102408_rename_fixed_version.rb b/db/migrate/20200326102408_rename_fixed_version.rbdeleted file mode 100644index e376fdd58ae..00000000000--- a/db/migrate/20200326102408_rename_fixed_version.rb+++ /dev/null@@ -1,65 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RenameFixedVersion < ActiveRecord::Migration[6.0]- def up- rename_column :work_packages, :fixed_version_id, :version_id- rename_column :work_package_journals, :fixed_version_id, :version_id-- rename_query_attributes("fixed_version", "version")- end-- def down- rename_column :work_packages, :version_id, :fixed_version_id- rename_column :work_package_journals, :version_id, :fixed_version_id-- rename_query_attributes("version", "fixed_version")- end-- def rename_query_attributes(from, to)- ActiveRecord::Base.connection.exec_query(- <<-SQL.squish- UPDATE- queries q_sink- SET- filters = regexp_replace(q_source.filters, '(\n)#{from}_id:(\n)', '\\1#{to}_id:\\2'),- column_names = regexp_replace(q_source.column_names, ':#{from}', ':#{to}'),- sort_criteria = regexp_replace(q_source.sort_criteria, '#{from}', '#{to}'),- group_by = regexp_replace(q_source.group_by, '#{from}', '#{to}')- FROM- queries q_source- WHERE- (q_source.filters LIKE '%#{from}_id:%'- OR q_source.column_names LIKE '%#{from}%'- OR q_source.sort_criteria LIKE '%#{from}%'- OR q_source.group_by = '#{from}')- AND q_sink.id = q_source.id- SQL- )- end-enddiff --git a/db/migrate/20200403105252_add_cron_to_delayed_jobs.rb b/db/migrate/20200403105252_add_cron_to_delayed_jobs.rbdeleted file mode 100644index 8ad4afed36a..00000000000--- a/db/migrate/20200403105252_add_cron_to_delayed_jobs.rb+++ /dev/null@@ -1,37 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddCronToDelayedJobs < ActiveRecord::Migration[6.0]- def self.up- add_column :delayed_jobs, :cron, :string- end-- def self.down- remove_column :delayed_jobs, :cron- end-enddiff --git a/db/migrate/20200415131633_add_work_package_exports.rb b/db/migrate/20200415131633_add_work_package_exports.rbdeleted file mode 100644index 79634a3210c..00000000000--- a/db/migrate/20200415131633_add_work_package_exports.rb+++ /dev/null@@ -1,37 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddWorkPackageExports < ActiveRecord::Migration[6.0]- def change- create_table :work_package_exports do |t|- t.references :user-- t.timestamps- end- end-enddiff --git a/db/migrate/20200427121606_add_filter_to_ldap.rb b/db/migrate/20200427121606_add_filter_to_ldap.rbdeleted file mode 100644index 23e93c4a039..00000000000--- a/db/migrate/20200427121606_add_filter_to_ldap.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddFilterToLdap < ActiveRecord::Migration[6.0]- def change- add_column :auth_sources, :filter_string, :text, null: true- end-enddiff --git a/db/migrate/20200428105404_unique_member_role.rb b/db/migrate/20200428105404_unique_member_role.rbdeleted file mode 100644index cd71775028d..00000000000--- a/db/migrate/20200428105404_unique_member_role.rb+++ /dev/null@@ -1,37 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class UniqueMemberRole < ActiveRecord::Migration[6.0]- def change- change_table :member_roles do |t|- t.index %i[member_id role_id inherited_from],- name: "unique_inherited_role",- unique: true- end- end-enddiff --git a/db/migrate/20200504085933_add_schedule_manually_to_work_packages.rb b/db/migrate/20200504085933_add_schedule_manually_to_work_packages.rbdeleted file mode 100644index 0d4459dee57..00000000000--- a/db/migrate/20200504085933_add_schedule_manually_to_work_packages.rb+++ /dev/null@@ -1,37 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddScheduleManuallyToWorkPackages < ActiveRecord::Migration[6.0]- def change- add_column :work_packages, :schedule_manually, :boolean, default: false-- # We add a partial index here because 90% of the values will be false.- # So we only index the true values. This way the index is actually useful.- add_index :work_packages, :schedule_manually, where: :schedule_manually- end-enddiff --git a/db/migrate/20200522131255_splash_multi_list_customizable_journals.rb b/db/migrate/20200522131255_splash_multi_list_customizable_journals.rbdeleted file mode 100644index 028f4e06ba1..00000000000--- a/db/migrate/20200522131255_splash_multi_list_customizable_journals.rb+++ /dev/null@@ -1,127 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class SplashMultiListCustomizableJournals < ActiveRecord::Migration[6.0]- def up- # First get all customizable_journals entries that belong to a multi list custom field and that have more than one- # value (a comma separated list). Return the values, splashed using unnest(string_to_array(...)). E.g. `1,2,3` will- # be returned as three rows with the value_part `1`, `2` and `3` respectively.- # Those are then inserted into the journals table.- # Lastly, the entries with the unsplashed values are deleted.- execute <<~SQL.squish- WITH existing_journals AS (- SELECT *- FROM (- SELECT customizable_journals.* FROM customizable_journals- JOIN custom_fields- ON custom_fields.id = customizable_journals.custom_field_id AND field_format = 'list' AND multi_value = true- ) customizable_journals- , unnest(string_to_array(customizable_journals.value, ',')) value_part- WHERE customizable_journals.value LIKE '%,%'- ),- splash_journals AS (- INSERT INTO- customizable_journals (- journal_id,- custom_field_id,- value- )- SELECT- journal_id,- custom_field_id,- value_part- FROM existing_journals- RETURNING *- ),- delete_journals AS (- DELETE- FROM- customizable_journals- WHERE id IN (SELECT id from existing_journals)- )-- SELECT * FROM splash_journals;- SQL- end-- # Group all customizable_journals by journal_id and custom_field_id and return those, for which- # two or more are returned. That way, we get all the once we need to aggregate again. We aggregate- # to a comma separated list within the same query.- # That query then serves to return all data that we need to insert into the customizable_journals again.- # Lastly, all customizable_journals entries that where not just created and that belong to a group of more than one- # value per journal and custom field are deleted.- def down- execute <<~SQL.squish- WITH aggregated_value AS (- SELECT- journal_id,- custom_field_id,- string_agg(value, ',') AS value- FROM- customizable_journals- GROUP BY- journal_id,- custom_field_id- HAVING COUNT(value) > 1- ),- insert_aggregated AS (- INSERT INTO- customizable_journals (- journal_id,- custom_field_id,- value- )- SELECT- journal_id,- custom_field_id,- value- FROM- aggregated_value- RETURNING *- )--- DELETE FROM- customizable_journals- WHERE- id IN (- SELECT- id- FROM- customizable_journals- JOIN aggregated_value- ON- customizable_journals.custom_field_id = aggregated_value.custom_field_id- AND customizable_journals.journal_id = aggregated_value.journal_id- )- AND id NOT IN (- SELECT id FROM insert_aggregated- )- SQL- end-enddiff --git a/db/migrate/20200522140244_remove_journal_versions_table.rb b/db/migrate/20200522140244_remove_journal_versions_table.rbdeleted file mode 100644index eeb8f487a7a..00000000000--- a/db/migrate/20200522140244_remove_journal_versions_table.rb+++ /dev/null@@ -1,39 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require_relative "20190724093332_add_journal_versions_table"--class RemoveJournalVersionsTable < ActiveRecord::Migration[6.0]- def up- ::AddJournalVersionsTable.down- end-- def down- ::AddJournalVersionsTable.up- end-enddiff --git a/db/migrate/20200527130633_add_templated_to_project.rb b/db/migrate/20200527130633_add_templated_to_project.rbdeleted file mode 100644index 871925ea70e..00000000000--- a/db/migrate/20200527130633_add_templated_to_project.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddTemplatedToProject < ActiveRecord::Migration[6.0]- def change- add_column :projects, :templated, :boolean, default: false, null: false- end-enddiff --git a/db/migrate/20200625133727_fix_inherited_group_member_roles.rb b/db/migrate/20200625133727_fix_inherited_group_member_roles.rbdeleted file mode 100644index 590ca4ead31..00000000000--- a/db/migrate/20200625133727_fix_inherited_group_member_roles.rb+++ /dev/null@@ -1,50 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class FixInheritedGroupMemberRoles < ActiveRecord::Migration[6.0]- def up- # Delete all member roles that should be inherited by groups- MemberRole.where.not(inherited_from: nil).delete_all-- # For all group memberships, recreate the member_roles for all users- # which will auto-create members for the users if necessary- Member- .includes(%i[principal])- .where(users: { type: "Group" })- .find_each do |member|- # Recreate member_roles for all group members- Groups::UpdateRolesService- .new(member.principal, current_user: SystemUser.first, contract_class: EmptyContract)- .call(member:, send_notifications: false)- end- end-- def down- # Nothing to do- end-enddiff --git a/db/migrate/20200708065116_fix_members_inconsistencies.rb b/db/migrate/20200708065116_fix_members_inconsistencies.rbdeleted file mode 100644index f284215d8a0..00000000000--- a/db/migrate/20200708065116_fix_members_inconsistencies.rb+++ /dev/null@@ -1,39 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class FixMembersInconsistencies < ActiveRecord::Migration[6.0]- def change- change_column_default :members, :created_on, -> { "CURRENT_TIMESTAMP" }-- # Update all members without created_on which got created by CTE- Member.where(created_on: nil).update_all(created_on: Time.zone.now)-- # Delete members without member_roles- Member.includes(:member_roles).where(member_roles: { id: nil }).destroy_all- end-enddiff --git a/db/migrate/20200803081038_journalize_scheduling_mode.rb b/db/migrate/20200803081038_journalize_scheduling_mode.rbdeleted file mode 100644index 996ce875a20..00000000000--- a/db/migrate/20200803081038_journalize_scheduling_mode.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class JournalizeSchedulingMode < ActiveRecord::Migration[6.0]- def change- add_column :work_package_journals, :schedule_manually, :boolean, default: false- end-enddiff --git a/db/migrate/20200820140526_remove_summable_setting.rb b/db/migrate/20200820140526_remove_summable_setting.rbdeleted file mode 100644index c449e9be789..00000000000--- a/db/migrate/20200820140526_remove_summable_setting.rb+++ /dev/null@@ -1,36 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RemoveSummableSetting < ActiveRecord::Migration[6.0]- # Do not need a down migration as we simply fall back on the default settings- def up- execute <<~SQL.squish- DELETE FROM settings WHERE name = 'work_package_list_summable_columns'- SQL- end-enddiff --git a/db/migrate/20200903064009_enable_current_project_custom_fields_columns.rb b/db/migrate/20200903064009_enable_current_project_custom_fields_columns.rbdeleted file mode 100644index 47d9eaf4a26..00000000000--- a/db/migrate/20200903064009_enable_current_project_custom_fields_columns.rb+++ /dev/null@@ -1,42 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class EnableCurrentProjectCustomFieldsColumns < ActiveRecord::Migration[6.0]- def up- return unless Setting.where(name: "enabled_projects_columns").exists? # rubocop:disable Rails/WhereExists-- columns = Setting.enabled_projects_columns- cf_columns = ProjectCustomField.pluck(:id).map { |id| "cf_#{id}" }-- Setting.enabled_projects_columns = (columns + cf_columns).uniq- end-- def down- # Nothing to do as setting is not used- end-enddiff --git a/db/migrate/20200907090753_change_attachment_filesize_to_big_int.rb b/db/migrate/20200907090753_change_attachment_filesize_to_big_int.rbdeleted file mode 100644index 0da979e4b49..00000000000--- a/db/migrate/20200907090753_change_attachment_filesize_to_big_int.rb+++ /dev/null@@ -1,39 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class ChangeAttachmentFilesizeToBigInt < ActiveRecord::Migration[6.0]- def up- change_column :attachments, :filesize, :integer, limit: 8- change_column :attachment_journals, :filesize, :integer, limit: 8- end-- def down- change_column :attachments, :filesize, :integer, limit: 4- change_column :attachment_journals, :filesize, :integer, limit: 4- end-enddiff --git a/db/migrate/20200914092212_set_current_timestamp_defaults_for_bcf_viewpoints_and_issues.rb b/db/migrate/20200914092212_set_current_timestamp_defaults_for_bcf_viewpoints_and_issues.rbdeleted file mode 100644index 5fc22c63da0..00000000000--- a/db/migrate/20200914092212_set_current_timestamp_defaults_for_bcf_viewpoints_and_issues.rb+++ /dev/null@@ -1,40 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class SetCurrentTimestampDefaultsForBcfViewpointsAndIssues < ActiveRecord::Migration[6.0]- def up- change_column_default(:bcf_issues, :created_at, -> { "CURRENT_TIMESTAMP" })- change_column_default(:bcf_issues, :updated_at, -> { "CURRENT_TIMESTAMP" })- change_column_default(:bcf_viewpoints, :created_at, -> { "CURRENT_TIMESTAMP" })- change_column_default(:bcf_viewpoints, :updated_at, -> { "CURRENT_TIMESTAMP" })- end-- def down- # Nothing to do.- end-enddiff --git a/db/migrate/20200925084550_members_allow_null_on_project.rb b/db/migrate/20200925084550_members_allow_null_on_project.rbdeleted file mode 100644index 5b15687ee78..00000000000--- a/db/migrate/20200925084550_members_allow_null_on_project.rb+++ /dev/null@@ -1,154 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class MembersAllowNullOnProject < ActiveRecord::Migration[6.0]- def change- change_column_null :members, :project_id, true- change_column_default :members, :project_id, from: 0, to: nil- add_column :members, :updated_at, :timestamp, default: -> { "CURRENT_TIMESTAMP" }-- reversible do |rev|- rev.up do- add_updated_at_values- migrate_principal_roles_data- end-- rev.down do- migrate_global_members_data- end- end-- change_column_null :members, :updated_at, false- rename_column :members, :created_on, :created_at-- drop_table :principal_roles do |t|- t.column :role_id, :integer, null: false, index: true- t.column :principal_id, :integer, null: false, index: true- t.timestamps- end- end-- private-- def add_updated_at_values- execute <<~SQL.squish- UPDATE- members- SET#{' '}- updated_at = created_on- SQL- end-- def migrate_principal_roles_data- fetch_principal_roles.each do |principal_id, records|- member_id = insert_into_members(principal_id, records.first["created_at"], records.first["updated_at"])- insert_into_member_roles(member_id, records.pluck("role_id"))- end- end-- def fetch_principal_roles- select_all("SELECT * from principal_roles")- .to_a- .group_by { |r| r["principal_id"] }- end-- def insert_into_members(principal_id, created_at, updated_at)- member_id = select_all <<~SQL.squish- INSERT INTO- members(user_id, created_on, updated_at)- VALUES (#{principal_id}, '#{created_at}', '#{updated_at}')- RETURNING id- SQL-- member_id.to_a.first["id"]- end-- def insert_into_member_roles(member_id, role_ids)- values = role_ids.map { |role_id| "(#{member_id}, #{role_id})" }-- execute <<~SQL.squish- INSERT INTO- member_roles(member_id, role_id)- VALUES #{values.join(', ')}- SQL- end-- def migrate_global_members_data- insert_into_principal_roles- delete_global_members- end-- def insert_into_principal_roles- execute <<~SQL.squish- INSERT INTO- principal_roles (principal_id, role_id, created_at, updated_at)- SELECT- user_id,- role_id,- created_on,- created_on- FROM- members- JOIN- member_roles- ON- members.id = member_roles.member_id- WHERE- members.project_id IS NULL- SQL- end-- def delete_global_members- execute <<~SQL.squish- DELETE- FROM- members- WHERE- project_id IS NULL- SQL-- execute <<~SQL.squish- DELETE- FROM- member_roles- WHERE- id IN (- SELECT- member_roles.id- FROM- member_roles- LEFT JOIN- members- ON- member_roles.member_id = members.id- WHERE- members.id IS NULL- )- SQL- end-enddiff --git a/db/migrate/20201001184404_rename_timestamp_on_time_and_cost_entry.rb b/db/migrate/20201001184404_rename_timestamp_on_time_and_cost_entry.rbdeleted file mode 100644index 73b3ee6cc38..00000000000--- a/db/migrate/20201001184404_rename_timestamp_on_time_and_cost_entry.rb+++ /dev/null@@ -1,44 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RenameTimestampOnTimeAndCostEntry < ActiveRecord::Migration[6.0]- def change- alter_name_and_defaults(:time_entries)- alter_name_and_defaults(:cost_entries)- end-- private-- def alter_name_and_defaults(table)- rename_column table, :created_on, :created_at- rename_column table, :updated_on, :updated_at-- change_column_default table, :created_at, from: nil, to: -> { "CURRENT_TIMESTAMP" }- change_column_default table, :updated_at, from: nil, to: -> { "CURRENT_TIMESTAMP" }- end-enddiff --git a/db/migrate/20201005120137_ensure_integer_for_relations_foreign_keys.rb b/db/migrate/20201005120137_ensure_integer_for_relations_foreign_keys.rbdeleted file mode 100644index 81baf213488..00000000000--- a/db/migrate/20201005120137_ensure_integer_for_relations_foreign_keys.rb+++ /dev/null@@ -1,49 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--# The conversion of MySQL databases to PostgreSQL seems to create a lot of columns-# that should be of type `integer` but are created as `bigint`.-# This leads to cast errors e.g. when combining an array of integers with a bigint.-# This migration only focuses on two columns in the relations table-# as they need to be integers for custom sql (scope WorkPackages.for_scheduling).-class EnsureIntegerForRelationsForeignKeys < ActiveRecord::Migration[6.0]- def up- # The table information we have might be outdated- Relation.reset_column_information-- # Nothing to do for us if the column already has the expected type- return if Relation.column_for_attribute("from_id").sql_type == "integer"-- change_table :relations do |t|- t.change :from_id, :integer, null: false- t.change :to_id, :integer, null: false- end-- Relation.reset_column_information- end-enddiff --git a/db/migrate/20201005184411_rename_timestamps.rb b/db/migrate/20201005184411_rename_timestamps.rbdeleted file mode 100644index e7f056db091..00000000000--- a/db/migrate/20201005184411_rename_timestamps.rb+++ /dev/null@@ -1,93 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RenameTimestamps < ActiveRecord::Migration[6.0]- def change- alter_name_and_defaults(:comments, :created_on, :created_at)- alter_name_and_defaults(:comments, :updated_on, :updated_at)-- alter_name_and_defaults(:messages, :created_on, :created_at)- alter_name_and_defaults(:messages, :updated_on, :updated_at)-- alter_name_and_defaults(:versions, :created_on, :created_at)- alter_name_and_defaults(:versions, :updated_on, :updated_at)-- alter_name_and_defaults(:users, :created_on, :created_at)- alter_name_and_defaults(:users, :updated_on, :updated_at)-- alter_name_and_defaults(:wiki_pages, :created_on, :created_at)- alter_name_and_defaults(:wiki_redirects, :created_on, :created_at)-- alter_name_and_defaults(:tokens, :created_on, :created_at)-- alter_name_and_defaults(:settings, :updated_on, :updated_at)-- alter_name_and_defaults(:cost_queries, :created_on, :created_at)- alter_name_and_defaults(:cost_queries, :updated_on, :updated_at)-- alter_name_and_defaults(:wiki_contents, :updated_on, :updated_at)-- add_timestamp_column(:journals, :updated_at, :created_at)-- add_timestamp_column(:roles, :created_at, "CURRENT_TIMESTAMP")- add_timestamp_column(:roles, :updated_at, "CURRENT_TIMESTAMP")- end-- private-- def alter_name_and_defaults(table, old_column_name, new_column_name)- rename_column table, old_column_name, new_column_name-- change_column_default table, new_column_name, from: nil, to: -> { "CURRENT_TIMESTAMP" }-- # Ensure we reset column information because otherwise,- # +updated_on+ will still be used.- begin- cls = table.to_s.singularize.classify.constantize- cls.reset_column_information- rescue StandardError => e- warn "Could not reset_column_information for table #{table}: #{e.message}"- end- end-- def add_timestamp_column(table, column_name, from_column = nil)- add_column table, column_name, :timestamp, default: -> { "CURRENT_TIMESTAMP" }-- reversible do |dir|- dir.up do- execute <<~SQL.squish- UPDATE- #{table}- SET #{column_name} = #{from_column}- SQL- end- end-- change_column_null table, column_name, true- end-enddiff --git a/db/migrate/20201125121949_remove_renamed_cron_job.rb b/db/migrate/20201125121949_remove_renamed_cron_job.rbdeleted file mode 100644index 141b3d4a960..00000000000--- a/db/migrate/20201125121949_remove_renamed_cron_job.rb+++ /dev/null@@ -1,36 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RemoveRenamedCronJob < ActiveRecord::Migration[6.0]- def up- # The job has been renamed to JobStatus::Cron::ClearOldJobStatusJob- # the new job will be added on restarting the application but the old will still be in the database- # and will cause 'uninitialized constant' errors.- execute("DELETE FROM delayed_jobs WHERE handler LIKE '%job_class: Cron::ClearOldJobStatusJob%'")- end-enddiff --git a/db/migrate/20210126112238_add_uniqueness_constrain_on_lastname_for_groups_and_placeholder_users.rb b/db/migrate/20210126112238_add_uniqueness_constrain_on_lastname_for_groups_and_placeholder_users.rbdeleted file mode 100644index 52a864c486c..00000000000--- a/db/migrate/20210126112238_add_uniqueness_constrain_on_lastname_for_groups_and_placeholder_users.rb+++ /dev/null@@ -1,45 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddUniquenessConstrainOnLastnameForGroupsAndPlaceholderUsers < ActiveRecord::Migration[6.1]- def up- # Partial unique index- execute <<-SQL.squish- CREATE UNIQUE INDEX unique_lastname_for_groups_and_placeholder_users ON- users (lastname, type)- WHERE (type = 'Group' OR type = 'PlaceholderUser');- SQL- end-- def down- # Remove unique index- execute <<-SQL.squish- DROP INDEX IF EXISTS unique_lastname_for_groups_and_placeholder_users;- SQL- end-enddiff --git a/db/migrate/20210127134438_alter_user_attributes_max_length.rb b/db/migrate/20210127134438_alter_user_attributes_max_length.rbdeleted file mode 100644index a2ddd3307d7..00000000000--- a/db/migrate/20210127134438_alter_user_attributes_max_length.rb+++ /dev/null@@ -1,41 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AlterUserAttributesMaxLength < ActiveRecord::Migration[6.0]- def up- change_column :users, :firstname, :string, limit: nil- change_column :users, :lastname, :string, limit: nil- change_column :users, :mail, :string, limit: nil- end-- def down- change_column :users, :firstname, :string, limit: 30- change_column :users, :lastname, :string, limit: 30- change_column :users, :mail, :string, limit: 60- end-enddiff --git a/db/migrate/20210214205545_replace_invalid_principal_references.rb b/db/migrate/20210214205545_replace_invalid_principal_references.rbdeleted file mode 100644index bac82d2cdf0..00000000000--- a/db/migrate/20210214205545_replace_invalid_principal_references.rb+++ /dev/null@@ -1,50 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class ReplaceInvalidPrincipalReferences < ActiveRecord::Migration[6.1]- def up- DeletedUser.reset_column_information- deleted_user_id = DeletedUser.first.id-- say "Replacing invalid custom value user references"- CustomValue- .joins(:custom_field)- .where("#{CustomField.table_name}.field_format" => "user")- .where("value NOT IN (SELECT id::text FROM users)")- .update_all(value: deleted_user_id)-- say "Replacing invalid responsible user references in work packages"- WorkPackage- .where("responsible_id NOT IN (SELECT id FROM users)")- .update_all(responsible_id: deleted_user_id)- end-- def down- # Nothing to do, as only invalid data is fixed- end-enddiff --git a/db/migrate/20210221230446_add_group_user_primary_key.rb b/db/migrate/20210221230446_add_group_user_primary_key.rbdeleted file mode 100644index 71bbc212391..00000000000--- a/db/migrate/20210221230446_add_group_user_primary_key.rb+++ /dev/null@@ -1,37 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddGroupUserPrimaryKey < ActiveRecord::Migration[6.1]- def change- # Adding a primary key will automatically fill that column with values.- # Therefore, there is no need to assign it manually.- add_column :group_users, :id, :primary_key-- add_index :group_users, %i[user_id group_id], unique: true- end-enddiff --git a/db/migrate/20210310101840_generalize_exports.rb b/db/migrate/20210310101840_generalize_exports.rbdeleted file mode 100644index 2be4f14dee2..00000000000--- a/db/migrate/20210310101840_generalize_exports.rb+++ /dev/null@@ -1,43 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class GeneralizeExports < ActiveRecord::Migration[6.1]- def change- rename_table :work_package_exports, :exports-- change_table :exports do |t|- t.string :type- end-- reversible do |dir|- dir.up do- execute "UPDATE exports SET type = 'WorkPackages::Export'"- end- end- end-enddiff --git a/db/migrate/20210331085058_migrate_sessions_unlogged.rb b/db/migrate/20210331085058_migrate_sessions_unlogged.rbdeleted file mode 100644index de9d305b38c..00000000000--- a/db/migrate/20210331085058_migrate_sessions_unlogged.rb+++ /dev/null@@ -1,51 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class MigrateSessionsUnlogged < ActiveRecord::Migration[6.1]- def up- truncate :sessions-- # Set the table to UNLOGGED- execute <<~SQL.squish- ALTER TABLE "sessions" SET UNLOGGED- SQL-- # We don't need the created at column- # that now no longer is set by rails- remove_column :sessions, :created_at, null: false- end-- def down- # Set the table to LOGGED- execute <<~SQL.squish- ALTER TABLE "sessions" SET LOGGED- SQL-- add_column :sessions, :created_at, :datetime- end-enddiff --git a/db/migrate/20210427065703_make_system_user_admin.rb b/db/migrate/20210427065703_make_system_user_admin.rbdeleted file mode 100644index 13d26187ee2..00000000000--- a/db/migrate/20210427065703_make_system_user_admin.rb+++ /dev/null@@ -1,37 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class MakeSystemUserAdmin < ActiveRecord::Migration[6.1]- def up- User.system.update_column(:admin, true)- end-- def down- User.system.update_column(:admin, false)- end-enddiff --git a/db/migrate/20210510193438_remove_project_setting.rb b/db/migrate/20210510193438_remove_project_setting.rbdeleted file mode 100644index 7e0f4fb427b..00000000000--- a/db/migrate/20210510193438_remove_project_setting.rb+++ /dev/null@@ -1,42 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RemoveProjectSetting < ActiveRecord::Migration[6.1]- # Note: rails 7.1 breaks the class' ancestor chain, and raises an error, when a class- # with an enum definition without a database field is being referenced.- # Re-defining the Project class without the enum to avoid the issue.- class Project < ApplicationRecord; end-- def up- Project.where(name: "sequential_project_identifiers").delete_all- end-- def down- # Nothing to do- end-enddiff --git a/db/migrate/20210512121322_make_project_identifier_unique.rb b/db/migrate/20210512121322_make_project_identifier_unique.rbdeleted file mode 100644index d219d125dd7..00000000000--- a/db/migrate/20210512121322_make_project_identifier_unique.rb+++ /dev/null@@ -1,51 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class MakeProjectIdentifierUnique < ActiveRecord::Migration[6.1]- def change- begin- remove_index :projects, :identifier- rescue StandardError => e- raise <<~MESSAGE- Failed to remove an index from the OpenProject database: #{e.message}-- You likely have two OpenProject database schemas running at the same time since migrating- from MySQL to PostgreSQL.-- Please follow the following guide in our forums on how to correct this error before continuing the upgrade:- https://community.openproject.org/topics/13672?r=13736#message-13736- MESSAGE- end-- begin- add_index :projects, :identifier, unique: true- rescue StandardError => e- raise "You have a duplicate project identifier in your database: #{e.message}"- end- end-enddiff --git a/db/migrate/20210519141244_remove_reply_from_message_journalizing.rb b/db/migrate/20210519141244_remove_reply_from_message_journalizing.rbdeleted file mode 100644index f8c110978c4..00000000000--- a/db/migrate/20210519141244_remove_reply_from_message_journalizing.rb+++ /dev/null@@ -1,34 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RemoveReplyFromMessageJournalizing < ActiveRecord::Migration[6.1]- def change- remove_column :message_journals, :last_reply_id, :integer- remove_column :message_journals, :replies_count, :integer, default: 0, null: false- end-enddiff --git a/db/migrate/20210615150558_aggregate_journals.rb b/db/migrate/20210615150558_aggregate_journals.rbdeleted file mode 100644index 61f4bc66922..00000000000--- a/db/migrate/20210615150558_aggregate_journals.rb+++ /dev/null@@ -1,430 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require_relative "20200924085508_cleanup_orphaned_journal_data"-require_relative "migration_utils/utils"--class AggregateJournals < ActiveRecord::Migration[6.1]- include ::Migration::Utils-- # Classes have been removed by now- class WikiContent < ApplicationRecord; end-- # Class has been changed in the meantime.- # It received a status enum which's column does not yet exist when this migration runs.- class Attachment < ApplicationRecord; end-- def up- [Attachment,- Changeset,- Message,- News,- WikiContent,- WorkPackage,- Budget,- TimeEntry,- Document,- Meeting,- MeetingContent].each do |klass|- say_with_time "Aggregating journals for #{klass}" do- aggregate_journals(klass)- end- end-- # Now cleanup all orphaned attachable/customizable journals- CleanupOrphanedJournalData.up- end-- # The change is irreversible (aggregated journals cannot be broken down) but down will not cause database inconsistencies.-- def aggregate_journals(klass)- in_configurable_batches(klass) do |instances|- # Instantiating is faster than calculating the aggregated journals multiple times.- aggregated_journals = aggregated_journals_of(klass, instances).to_a-- aggregated_journals- .reject { |journal| journal.notes_id == journal.id }- .each do |mismatched_journal|- update_journal_notes(mismatched_journal)- end-- remove_unnecessary_journals(klass, instances, aggregated_journals)- end- end-- def aggregated_journals_of(klass, instances)- aggregated_journal(sql: Journal.where(journable_type: klass.name,- journable_id: instances.pluck(:id))- .to_sql)- end-- def update_journal_notes(mismatched_journal)- sql = <<~SQL.squish- UPDATE journals- SET notes = :notes- WHERE id = :id- SQL-- suppress_messages do- execute ::OpenProject::SqlSanitization.sanitize(sql, notes: mismatched_journal.notes, id: mismatched_journal.id)- end- end-- def remove_unnecessary_journals(klass, instances, aggregated_journals)- # Only delete the journals (without callbacks as it is faster).- # We remove the then orphaned attachable/customizable journals later.- Journal- .where(journable_type: klass.name, journable_id: instances.pluck(:id))- .where.not(id: aggregated_journals.map(&:id))- .delete_all- end-- def aggregated_journal(journable: nil, sql: nil, until_version: nil)- journals_preselection = raw_journals_subselect(journable, sql, until_version)-- # We wrap the sql with a subselect so that outside of this class,- # The fields native to journals (e.g. id, version) can be referenced, without- # having to also use a CASE/COALESCE statement.- Journal- .from(select_sql(journals_preselection))- .select("DISTINCT *")- end-- private-- # The sql used to query the database for the aggregated journals.- # The query makes use of 4 parts (which are selected from/joined):- # * The minimum journal version that starts an aggregation group.- # * The maximum journal version that ends an aggregation group.- # * Journals with notes that are within the bounds of minimum version/maximum version.- # * Journals with notes that are within the bounds of the before mentioned journal notes and the maximum journal version.- #- # The maximum version are those journals, whose successor:- # * Where created by a different user- # * Where created after the configured aggregation period had expired (always relative to the journal under consideration).- #- # The minimum version then is the maximum version of the group before - 1.- #- # e.g. a group of 10 sequential journals might break into the following groups- #- # Version 10 (User A, 6 minutes after 9)- # Version 9 (User A, 2 minutes after 8)- # Version 8 (User A, 4 minutes after 7)- # Version 7 (User A, 1 minute after 6)- # Version 6 (User A, 3 minutes after 5)- # Version 5 (User A, 1 minute after 4)- # Version 4 (User B, 1 minute after 3)- # Version 3 (User B, 4 minutes after 2)- # Version 2 (User A, 1 minute after 1)- # Version 1 (User A)- #- # would have the following maximum journals if the aggregation period where 5 minutes:- #- # Version 10 (User A, 6 minutes after 9)- # Version 9 (User A, 2 minutes after 8)- # Version 4 (User B, 1 minute after 3)- # Version 2 (User A, 1 minute after 1)- #- # The last journal (one without a successor) of a journable will obviously also always be a maximum journal.- #- # If the aggregation period where to be expanded to 7 minutes, the maximum journals would be slightly different:- #- # Version 10 (User A, 6 minutes after 9)- # Version 4 (User B, 1 minute after 3)- # Version 2 (User A, 1 minute after 1)- #- # As we do not store the aggregated journals, and rather calculate them on reading, the aggregated journals might be tuned- # by a user.- #- # The minimum version in the example with the 5 minute aggregation period would then be calculated from the maximum version:- #- # Version 10- # Version 5- # Version 3- # Version 1- #- # The first version will always be included.- #- # Without a journal with notes (the user commented on the journable) in between, the maximum journal is returned- # as the representation of every aggregation group. This is possible as the journals (together with their data and their- # customizable_journals/attachable_journals) represent the complete state of the journable at the given time.- #- # e.g. a group of 5 sequential journals without notes, belonging to the same user and created within the configured- # time difference between one journal and its successor- #- # Version 9- # Version 8- # Version 7- # Version 6- # Version 5- #- # would only return the last journal, Version 9.- #- # In case the group has one journal with notes in it, the last journal is also returned. But as we also want the note- # to be returned, we return the note as if it would belong to the maximum journal version. This explicitly means- # that all journals of the same group that are after the notes journal are also returned.- #- # e.g. a group of 5 sequential journals with only one note, belonging to the same user and created within the configured- # time difference between one journal and its successor- #- # Version 9- # Version 8- # Version 7- # Version 6 (note)- # Version 5- #- # would only return the last journal, Version 9, but would also return the note and the id of the journal the note- # belongs to natively.- #- # But as we do not want to aggregate notes, the behaviour above can no longer work if there is more than one note in the- # same group. In such a case, a group is cut into subsets. The journals returned will then only contain all the changes- # up until a journal with notes. The only exception to this is the last journal note which might also contain changes- # after it up to and including the maximum journal version of the group.-- # e.g. a group of 5 sequential journals with only one note, belonging to the same user and created within the configured- # time difference between one journal and its successor- #- # Version 9- # Version 8 (note)- # Version 7- # Version 6 (note)- # Version 5- #- # would return the last journal, Version 9, but with the note of Version 8 and also a reference in the form of- # note_id pointing to Version 8. It would also return Version 6, with its note and a reference in the form of note_id- # this time pointing to the native journal, Version 6.- #- # The journals that are considered for aggregation can also be reduced by providing a subselect. Doing so, one- # can e.g. consider only the journals created after a certain time.- def select_sql(journals_preselection)- <<~SQL.squish- (#{Journal- .from(start_group_journals_select(journals_preselection))- .joins(end_group_journals_join(journals_preselection))- .joins(notes_in_group_join(journals_preselection))- .joins(additional_notes_in_group_join(journals_preselection))- .select(projection_list).to_sql}) journals- SQL- end-- def user_or_time_group_breaking_journals_subselect(journals_preselection)- <<~SQL.squish- SELECT- predecessor.*,- row_number() OVER (ORDER BY predecessor.journable_type, predecessor.journable_id, predecessor.version ASC) #{group_number_alias}- FROM #{journals_preselection} predecessor- LEFT OUTER JOIN #{journals_preselection} successor- ON predecessor.version + 1 = successor.version- AND predecessor.journable_type = successor.journable_type- AND predecessor.journable_id = successor.journable_id- WHERE (predecessor.user_id != successor.user_id- OR #{beyond_aggregation_time_condition})- OR successor.id IS NULL- SQL- end-- def notes_journals_subselect(journals_preselection)- <<~SQL.squish- (SELECT- notes_journals.*- FROM #{journals_preselection} notes_journals- WHERE notes_journals.notes != '' AND notes_journals.notes IS NOT NULL)- SQL- end-- def start_group_journals_select(journals_preselection)- "(#{user_or_time_group_breaking_journals_subselect(journals_preselection)}) #{start_group_journals_alias}"- end-- def end_group_journals_join(journals_preselection)- group_journals_join_condition = <<~SQL.squish- #{start_group_journals_alias}.#{group_number_alias} = #{end_group_journals_alias}.#{group_number_alias} - 1- AND #{start_group_journals_alias}.journable_type = #{end_group_journals_alias}.journable_type- AND #{start_group_journals_alias}.journable_id = #{end_group_journals_alias}.journable_id- SQL-- end_group_journals = <<~SQL.squish- RIGHT OUTER JOIN- (#{user_or_time_group_breaking_journals_subselect(journals_preselection)}) #{end_group_journals_alias}- ON #{group_journals_join_condition}- SQL-- Arel.sql(end_group_journals)- end-- def notes_in_group_join(journals_preselection)- # As we right join on the minimum journal version, the minimum might be empty. We thus have to coalesce in such- # case as <= will not interpret NULL as 0.- # This also works if we do not fetch the whole set of journals starting from the first journal but rather- # start somewhere within the set. This might take place e.g. when fetching only the journals that are- # created after a certain point in time which is done when displaying of the last month in the activity module.- breaking_journals_notes_join_condition = <<~SQL.squish- COALESCE(#{start_group_journals_alias}.version, 0) + 1 <= #{notes_in_group_alias}.version- AND #{end_group_journals_alias}.version >= #{notes_in_group_alias}.version- AND #{end_group_journals_alias}.journable_type = #{notes_in_group_alias}.journable_type- AND #{end_group_journals_alias}.journable_id = #{notes_in_group_alias}.journable_id- SQL-- breaking_journals_notes = <<~SQL.squish- LEFT OUTER JOIN- #{notes_journals_subselect(journals_preselection)} #{notes_in_group_alias}- ON #{breaking_journals_notes_join_condition}- SQL-- Arel.sql(breaking_journals_notes)- end-- def additional_notes_in_group_join(journals_preselection)- successor_journals_notes_join_condition = <<~SQL.squish- #{notes_in_group_alias}.version < successor_notes.version- AND #{end_group_journals_alias}.version >= successor_notes.version- AND #{end_group_journals_alias}.journable_type = successor_notes.journable_type- AND #{end_group_journals_alias}.journable_id = successor_notes.journable_id- SQL-- successor_journals_notes = <<~SQL.squish- LEFT OUTER JOIN- #{notes_journals_subselect(journals_preselection)} successor_notes- ON #{successor_journals_notes_join_condition}- SQL-- Arel.sql(successor_journals_notes)- end-- def projection_list- projections = <<~SQL.squish- #{end_group_journals_alias}.journable_type,- #{end_group_journals_alias}.journable_id,- #{end_group_journals_alias}.user_id,- #{end_group_journals_alias}.activity_type,- #{notes_projection} notes,- #{notes_id_projection} notes_id,- #{notes_in_group_alias}.version notes_version,- #{version_projection} AS version,- #{created_at_projection} created_at,- #{updated_at_projection} updated_at,- #{id_projection} id- SQL-- Arel.sql(projections)- end-- def id_projection- attribute_projection(:id)- end-- def version_projection- attribute_projection(:version)- end-- def created_at_projection- attribute_projection(:created_at)- end-- def updated_at_projection- attribute_projection(:updated_at)- end-- def attribute_projection(attribute)- <<~SQL.squish- CASE- WHEN successor_notes.version IS NOT NULL THEN #{notes_in_group_alias}.#{attribute}- ELSE #{end_group_journals_alias}.#{attribute} END- SQL- end-- def notes_id_projection- <<~SQL.squish- COALESCE(#{notes_in_group_alias}.id, #{end_group_journals_alias}.id)- SQL- end-- def notes_projection- <<~SQL.squish- COALESCE(#{notes_in_group_alias}.notes, '')- SQL- end-- def raw_journals_subselect(journable, sql, until_version)- if sql- raise "until_version used together with sql" if until_version-- "(#{sql})"- elsif journable- limit = until_version ? "AND journals.version <= #{until_version}" : ""-- <<~SQL.squish- (- SELECT * from journals- WHERE journals.journable_id = #{journable.id}- AND journals.journable_type = '#{journable.class.name}'- #{limit}- )- SQL- else- where = until_version ? "WHERE journals.version <= #{until_version}" : ""-- <<~SQL.squish- (SELECT * from journals #{where})- SQL- end- end-- # Returns a SQL condition that will determine whether two entries are too far apart (temporal)- # to be considered for aggregation. This takes the current instance settings for temporal- # proximity into account.- def beyond_aggregation_time_condition- aggregation_time_seconds = Setting.journal_aggregation_time_minutes.to_i.minutes- if aggregation_time_seconds == 0- # if aggregation is disabled, we consider everything to be beyond aggregation time- # even if creation dates are exactly equal- return "(true = true)"- end-- difference = "(successor.created_at - predecessor.created_at)"- threshold = "interval '#{aggregation_time_seconds} second'"-- "(#{difference} > #{threshold})"- end-- def start_group_journals_alias- "start_groups_journals"- end-- def end_group_journals_alias- "end_groups_journals"- end-- def group_number_alias- "group_number"- end-- def notes_in_group_alias- "notes_in_group_journals"- end-enddiff --git a/db/migrate/20210616145324_polymorphic_journal_data.rb b/db/migrate/20210616145324_polymorphic_journal_data.rbdeleted file mode 100644index 1837fc7d5c6..00000000000--- a/db/migrate/20210616145324_polymorphic_journal_data.rb+++ /dev/null@@ -1,108 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class PolymorphicJournalData < ActiveRecord::Migration[6.1]- # The wiki content table got renamed after writing the migration initially.- class WikiContentJournal < ApplicationRecord- self.table_name = "wiki_content_journals"- end-- def up- # For performance reasons, the existing indices are first removed and then readded after the- # update is done.- add_data_and_remove_index-- data_journals.each do |journal_data|- execute <<~SQL.squish- UPDATE journals- SET data_id = data.id, data_type = '#{journal_data.name}'- FROM #{journal_data.table_name} data- WHERE data.journal_id = journals.id- SQL-- remove_column journal_data.table_name, :journal_id- end-- add_indices- end-- def down- data_journals.each do |journal_data|- add_column journal_data.table_name, :journal_id, :integer- add_index journal_data.table_name, :journal_id-- execute <<~SQL.squish- UPDATE #{journal_data.table_name} data- SET journal_id = journals.id- FROM journals- WHERE data.id = journals.data_id AND journals.data_type = '#{journal_data.name}'- SQL- end-- remove_reference :journals, :data, polymorphic: true- end-- def data_journals- [::Journal::ChangesetJournal,- ::Journal::AttachmentJournal,- ::Journal::MessageJournal,- ::Journal::NewsJournal,- WikiContentJournal,- ::Journal::WorkPackageJournal,- ::Journal::BudgetJournal,- ::Journal::TimeEntryJournal,- ::Journal::DocumentJournal,- ::Journal::MeetingJournal,- ::Journal::MeetingContentJournal]- end-- def add_data_and_remove_index- change_table :journals do |j|- j.references :data, polymorphic: true, index: false-- j.remove_index :journable_id- j.remove_index :journable_type- j.remove_index :created_at- j.remove_index :user_id- j.remove_index :activity_type- j.remove_index %i[journable_type journable_id version]- end- end-- def add_indices- change_table :journals do |j|- j.index :journable_id- j.index :journable_type- j.index :created_at- j.index :user_id- j.index :activity_type- j.index %i[journable_type journable_id version], unique: true- j.index %i[data_id data_type], unique: true- end- end-enddiff --git a/db/migrate/20210618125430_authors_as_watchers.rb b/db/migrate/20210618125430_authors_as_watchers.rbdeleted file mode 100644index a7477ab99c6..00000000000--- a/db/migrate/20210618125430_authors_as_watchers.rb+++ /dev/null@@ -1,81 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AuthorsAsWatchers < ActiveRecord::Migration[6.1]- def up- # Add a watcher on every work package for its author- # if:- # * the author isn't already watcher- # * the author isn't locked and has the permission to see the work package- # * member of the project in a role with the necessary permission OR- # * non member in a public project and the non member role has the necessary permission- execute <<~SQL.squish- INSERT INTO watchers (- watchable_id,- watchable_type,- user_id- )- SELECT DISTINCT work_packages.id, 'WorkPackage', users.id- FROM work_packages- LEFT JOIN- watchers- ON watchers.watchable_id = work_packages.id- AND watchers.watchable_type = 'WorkPackage'- AND watchers.user_id = work_packages.author_id- LEFT JOIN- users- ON work_packages.author_id = users.id- AND users.type = 'User'- AND users.status != #{Principal.statuses[:locked]}- LEFT JOIN- projects- ON work_packages.project_id = projects.id- LEFT JOIN- members- ON work_packages.project_id = members.project_id- AND members.user_id = users.id- LEFT JOIN- member_roles- ON members.id = member_roles.member_id- LEFT JOIN- roles- ON member_roles.role_id = roles.id- OR (roles.builtin = #{Role::BUILTIN_NON_MEMBER} AND projects.public)- LEFT JOIN- role_permissions- ON roles.id = role_permissions.role_id- AND role_permissions.permission = 'view_work_packages'- WHERE watchers.id IS NULL- AND users.id IS NOT NULL- AND role_permissions IS NOT NULL- SQL- end-- # No down since we cannot distinguish between watchers that existed before- # and the ones that where created by the migration.-enddiff --git a/db/migrate/20210618132206_add_notification_settings.rb b/db/migrate/20210618132206_add_notification_settings.rbdeleted file mode 100644index 8639113cf32..00000000000--- a/db/migrate/20210618132206_add_notification_settings.rb+++ /dev/null@@ -1,66 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddNotificationSettings < ActiveRecord::Migration[6.1]- def up- create_table :notification_settings do |t|- t.belongs_to :project, null: true, index: true, foreign_key: true- t.belongs_to :user, null: false, index: true, foreign_key: true- t.integer :channel, limit: 1- t.boolean :watched, default: false- t.boolean :involved, default: false- t.boolean :mentioned, default: false- t.boolean :all, default: false-- t.timestamps default: -> { "CURRENT_TIMESTAMP" }-- t.index %i[user_id channel],- unique: true,- where: "project_id IS NULL",- name: "index_notification_settings_unique_project_null"-- t.index %i[user_id project_id channel],- unique: true,- where: "project_id IS NOT NULL",- name: "index_notification_settings_unique_project"- end-- remove_column :members, :mail_notification- remove_column :users, :mail_notification- end-- def down- add_column :members, :mail_notification, :boolean, default: false, null: false- add_column :users, :mail_notification, :string, default: "", null: false-- drop_table :notification_settings-- User.reset_column_information- User.update_all(mail_notification: "only_assigned")- end-enddiff --git a/db/migrate/20210628185054_extend_custom_field_name_length.rb b/db/migrate/20210628185054_extend_custom_field_name_length.rbdeleted file mode 100644index 24096d5ac7e..00000000000--- a/db/migrate/20210628185054_extend_custom_field_name_length.rb+++ /dev/null@@ -1,37 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class ExtendCustomFieldNameLength < ActiveRecord::Migration[6.1]- def up- change_column :custom_fields, :name, :string, limit: nil- end-- def down- change_column :custom_fields, :name, :string, limit: 30- end-enddiff --git a/db/migrate/20210701073944_add_digest_setting.rb b/db/migrate/20210701073944_add_digest_setting.rbdeleted file mode 100644index f88186fa467..00000000000--- a/db/migrate/20210701073944_add_digest_setting.rb+++ /dev/null@@ -1,49 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddDigestSetting < ActiveRecord::Migration[6.1]- def up- # No-op- end-- def down- remove_digest_channels- end-- # Removes all digest channels. Includes non default channels as those might- # also have been added not by the migration but in the cause of the functionality- # the migration was added for.- def remove_digest_channels- execute <<~SQL.squish- DELETE FROM- notification_settings- WHERE- channel = 2- SQL- end-enddiff --git a/db/migrate/20210701082511_add_digest_to_notification.rb b/db/migrate/20210701082511_add_digest_to_notification.rbdeleted file mode 100644index c6716bae639..00000000000--- a/db/migrate/20210701082511_add_digest_to_notification.rb+++ /dev/null@@ -1,40 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddDigestToNotification < ActiveRecord::Migration[6.1]- def change- change_table :notifications, bulk: true do |t|- t.column :read_mail_digest, :boolean, default: false, index: true- t.column :reason_mail, :integer, limit: 1- t.column :reason_mail_digest, :integer, limit: 1- end-- rename_column :notifications, :reason, :reason_ian- rename_column :notifications, :read_email, :read_mail- end-enddiff --git a/db/migrate/20210713081724_flip_bcf_viewpoint_clipping_direction_selectively.rb b/db/migrate/20210713081724_flip_bcf_viewpoint_clipping_direction_selectively.rbdeleted file mode 100644index ff4a94c15b8..00000000000--- a/db/migrate/20210713081724_flip_bcf_viewpoint_clipping_direction_selectively.rb+++ /dev/null@@ -1,71 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class FlipBcfViewpointClippingDirectionSelectively < ActiveRecord::Migration[6.1]- def up- flip_op_clipping_planes- end-- def down- flip_op_clipping_planes- end-- private-- def flip_op_clipping_planes- viewpoints = select_viewpoints_created_in_op- viewpoints.each do |viewpoint|- new_json_viewpoint = flip_clipping_planes(viewpoint.json_viewpoint)- viewpoint.update_column(:json_viewpoint, new_json_viewpoint)- end- end-- def select_viewpoints_created_in_op- join_condition = %{- bcf_viewpoints.json_viewpoint->>'clipping_planes' IS NOT NULL- AND- (- bcf_issues.markup IS NULL- OR- XPATH_EXISTS('/comment()[contains(., ''Created by OpenProject'')]', bcf_issues.markup)- )- }- ::Bim::Bcf::Viewpoint.joins(:issue).where(join_condition)- end-- def flip_clipping_planes(viewpoint)- viewpoint_dup = viewpoint.deep_dup- viewpoint_dup["clipping_planes"].each do |plane|- plane["direction"]["x"] *= -1- plane["direction"]["y"] *= -1- plane["direction"]["z"] *= -1- end-- viewpoint_dup- end-enddiff --git a/db/migrate/20210726070813_remove_journal_versions.rb b/db/migrate/20210726070813_remove_journal_versions.rbdeleted file mode 100644index b11e5512be4..00000000000--- a/db/migrate/20210726070813_remove_journal_versions.rb+++ /dev/null@@ -1,41 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require_relative "20190724093332_add_journal_versions_table"--# db/migrate/20200522140244_remove_journal_versions_table.rb-# incorrectly removes journal_versions-class RemoveJournalVersions < ActiveRecord::Migration[6.1]- def up- ::AddJournalVersionsTable.new.down- end-- def down- # Nothing to do- end-enddiff --git a/db/migrate/20210802114054_add_notification_setting_options.rb b/db/migrate/20210802114054_add_notification_setting_options.rbdeleted file mode 100644index 16b31531540..00000000000--- a/db/migrate/20210802114054_add_notification_setting_options.rb+++ /dev/null@@ -1,48 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddNotificationSettingOptions < ActiveRecord::Migration[6.1]- def change- add_notification_settings_options- end-- def add_notification_settings_options- change_table :notification_settings, bulk: true do |t|- # Adding indices here is probably useful as most of those are expected to be false- # and we are searching for those that are true.- # The columns watched, involved and mentioned will probably be true most of the time- # so having an index there should not improve speed.- t.boolean :work_package_commented, default: false, index: true- t.boolean :work_package_created, default: false, index: true- t.boolean :work_package_processed, default: false, index: true- t.boolean :work_package_prioritized, default: false, index: true- t.boolean :work_package_scheduled, default: false, index: true- t.index :all- end- end-enddiff --git a/db/migrate/20210825183540_make_user_preferences_json.rb b/db/migrate/20210825183540_make_user_preferences_json.rbdeleted file mode 100644index 9fe33c5584b..00000000000--- a/db/migrate/20210825183540_make_user_preferences_json.rb+++ /dev/null@@ -1,83 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require_relative "migration_utils/utils"--class MakeUserPreferencesJson < ActiveRecord::Migration[6.1]- include ::Migration::Utils-- class UserPreferenceWithOthers < ::UserPreference- self.table_name = "user_preferences"- serialize :others, type: Hash- serialize :settings, coder: ::Serializers::IndifferentHashSerializer- end-- def up- add_column :user_preferences, :settings, :jsonb, default: {}-- UserPreferenceWithOthers.reset_column_information- in_configurable_batches(UserPreferenceWithOthers).each_record do |pref|- migrate_yaml_to_json(pref)- pref.save!(validate: false)- end-- change_table :user_preferences, bulk: true do |t|- t.remove :others, :hide_mail, :time_zone- end- end-- def down- change_table :user_preferences, bulk: true do |t|- t.text :others- t.boolean :hide_mail, default: true- t.text :time_zone- end-- UserPreferenceWithOthers.reset_column_information- in_configurable_batches(UserPreferenceWithOthers).each_record do |pref|- migrate_json_to_yaml(pref)- pref.save!(validate: false)- end-- remove_column :user_preferences, :settings, :jsonb- end-- private-- def migrate_yaml_to_json(pref)- pref.settings = pref.others- pref.settings[:hide_mail] = pref.hide_mail- pref.settings[:time_zone] = pref.time_zone- end-- def migrate_json_to_yaml(pref)- pref.others = pref.settings- pref.hide_mail = pref.settings[:hide_mail]- pref.time_zone = pref.settings[:time_zone]- end-enddiff --git a/db/migrate/20210902201126_cleanup_user_preferences.rb b/db/migrate/20210902201126_cleanup_user_preferences.rbdeleted file mode 100644index 8dbbed25809..00000000000--- a/db/migrate/20210902201126_cleanup_user_preferences.rb+++ /dev/null@@ -1,95 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class CleanupUserPreferences < ActiveRecord::Migration[6.1]- def up- execute <<~SQL.squish- UPDATE user_preferences- SET settings = settings - 'warn_on_leaving_unsaved' || '{"warn_on_leaving_unsaved": true}'- WHERE settings ->> 'warn_on_leaving_unsaved' = '1'- SQL-- execute <<~SQL.squish- UPDATE user_preferences- SET settings = settings - 'warn_on_leaving_unsaved' || '{"warn_on_leaving_unsaved": false}'- WHERE settings ->> 'warn_on_leaving_unsaved' = '0'- SQL-- execute <<~SQL.squish- UPDATE user_preferences- SET settings = settings - 'hide_mail' || '{"hide_mail": false}'- WHERE settings ->> 'hide_mail' = '0'- SQL-- execute <<~SQL.squish- UPDATE user_preferences- SET settings = settings - 'hide_mail' || '{"hide_mail": true}'- WHERE settings ->> 'hide_mail' = '1'- SQL-- # Remove all other keys from the user preferences- object_map = UserPreferences::Schema.properties.map { |key| "'#{key}', settings->'#{key}'" }.join(", ")- execute <<~SQL.squish- WITH subquery AS (- SELECT id,- jsonb_strip_nulls(jsonb_build_object(#{object_map})) as stripped_settings- FROM user_preferences- )- UPDATE user_preferences- SET settings = subquery.stripped_settings- FROM subquery- WHERE user_preferences.id = subquery.id- SQL- end-- def down- execute <<~SQL.squish- UPDATE user_preferences- SET settings = settings - 'warn_on_leaving_unsaved' || '{"warn_on_leaving_unsaved": "1"}'- WHERE settings ->> 'warn_on_leaving_unsaved' = 'true'- SQL-- execute <<~SQL.squish- UPDATE user_preferences- SET settings = settings - 'warn_on_leaving_unsaved' || '{"warn_on_leaving_unsaved": "0"}'- WHERE settings ->> 'warn_on_leaving_unsaved' = 'false'- SQL-- execute <<~SQL.squish- UPDATE user_preferences- SET settings = settings - 'hide_mail' || '{"hide_mail": 0}'- WHERE settings ->> 'hide_mail' = 'true'- SQL-- execute <<~SQL.squish- UPDATE user_preferences- SET settings = settings - 'hide_mail' || '{"hide_mail": 1}'- WHERE settings ->> 'hide_mail' = 'false'- SQL- end-enddiff --git a/db/migrate/20210910092414_add_bcf_comment_hierarchy.rb b/db/migrate/20210910092414_add_bcf_comment_hierarchy.rbdeleted file mode 100644index 25308536108..00000000000--- a/db/migrate/20210910092414_add_bcf_comment_hierarchy.rb+++ /dev/null@@ -1,34 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddBcfCommentHierarchy < ActiveRecord::Migration[6.1]- def change- add_column :bcf_comments, :reply_to, :bigint, default: nil, null: true- add_foreign_key :bcf_comments, :bcf_comments, column: :reply_to, on_delete: :nullify- end-enddiff --git a/db/migrate/20210914065555_cleanup_notifications.rb b/db/migrate/20210914065555_cleanup_notifications.rbdeleted file mode 100644index 5b63f186f3f..00000000000--- a/db/migrate/20210914065555_cleanup_notifications.rb+++ /dev/null@@ -1,86 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class CleanupNotifications < ActiveRecord::Migration[6.1]- def up- change_table :notifications, bulk: true do |t|- t.remove :read_mail, :reason_mail, :reason_mail_digest- t.rename :reason_ian, :reason- t.rename :read_mail_digest, :mail_reminder_sent- t.boolean :mail_alert_sent, default: nil, index: true- end-- change_table :notification_settings, bulk: true do |t|- t.remove_index name: "index_notification_settings_unique_project_null"- t.remove_index name: "index_notification_settings_unique_project"-- # Delete all non in-app- NotificationSetting.where("channel > 0").delete_all-- t.remove :channel, :all-- t.index %i[user_id],- unique: true,- where: "project_id IS NULL",- name: "index_notification_settings_unique_project_null"-- t.index %i[user_id project_id],- unique: true,- where: "project_id IS NOT NULL",- name: "index_notification_settings_unique_project"- end- end-- def down- change_table :notifications, bulk: true do |t|- t.boolean :read_mail, default: false, index: true- t.integer :reason_mail, limit: 1- t.integer :reason_mail_digest, limit: 1- t.rename :mail_reminder_sent, :read_mail_digest- t.rename :reason, :reason_ian- end-- change_table :notification_settings, bulk: true do |t|- t.integer :channel, limit: 1- t.boolean :all, default: false-- t.remove_index name: "index_notification_settings_unique_project_null"- t.remove_index name: "index_notification_settings_unique_project"-- t.index %i[user_id channel],- unique: true,- where: "project_id IS NULL",- name: "index_notification_settings_unique_project_null"-- t.index %i[user_id project_id channel],- unique: true,- where: "project_id IS NOT NULL",- name: "index_notification_settings_unique_project"- end- end-enddiff --git a/db/migrate/20210915154656_add_user_preference_settings_indices.rb b/db/migrate/20210915154656_add_user_preference_settings_indices.rbdeleted file mode 100644index cdce67f25f3..00000000000--- a/db/migrate/20210915154656_add_user_preference_settings_indices.rb+++ /dev/null@@ -1,46 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddUserPreferenceSettingsIndices < ActiveRecord::Migration[6.1]- def change- add_index :user_preferences,- "(settings->'daily_reminders'->'enabled')",- using: :gin,- name: "index_user_prefs_settings_daily_reminders_enabled"-- add_index :user_preferences,- "(settings->'daily_reminders'->'times')",- using: :gin,- name: "index_user_prefs_settings_daily_reminders_times"-- add_index :user_preferences,- "(settings->'time_zone')",- using: :gin,- name: "index_user_prefs_settings_time_zone"- end-enddiff --git a/db/migrate/20210917190141_non_work_package_notification_settings.rb b/db/migrate/20210917190141_non_work_package_notification_settings.rbdeleted file mode 100644index 5328fa8b57e..00000000000--- a/db/migrate/20210917190141_non_work_package_notification_settings.rb+++ /dev/null@@ -1,42 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class NonWorkPackageNotificationSettings < ActiveRecord::Migration[6.1]- def change- change_table :notification_settings, bulk: true do |t|- t.boolean :news_added, default: false, index: true- t.boolean :news_commented, default: false, index: true- t.boolean :document_added, default: false, index: true- t.boolean :forum_messages, default: false, index: true- t.boolean :wiki_page_added, default: false, index: true- t.boolean :wiki_page_updated, default: false, index: true- t.boolean :membership_added, default: false, index: true- t.boolean :membership_updated, default: false, index: true- end- end-enddiff --git a/db/migrate/20210922123908_notification_foreign_key_constraint.rb b/db/migrate/20210922123908_notification_foreign_key_constraint.rbdeleted file mode 100644index bb982f74683..00000000000--- a/db/migrate/20210922123908_notification_foreign_key_constraint.rb+++ /dev/null@@ -1,51 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class NotificationForeignKeyConstraint < ActiveRecord::Migration[6.1]- def change- reversible do |dir|- dir.up do- cleanup_invalid_notifications- end- end-- add_foreign_key :notifications, :journals- add_index :notifications, :journal_id- end-- private-- def cleanup_invalid_notifications- execute <<~SQL.squish- DELETE FROM notifications to_delete- USING notifications to_identify- LEFT JOIN journals ON to_identify.journal_id = journals.id- WHERE to_delete.id = to_identify.id AND journals.id IS NULL- SQL- end-enddiff --git a/db/migrate/20210928133538_add_reminder_workdays.rb b/db/migrate/20210928133538_add_reminder_workdays.rbdeleted file mode 100644index 5f01b12e1db..00000000000--- a/db/migrate/20210928133538_add_reminder_workdays.rb+++ /dev/null@@ -1,44 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require_relative "migration_utils/utils"--class AddReminderWorkdays < ActiveRecord::Migration[6.1]- include ::Migration::Utils-- def up- add_index :user_preferences,- "(settings->'workdays')",- using: :gin,- name: :index_user_prefs_settings_workdays- end-- def down- remove_index_if_exists :user_preferences, :index_user_prefs_settings_workdays- end-enddiff --git a/db/migrate/20211005080304_tzinfo_time_zones.rb b/db/migrate/20211005080304_tzinfo_time_zones.rbdeleted file mode 100644index 948d21091c2..00000000000--- a/db/migrate/20211005080304_tzinfo_time_zones.rb+++ /dev/null@@ -1,88 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class TzinfoTimeZones < ActiveRecord::Migration[6.1]- def up- zone_mappings = ActiveSupport::TimeZone- .all- .flat_map do |tz|- [- [tz.name, tz.tzinfo.canonical_zone.name],- # Some entries seem to already be in that format so we leave them unchanged- [tz.tzinfo.canonical_zone.name, tz.tzinfo.canonical_zone.name]- ]- end-- migrate_user_time_zone(zone_mappings)- migrate_default_time_zone(zone_mappings)- end-- def down- zone_mappings = ActiveSupport::TimeZone- .all- .map do |tz|- [tz.tzinfo.canonical_zone.name, tz.name]- end-- migrate_user_time_zone(zone_mappings)- migrate_default_time_zone(zone_mappings)- end-- protected-- def migrate_user_time_zone(mappings)- execute <<~SQL.squish- WITH source AS (- SELECT id, settings || jsonb_build_object('time_zone', to_zone) settings- FROM user_preferences- LEFT JOIN (SELECT * FROM (#{Arel::Nodes::ValuesList.new(mappings).to_sql}) as t(from_zone, to_zone)) zones- ON zones.from_zone = user_preferences.settings->>'time_zone'- )-- UPDATE user_preferences sink- SET settings = source.settings- FROM source- WHERE source.id = sink.id- AND sink.settings->'time_zone' IS NOT NULL- SQL- end-- def migrate_default_time_zone(mappings)- execute <<~SQL.squish- WITH zones AS (- SELECT * FROM (#{Arel::Nodes::ValuesList.new(mappings).to_sql}) as t(from_zone, to_zone)- )-- UPDATE settings- SET value = zones.to_zone- FROM zones- WHERE settings.name = 'user_default_timezone'- AND settings.value = zones.from_zone- SQL- end-enddiff --git a/db/migrate/20211005135637_remove_invalid_group_users.rb b/db/migrate/20211005135637_remove_invalid_group_users.rbdeleted file mode 100644index 4dfbfe63664..00000000000--- a/db/migrate/20211005135637_remove_invalid_group_users.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RemoveInvalidGroupUsers < ActiveRecord::Migration[6.1]- def up- GroupUser.where.missing(:user).destroy_all- end-enddiff --git a/db/migrate/20211022143726_remove_snapshot_data.rb b/db/migrate/20211022143726_remove_snapshot_data.rbdeleted file mode 100644index 319b0c8d85e..00000000000--- a/db/migrate/20211022143726_remove_snapshot_data.rb+++ /dev/null@@ -1,40 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RemoveSnapshotData < ActiveRecord::Migration[6.1]- def up- execute <<~SQL.squish- UPDATE bcf_viewpoints- SET json_viewpoint = json_viewpoint #- '{snapshot,snapshot_data}';- SQL- end-- def down- # removed snapshot data cannot be restored- end-enddiff --git a/db/migrate/20211026061420_add_indexes_for_email_reminder_pause.rb b/db/migrate/20211026061420_add_indexes_for_email_reminder_pause.rbdeleted file mode 100644index 3722b24d2a2..00000000000--- a/db/migrate/20211026061420_add_indexes_for_email_reminder_pause.rb+++ /dev/null@@ -1,43 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require_relative "migration_utils/utils"--class AddIndexesForEmailReminderPause < ActiveRecord::Migration[6.1]- include ::Migration::Utils-- def up- add_index :user_preferences,- "((user_preferences.settings->'pause_reminders'->>'enabled')::boolean)",- name: :index_user_prefs_settings_pause_reminders_enabled- end-- def down- remove_index_if_exists :user_preferences, :index_user_prefs_settings_pause_reminders_enabled- end-enddiff --git a/db/migrate/20211101152840_redistribute_edit_project_permission.rb b/db/migrate/20211101152840_redistribute_edit_project_permission.rbdeleted file mode 100644index fdbfc06ff11..00000000000--- a/db/migrate/20211101152840_redistribute_edit_project_permission.rb+++ /dev/null@@ -1,60 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RedistributeEditProjectPermission < ActiveRecord::Migration[6.1]- def up- add_permission("select_custom_fields")- add_permission("select_done_status")- end-- def down- remove_permission("select_custom_fields")- remove_permission("select_done_status")- end-- private-- def add_permission(name)- execute <<~SQL.squish- INSERT INTO- role_permissions- (permission, role_id, created_at, updated_at)- SELECT '#{name}', role_id, NOW(), NOW()- FROM role_permissions- WHERE permission = 'edit_project'- SQL- end-- def remove_permission(name)- execute <<~SQL.squish- DELETE FROM- role_permissions- WHERE permission = '#{name}'- SQL- end-enddiff --git a/db/migrate/20211102161932_remove_custom_field_types.rb b/db/migrate/20211102161932_remove_custom_field_types.rbdeleted file mode 100644index f78bcfbc689..00000000000--- a/db/migrate/20211102161932_remove_custom_field_types.rb+++ /dev/null@@ -1,63 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RemoveCustomFieldTypes < ActiveRecord::Migration[6.1]- def up- delete_custom_field("TimeEntryActivityCustomField")- delete_custom_field("DocumentCategoryCustomField")- delete_custom_field("IssuePriorityCustomField")-- delete_custom_values- end-- def delete_custom_field(type)- execute <<~SQL.squish- DELETE FROM- custom_fields- WHERE- type = '#{type}'- SQL- end-- def delete_custom_values- execute <<~SQL.squish- DELETE FROM- custom_values values_delete- USING- custom_values values_select- LEFT OUTER JOIN- custom_fields- ON- custom_fields.id = values_select.custom_field_id- WHERE- values_delete.id = values_select.id- AND- custom_fields.id IS NULL- SQL- end-enddiff --git a/db/migrate/20211103120946_clean_emails_footer.rb b/db/migrate/20211103120946_clean_emails_footer.rbdeleted file mode 100644index d9bbfd86dac..00000000000--- a/db/migrate/20211103120946_clean_emails_footer.rb+++ /dev/null@@ -1,64 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class CleanEmailsFooter < ActiveRecord::Migration[6.1]- def up- return unless Setting.where(name: "emails_footer").exists? # rubocop:disable Rails/WhereExists-- Setting.reset_column_information- filtered_footer = Setting- .emails_footer- .reject do |locale, text|- if assumed_notification_text?(text)- warn "Removing emails footer for #{locale} as it matches the default notification syntax."- true- end- end-- if filtered_footer.length < Setting.emails_footer.length- Setting.emails_footer = filtered_footer- end- end-- def down- # Nothing to migrate- end-- private-- def assumed_notification_text?(text)- [- "You have received this notification because of your notification settings",- "You have received this notification because you have either subscribed to it, or are involved in it.",- "Sie erhalten diese E-Mail aufgrund Ihrer Benachrichtungseinstellungen",- "/my/account",- "/my/notifications",- '/my/mail\_notifications'- ].any? { |val| text.include?(val) }- end-enddiff --git a/db/migrate/20211104151329_default_notification_setting.rb b/db/migrate/20211104151329_default_notification_setting.rbdeleted file mode 100644index df410c3c7a4..00000000000--- a/db/migrate/20211104151329_default_notification_setting.rb+++ /dev/null@@ -1,48 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class DefaultNotificationSetting < ActiveRecord::Migration[6.1]- def up- NotificationSetting.delete_all-- execute <<~SQL.squish- INSERT INTO- notification_settings- (user_id, watched, involved, mentioned)- SELECT- id, true, true, true- FROM- users- WHERE type = 'User'- SQL- end-- def down- # No data to revert- end-enddiff --git a/db/migrate/20211117195121_remove_destroyed_help_texts.rb b/db/migrate/20211117195121_remove_destroyed_help_texts.rbdeleted file mode 100644index 68eaca89ba1..00000000000--- a/db/migrate/20211117195121_remove_destroyed_help_texts.rb+++ /dev/null@@ -1,44 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RemoveDestroyedHelpTexts < ActiveRecord::Migration[6.1]- def up- execute <<~SQL- DELETE FROM attribute_help_texts- WHERE attribute_name LIKE 'custom_field_%'- AND attribute_name NOT IN (- SELECT CONCAT('custom_field_', id)- FROM custom_fields- )- SQL- end-- def down- # Nothing to do- end-enddiff --git a/db/migrate/20211118203332_clean_hide_mail.rb b/db/migrate/20211118203332_clean_hide_mail.rbdeleted file mode 100644index 134cf2a6aec..00000000000--- a/db/migrate/20211118203332_clean_hide_mail.rb+++ /dev/null@@ -1,47 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class CleanHideMail < ActiveRecord::Migration[6.1]- def up- execute <<~SQL.squish- UPDATE user_preferences- SET settings = settings - 'hide_mail' || '{"hide_mail": false}'- WHERE settings ->> 'hide_mail' = '0'- SQL-- execute <<~SQL.squish- UPDATE user_preferences- SET settings = settings - 'hide_mail' || '{"hide_mail": true}'- WHERE settings ->> 'hide_mail' = '1'- SQL- end-- def down- # Nothing to do- end-enddiff --git a/db/migrate/20211209092519_query_views.rb b/db/migrate/20211209092519_query_views.rbdeleted file mode 100644index 3d8490e3f04..00000000000--- a/db/migrate/20211209092519_query_views.rb+++ /dev/null@@ -1,143 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class QueryViews < ActiveRecord::Migration[6.1]- def up- add_column :queries,- :starred,- :boolean,- default: false-- # Some older queries seem to lack values for created_at and updated_at. Taking NOW which is better than NULL.- execute <<~SQL.squish- UPDATE- queries- SET- created_at = NOW()- WHERE- created_at IS NULL- SQL-- execute <<~SQL.squish- UPDATE- queries- SET- updated_at = NOW()- WHERE- updated_at IS NULL- SQL-- execute <<~SQL.squish- INSERT INTO- views (- type,- query_id,- created_at,- updated_at- )- SELECT- 'work_packages_table',- id,- created_at,- updated_at- FROM queries- WHERE- hidden = false- SQL-- execute <<~SQL.squish- UPDATE- queries- SET- starred = true- WHERE- id IN (SELECT navigatable_id FROM menu_items WHERE type = 'MenuItems::QueryMenuItem')- SQL-- execute <<~SQL.squish- DELETE FROM- menu_items- WHERE- type = 'MenuItems::QueryMenuItem'- SQL-- remove_column :queries,- :hidden-- rename_column :queries,- :is_public,- :public- end-- def down- rename_column :queries,- :public,- :is_public-- add_column :queries,- :hidden,- :boolean,- default: false-- # Consciously avoiding the use of a PostgreSQL 13.0 feature (gen_random_uuid())- Query.where(starred: true).find_each do |query|- execute <<~SQL.squish- INSERT INTO- menu_items (- type,- navigatable_id,- name,- title- ) VALUES (- 'MenuItems::QueryMenuItem',- #{query.id},- '#{SecureRandom.uuid}',- '#{query.name}'- )- SQL- end-- execute <<~SQL.squish- UPDATE- queries- SET- hidden = true- WHERE- id NOT IN (SELECT query_id FROM views WHERE type = 'work_packages_table')- SQL-- execute <<~SQL.squish- DELETE FROM- views- WHERE type = 'work_packages_table'- SQL-- remove_column :queries,- :starred- end-enddiff --git a/db/migrate/20220106145037_fix_missing_notification_settings.rb b/db/migrate/20220106145037_fix_missing_notification_settings.rbdeleted file mode 100644index 17fa1341557..00000000000--- a/db/migrate/20220106145037_fix_missing_notification_settings.rb+++ /dev/null@@ -1,47 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class FixMissingNotificationSettings < ActiveRecord::Migration[6.1]- def up- execute <<~SQL.squish- INSERT INTO- notification_settings- (user_id, watched, involved, mentioned)- SELECT- u.id, true, true, true- FROM- users u- WHERE type = 'User'- AND NOT EXISTS (SELECT * FROM notification_settings ns WHERE ns.user_id = u.id)- SQL- end-- def down- # No data to revert- end-enddiff --git a/db/migrate/20220202140507_reorder_project_children.rb b/db/migrate/20220202140507_reorder_project_children.rbdeleted file mode 100644index 42d8fd4837f..00000000000--- a/db/migrate/20220202140507_reorder_project_children.rb+++ /dev/null@@ -1,80 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class ReorderProjectChildren < ActiveRecord::Migration[6.1]- class ProjectMigration < ApplicationRecord- include ::Projects::Hierarchy- self.table_name = "projects"- end-- def up- Rails.logger.info { "Resorting siblings by name in the project's nested set." }- ProjectMigration.transaction { reorder! }- end-- def down- # Nothing to do- end-- private-- def reorder!- # Reorder the project roots- reorder_siblings ProjectMigration.roots-- # Reorder every project hierarchy- ProjectMigration- .where(id: unique_parent_ids)- .find_each { |project| reorder_siblings(project.children) }- end-- def unique_parent_ids- ProjectMigration- .where.not(parent_id: nil)- .select(:parent_id)- .distinct- end-- def reorder_siblings(siblings)- return unless siblings.many?-- # Resort children manually- sorted = siblings.sort_by { |project| project.name.downcase }-- # Get the current first child- first = siblings.first-- sorted.each_with_index do |child, i|- if i == 0- child.move_to_left_of(first) unless child == first- else- child.move_to_right_of(sorted[i - 1])- end- end- end-enddiff --git a/db/migrate/20220223095355_projects_lft_rgt_index.rb b/db/migrate/20220223095355_projects_lft_rgt_index.rbdeleted file mode 100644index 0b397a7149b..00000000000--- a/db/migrate/20220223095355_projects_lft_rgt_index.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class ProjectsLftRgtIndex < ActiveRecord::Migration[6.1]- def change- add_index :projects, %i[lft rgt]- end-enddiff --git a/db/migrate/20220302123642_assignable_to_permission.rb b/db/migrate/20220302123642_assignable_to_permission.rbdeleted file mode 100644index c07c45daeb3..00000000000--- a/db/migrate/20220302123642_assignable_to_permission.rb+++ /dev/null@@ -1,58 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AssignableToPermission < ActiveRecord::Migration[6.1]- def up- # Because of a missing dependent: :destroy, some role_permission- # for removed roles exist.- execute <<~SQL.squish- DELETE FROM role_permissions WHERE role_id IS NULL- SQL-- execute <<~SQL.squish- INSERT INTO role_permissions (role_id, permission, created_at, updated_at)- SELECT id role_id, 'work_package_assigned' permission, NOW() created_at, NOW() updated_at FROM roles- WHERE assignable AND type = 'Role' AND builtin = 0- SQL-- remove_column :roles, :assignable- end-- def down- add_column :roles, :assignable, :boolean, default: true-- execute <<~SQL.squish- UPDATE roles- SET assignable = EXISTS(SELECT 1 from role_permissions WHERE permission = 'work_package_assigned' and role_id = roles.id)- SQL-- execute <<~SQL.squish- DELETE FROM role_permissions where permission = 'work_package_assigned'- SQL- end-enddiff --git a/db/migrate/20220319211253_add_parent_id_to_wp.rb b/db/migrate/20220319211253_add_parent_id_to_wp.rbdeleted file mode 100644index 303eb5721b2..00000000000--- a/db/migrate/20220319211253_add_parent_id_to_wp.rb+++ /dev/null@@ -1,273 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddParentIdToWp < ActiveRecord::Migration[6.1]- RELATION_TYPES = %i[relates duplicates blocks follows includes requires hierarchy].freeze-- def up- migrate_parent_information-- add_relation_type-- add_relation_index-- add_closure_tree_table-- build_closure_tree-- cleanup_transitive_relations-- remove_typed_dag_columns- end-- def down- add_relation_type_column-- update_relation_column_from_relation_type-- insert_hierarchy_relation_for_parent-- remove_closure_tree-- remove_closure_tree_columns_on_foreign_tables-- build_typed_dag- end-- private-- def migrate_parent_information- add_column :work_packages, :parent_id, :integer, null: true-- add_parent_index-- execute <<~SQL.squish- UPDATE- work_packages- SET- parent_id = from_id- FROM relations- WHERE- hierarchy = 1- AND relates = 0- AND duplicates = 0- AND blocks = 0- AND follows = 0- AND includes = 0- AND requires = 0- AND work_packages.id = relations.to_id- SQL-- execute <<~SQL.squish- DELETE- FROM- relations- WHERE- hierarchy = 1- AND #{(RELATION_TYPES - [:hierarchy]).join(' = 0 AND ')} = 0- SQL- end-- def add_relation_type- add_column :relations, :relation_type, :string-- (RELATION_TYPES - [:hierarchy]).each do |type|- execute <<~SQL.squish- UPDATE- relations- SET- relation_type = '#{type}'- WHERE- #{type} = 1- AND #{(RELATION_TYPES - [type]).join(' = 0 AND ')} = 0- SQL- end- end-- def add_closure_tree_table- # Copied from closure tree migration- create_table :work_package_hierarchies, id: false do |t|- t.integer :ancestor_id, null: false- t.integer :descendant_id, null: false- t.integer :generations, null: false- end-- add_index :work_package_hierarchies, %i[ancestor_id descendant_id generations],- unique: true,- name: "work_package_anc_desc_idx"-- add_index :work_package_hierarchies, [:descendant_id],- name: "work_package_desc_idx"- # End copied from closure tree migration- end-- # Creates the actual closure tree data.- # This recursive query is used over ClosureTreeWorkPackage.rebuild! for speed- # but its result is equivalent.- def build_closure_tree- execute <<~SQL.squish- WITH RECURSIVE closure_tree(ancestor_id, descendant_id, generations) AS (- SELECT- id ancestor_id,- id descendant_id,- 0 generations- FROM work_packages- UNION- SELECT- closure_tree.ancestor_id,- work_packages.id descendant_id,- closure_tree.generations + 1- FROM closure_tree- JOIN work_packages ON work_packages.parent_id = closure_tree.descendant_id- )-- INSERT INTO- work_package_hierarchies (- ancestor_id,- descendant_id,- generations- )- SELECT- ancestor_id,- descendant_id,- generations- FROM- closure_tree- SQL- end-- def add_relation_index- add_index :relations, %i[from_id to_id relation_type],- unique: true- add_index :relations, %i[to_id from_id relation_type],- unique: true- end-- def add_parent_index- add_index :work_packages, :parent_id- end-- def add_relation_type_column- change_table :relations do |r|- RELATION_TYPES.each do |column|- r.column column, :integer, default: 0, null: false- end- end- end-- def cleanup_transitive_relations- execute <<~SQL.squish- DELETE- FROM- relations- WHERE- #{RELATION_TYPES.join(' + ')} != 1- SQL- end-- def remove_typed_dag_columns- RELATION_TYPES.each do |type|- remove_column :relations, type- end-- remove_column :relations, :count- end-- def update_relation_column_from_relation_type- ActiveRecord::Base.connection.execute <<-SQL.squish- UPDATE- relations- SET- relates = CASE- WHEN relations.relation_type = 'relates'- THEN 1- ELSE 0- END,- duplicates = CASE- WHEN relations.relation_type = 'duplicates'- THEN 1- ELSE 0- END,- blocks = CASE- WHEN relations.relation_type = 'blocks'- THEN 1- ELSE 0- END,- follows = CASE- WHEN relations.relation_type = 'precedes'- THEN 1- ELSE 0- END,- includes = CASE- WHEN relations.relation_type = 'includes'- THEN 1- ELSE 0- END,- requires = CASE- WHEN relations.relation_type = 'requires'- THEN 1- ELSE 0- END- SQL- end-- def remove_closure_tree- drop_table :work_package_hierarchies- end-- def remove_closure_tree_columns_on_foreign_tables- remove_column :relations, :relation_type-- remove_column :work_packages, :parent_id- end-- def build_typed_dag- require_relative "20180105130053_rebuild_dag"-- ::RebuildDag.new.up- end-- def insert_hierarchy_relation_for_parent- ActiveRecord::Base.connection.execute <<-SQL.squish- INSERT INTO relations- (from_id, to_id, hierarchy)- SELECT w1.id, w2.id, 1- FROM work_packages w1- JOIN work_packages w2- ON w1.id = w2.parent_id- SQL- end-- # rubocop:disable Rails/ApplicationRecord- class ClosureTreeWorkPackage < ActiveRecord::Base- self.table_name = "work_packages"-- has_closure_tree- end- # rubocop:enable Rails/ApplicationRecord-enddiff --git a/db/migrate/20220323083000_add_include_subprojects_to_query.rb b/db/migrate/20220323083000_add_include_subprojects_to_query.rbdeleted file mode 100644index a69b78b4708..00000000000--- a/db/migrate/20220323083000_add_include_subprojects_to_query.rb+++ /dev/null@@ -1,42 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddIncludeSubprojectsToQuery < ActiveRecord::Migration[6.1]- def change- add_column :queries,- :include_subprojects,- :boolean,- null: false,- default: Setting.display_subprojects_work_packages?-- # Remove the default now- reversible do |dir|- dir.up { change_column_default :queries, :include_subprojects, nil }- end- end-enddiff --git a/db/migrate/20220408080838_bigint_primary_key_on_relations.rb b/db/migrate/20220408080838_bigint_primary_key_on_relations.rbdeleted file mode 100644index 4518de6f274..00000000000--- a/db/migrate/20220408080838_bigint_primary_key_on_relations.rb+++ /dev/null@@ -1,44 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class BigintPrimaryKeyOnRelations < ActiveRecord::Migration[6.1]- def up- unless OpenProject::Database.version_matches?(100000)- version = OpenProject::Database.version- raise "This migration requires a PostgreSQL server version of at least 10.0, found #{version}"- end-- execute <<~SQL.squish- ALTER SEQUENCE relations_id_seq AS bigint;- SQL- end-- def down- # nothing to do- end-enddiff --git a/db/migrate/20220414085531_migrate_team_planner_permissions.rb b/db/migrate/20220414085531_migrate_team_planner_permissions.rbdeleted file mode 100644index 782c4e26cb2..00000000000--- a/db/migrate/20220414085531_migrate_team_planner_permissions.rb+++ /dev/null@@ -1,70 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class MigrateTeamPlannerPermissions < ActiveRecord::Migration[6.1]- def up- # Add view_team_planner role if a role already has the view_work_packages permission- execute <<~SQL.squish- INSERT INTO- role_permissions- (role_id, permission, created_at, updated_at)- SELECT- role_permissions.role_id, 'view_team_planner', NOW(), NOW()- FROM- role_permissions- GROUP BY role_permissions.role_id- HAVING- ARRAY_AGG(role_permissions.permission)::text[] @> ARRAY['view_work_packages']- AND- NOT ARRAY_AGG(role_permissions.permission)::text[] @> ARRAY['view_team_planner'];- SQL-- # Add manage_team_planner if a role already has- # the view_team_planner (which in turn means the view_work_packages permission),- # add_work_packages, edit_work_packages, save_queries and manage_public_queries permission- execute <<~SQL.squish- INSERT INTO- role_permissions- (role_id, permission, created_at, updated_at)- SELECT- role_permissions.role_id, 'manage_team_planner', NOW(), NOW()- FROM- role_permissions- GROUP BY role_permissions.role_id- HAVING- ARRAY_AGG(role_permissions.permission)::text[] @>- ARRAY['view_work_packages', 'add_work_packages', 'edit_work_packages', 'save_queries', 'manage_public_queries']- AND- NOT ARRAY_AGG(role_permissions.permission)::text[] @> ARRAY['manage_team_planner']- SQL- end-- def down- # Nothing to do- end-enddiff --git a/db/migrate/20220426132637_refix_inherited_group_member_roles.rb b/db/migrate/20220426132637_refix_inherited_group_member_roles.rbdeleted file mode 100644index b40fa538b72..00000000000--- a/db/migrate/20220426132637_refix_inherited_group_member_roles.rb+++ /dev/null@@ -1,42 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RefixInheritedGroupMemberRoles < ActiveRecord::Migration[6.1]- def up- # When the FixInheritedGroupMemberRoles ran initially, Members- # where the MemberRoles were inherited from more than one Group where- # applied incorrectly. Only the MemberRoles of the last Group where kept.- require Rails.root.join("db/migrate/20200625133727_fix_inherited_group_member_roles.rb")-- # created_on has been renamed to created_at- Member.reset_column_information- Principal.reset_column_information-- FixInheritedGroupMemberRoles.new.up- end-enddiff --git a/db/migrate/20220428071221_restore_defaults_on_empty_settings.rb b/db/migrate/20220428071221_restore_defaults_on_empty_settings.rbdeleted file mode 100644index 4d00b53022f..00000000000--- a/db/migrate/20220428071221_restore_defaults_on_empty_settings.rb+++ /dev/null@@ -1,54 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RestoreDefaultsOnEmptySettings < ActiveRecord::Migration[6.1]- def up- settings = Setting.where(value: "")-- settings.find_each do |setting|- definition = Settings::Definition[setting.name]-- if definition.nil?- warn "Did not find definition for #{setting.name}. This setting is probably outdated an can be removed."- next- end-- next if definition.value == ""-- if definition.writable?- setting.update_attribute(:value, definition.value)- else- setting.destroy- end- end- end-- def down- # Nothing to do- end-enddiff --git a/db/migrate/20220503093844_create_oauth_client.rb b/db/migrate/20220503093844_create_oauth_client.rbdeleted file mode 100644index 319b83b2765..00000000000--- a/db/migrate/20220503093844_create_oauth_client.rb+++ /dev/null@@ -1,40 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class CreateOAuthClient < ActiveRecord::Migration[6.1]- def change- create_table :oauth_clients do |t|- t.string :client_id, null: false- t.string :client_secret, null: false- t.references :integration,- polymorphic: true, index: { unique: true }, null: false-- t.timestamps- end- end-enddiff --git a/db/migrate/20220511124930_create_week_days.rb b/db/migrate/20220511124930_create_week_days.rbdeleted file mode 100644index 0dd0df3e0cd..00000000000--- a/db/migrate/20220511124930_create_week_days.rb+++ /dev/null@@ -1,49 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class CreateWeekDays < ActiveRecord::Migration[6.1]- def up- create_table :week_days do |t|- t.integer :day, null: false- t.boolean :working, null: false, default: true-- t.timestamps- end-- execute <<-SQL.squish- ALTER TABLE week_days- ADD CONSTRAINT unique_day_number UNIQUE (day);- ALTER TABLE week_days- ADD CHECK (day >= 1 AND day <=7);- SQL- end-- def down- drop_table :week_days- end-enddiff --git a/db/migrate/20220517113828_create_non_working_days.rb b/db/migrate/20220517113828_create_non_working_days.rbdeleted file mode 100644index 3c1fe3ea5cf..00000000000--- a/db/migrate/20220517113828_create_non_working_days.rb+++ /dev/null@@ -1,39 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class CreateNonWorkingDays < ActiveRecord::Migration[6.1]- def change- create_table :non_working_days do |t|- t.string :name, null: false- t.date :date, null: false-- t.timestamps- end- add_index :non_working_days, :date, unique: true- end-enddiff --git a/db/migrate/20220525154549_add_duration_to_work_packages.rb b/db/migrate/20220525154549_add_duration_to_work_packages.rbdeleted file mode 100644index 8d2bb12fde6..00000000000--- a/db/migrate/20220525154549_add_duration_to_work_packages.rb+++ /dev/null@@ -1,58 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddDurationToWorkPackages < ActiveRecord::Migration[6.1]- def change- add_column :work_packages, :duration, :integer-- add_column :work_package_journals, :duration, :integer-- reversible do |dir|- dir.up do- set_duration(:work_packages)- set_duration(:work_package_journals)- end- end- end-- private-- def set_duration(table)- execute <<~SQL.squish- UPDATE- #{table}- SET- duration = CASE- WHEN start_date IS NULL OR due_date IS NULL- THEN 1- ELSE- due_date - start_date + 1- END- SQL- end-enddiff --git a/db/migrate/20220608213712_add_logged_by_id_to_time_entries.rb b/db/migrate/20220608213712_add_logged_by_id_to_time_entries.rbdeleted file mode 100644index 57f8491a8dd..00000000000--- a/db/migrate/20220608213712_add_logged_by_id_to_time_entries.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddLoggedByIdToTimeEntries < ActiveRecord::Migration[7.0]- def change- add_reference :time_entries, :logged_by, foreign_key: { to_table: :users }, index: true- end-enddiff --git a/db/migrate/20220614132200_add_ignore_non_working_days_to_work_packages.rb b/db/migrate/20220614132200_add_ignore_non_working_days_to_work_packages.rbdeleted file mode 100644index d3f18593fea..00000000000--- a/db/migrate/20220614132200_add_ignore_non_working_days_to_work_packages.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddIgnoreNonWorkingDaysToWorkPackages < ActiveRecord::Migration[7.0]- def change- add_column :work_packages, :ignore_non_working_days, :boolean, default: true, null: false- end-enddiff --git a/db/migrate/20220615213015_migrate_log_time_to_log_own_time_in_role_permissions.rb b/db/migrate/20220615213015_migrate_log_time_to_log_own_time_in_role_permissions.rbdeleted file mode 100644index fab80d642cd..00000000000--- a/db/migrate/20220615213015_migrate_log_time_to_log_own_time_in_role_permissions.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class MigrateLogTimeToLogOwnTimeInRolePermissions < ActiveRecord::Migration[7.0]- def change- RolePermission.where(permission: "log_time").update_all(permission: "log_own_time")- end-enddiff --git a/db/migrate/20220620132922_change_duration_default_value.rb b/db/migrate/20220620132922_change_duration_default_value.rbdeleted file mode 100644index ff35c83a612..00000000000--- a/db/migrate/20220620132922_change_duration_default_value.rb+++ /dev/null@@ -1,50 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class ChangeDurationDefaultValue < ActiveRecord::Migration[7.0]- def up- set_duration(:work_packages)- set_duration(:work_package_journals)- end-- private-- def set_duration(table)- execute <<~SQL.squish- UPDATE- #{table}- SET- duration = CASE- WHEN start_date IS NULL OR due_date IS NULL- THEN NULL- ELSE- due_date - start_date + 1- END- SQL- end-enddiff --git a/db/migrate/20220622151721_drop_project_associations.rb b/db/migrate/20220622151721_drop_project_associations.rbdeleted file mode 100644index fe073bd551c..00000000000--- a/db/migrate/20220622151721_drop_project_associations.rb+++ /dev/null@@ -1,40 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class DropProjectAssociations < ActiveRecord::Migration[7.0]- def change- drop_table :project_associations do |t|- t.belongs_to :project_a, type: :int- t.belongs_to :project_b, type: :int-- t.column :description, :text-- t.timestamps null: true- end- end-enddiff --git a/db/migrate/20220629073727_add_polymorphic_integration_to_oauth_application.rb b/db/migrate/20220629073727_add_polymorphic_integration_to_oauth_application.rbdeleted file mode 100644index 65cb2b85c31..00000000000--- a/db/migrate/20220629073727_add_polymorphic_integration_to_oauth_application.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddPolymorphicIntegrationToOAuthApplication < ActiveRecord::Migration[7.0]- def change- add_reference :oauth_applications, :integration, polymorphic: true- end-enddiff --git a/db/migrate/20220707192304_backfill_time_entries_with_logged_by_id.rb b/db/migrate/20220707192304_backfill_time_entries_with_logged_by_id.rbdeleted file mode 100644index a3d459d0945..00000000000--- a/db/migrate/20220707192304_backfill_time_entries_with_logged_by_id.rb+++ /dev/null@@ -1,41 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class BackfillTimeEntriesWithLoggedById < ActiveRecord::Migration[7.0]- def up- TimeEntry- .where.not(user_id: User.select(:id))- .update_all(user_id: DeletedUser.first.id)-- TimeEntry.all.update_all("logged_by_id = user_id")- end-- def down- # Nothing to do- end-enddiff --git a/db/migrate/20220712132505_add_foreign_key_constraint_for_type_color_id.rb b/db/migrate/20220712132505_add_foreign_key_constraint_for_type_color_id.rbdeleted file mode 100644index fbfcefdb8aa..00000000000--- a/db/migrate/20220712132505_add_foreign_key_constraint_for_type_color_id.rb+++ /dev/null@@ -1,49 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddForeignKeyConstraintForTypeColorId < ActiveRecord::Migration[7.0]- def change- # nullify invalid color references- reversible do |dir|- dir.up do- execute <<~SQL.squish- UPDATE types- SET color_id = NULL- WHERE types.color_id IS NOT NULL- AND NOT EXISTS (- SELECT 1- FROM colors- WHERE colors.id = types.color_id- )- SQL- end- end-- add_foreign_key :types, :colors, on_delete: :nullify- end-enddiff --git a/db/migrate/20220714145356_migrate_work_package_export_settings.rb b/db/migrate/20220714145356_migrate_work_package_export_settings.rbdeleted file mode 100644index b7e6d473f1e..00000000000--- a/db/migrate/20220714145356_migrate_work_package_export_settings.rb+++ /dev/null@@ -1,43 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class MigrateWorkPackageExportSettings < ActiveRecord::Migration[7.0]- def up- execute <<~SQL.squish- UPDATE settings SET name = 'work_packages_projects_export_limit'- WHERE name = 'work_packages_export_limit'- SQL- end-- def down- execute <<~SQL.squish- UPDATE settings SET name = 'work_packages_export_limit'- WHERE name = 'work_packages_projects_export_limit'- SQL- end-enddiff --git a/db/migrate/20220804112533_remove_notification_cleanup_job.rb b/db/migrate/20220804112533_remove_notification_cleanup_job.rbdeleted file mode 100644index 5468cee458f..00000000000--- a/db/migrate/20220804112533_remove_notification_cleanup_job.rb+++ /dev/null@@ -1,36 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RemoveNotificationCleanupJob < ActiveRecord::Migration[7.0]- def up- execute("DELETE FROM delayed_jobs WHERE handler LIKE '%job_class: Notifications::CleanupJob%'")- Setting- .where(name: "notification_retention_period_days")- .delete_all- end-enddiff --git a/db/migrate/20220811061024_rename_work_package_export_limit.rb b/db/migrate/20220811061024_rename_work_package_export_limit.rbdeleted file mode 100644index 31aea4c2cb3..00000000000--- a/db/migrate/20220811061024_rename_work_package_export_limit.rb+++ /dev/null@@ -1,47 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RenameWorkPackageExportLimit < ActiveRecord::Migration[7.0]- def up- if Setting.where(name: "work_packages_projects_export_limit").exists? # rubocop:disable Rails/WhereExists- Setting- .where(name: "work_packages_export_limit")- .delete_all- else- Setting- .where(name: "work_packages_export_limit")- .update_all(name: "work_packages_projects_export_limit")- end- end-- def down- Setting- .where(name: "work_packages_projects_export_limit")- .update_all(name: "work_packages_export_limit")- end-enddiff --git a/db/migrate/20220815072420_add_logged_by_to_time_entries_journals.rb b/db/migrate/20220815072420_add_logged_by_to_time_entries_journals.rbdeleted file mode 100644index 05bd07687b2..00000000000--- a/db/migrate/20220815072420_add_logged_by_to_time_entries_journals.rb+++ /dev/null@@ -1,49 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddLoggedByToTimeEntriesJournals < ActiveRecord::Migration[7.0]- def change- add_reference :time_entry_journals, :logged_by, foreign_key: { to_table: :users }, index: true-- reversible do |change|- change.up do- Journal::TimeEntryJournal- .where.not(user_id: User.select(:id))- .update_all(user_id: DeletedUser.first.id)-- execute <<~SQL.squish- UPDATE time_entry_journals- SET logged_by_id = user_id- SQL- end- end-- change_column_null :time_entries, :logged_by_id, false- change_column_null :time_entry_journals, :logged_by_id, false- end-enddiff --git a/db/migrate/20220817154403_remove_work_packages_duration_field_active_setting.rb b/db/migrate/20220817154403_remove_work_packages_duration_field_active_setting.rbdeleted file mode 100644index 2b8c77481df..00000000000--- a/db/migrate/20220817154403_remove_work_packages_duration_field_active_setting.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RemoveWorkPackagesDurationFieldActiveSetting < ActiveRecord::Migration[7.0]- def change- Setting.where(name: "work_packages_duration_field_active").destroy_all- end-enddiff --git a/db/migrate/20220818074150_fix_invalid_journals.rb b/db/migrate/20220818074150_fix_invalid_journals.rbdeleted file mode 100644index 2d1e65becd5..00000000000--- a/db/migrate/20220818074150_fix_invalid_journals.rb+++ /dev/null@@ -1,75 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class FixInvalidJournals < ActiveRecord::Migration[7.0]- def up- get_broken_journals.each do |journable_type, relation|- next unless relation.any?-- # rubocop:disable Rails/Output- puts "Cleaning up broken journals on #{journable_type}"- # rubocop:enable Rails/Output- destroy_journals(relation)- end- end-- def down- # nothing to do- end-- def destroy_journals(journals)- journal_ids = journals.pluck(:id)-- Journal::AttachableJournal.where(journal_id: journal_ids).delete_all- Journal::CustomizableJournal.where(journal_id: journal_ids).delete_all-- journals.delete_all-- # We delete manually the related journals here rather than- # relying on .destroy. This is because in the future (from- # the migration's perspective) new such journals may appear- # which do not yet exist at the point of this migration.- #- # This is to avoid errors such as the following:- # PG::UndefinedTable: ERROR: relation "storages_file_links_journals" does not exist- # LINE 9: WHERE a.attrelid = '"storages_file_links_journals"'::regcla...- end-- def get_broken_journals- Journal- .pluck("DISTINCT(journable_type)")- .compact- .to_h do |journable_type|- relation = Journal- .where(journable_type:)- .where.not(data_type: "Journal::#{journable_type}Journal")-- [journable_type, relation]- end- end-enddiff --git a/db/migrate/20220818074159_fix_deleted_data_journals.rb b/db/migrate/20220818074159_fix_deleted_data_journals.rbdeleted file mode 100644index a33d8d6a278..00000000000--- a/db/migrate/20220818074159_fix_deleted_data_journals.rb+++ /dev/null@@ -1,201 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class FixDeletedDataJournals < ActiveRecord::Migration[7.0]- def up- get_missing_journals.each do |journable_type, relation|- Rails.logger.debug { "Cleaning up journals on #{journable_type}" }-- if unmigratable_journal_classes.key?(journable_type) && relation.count > 0- raise <<~ERROR- We have found missing journal entries for the #{journable_type} model.-- Unfortunately, you cannot update directly to OpenProject #{OpenProject::VERSION.to_semver},- as subsequent migrations are not yet processed for this model.-- To fix this issue, please try one of these options:-- Upgrade first to Openproject 13.0.0, and then to this version.-- ------ Skip this migration by connecting to the database, and running the following SQL command:-- INSERT INTO schema_migrations (version) VALUES (20220818074159);-- Then, run this migration step again. It will skip this migration.-- Once migrated, remove this migration entry again by running this SQL command:-- DELETE FROM schema_migrations WHERE version='20220818074159';-- Then, run this migration step again. Only this skipped migration will be performed.- ERROR- end-- relation.find_each { |journal| fix_journal_data(journal) }-- count = relation.count- unfixed_journals_found(journable_type, relation, count) if count > 0- end- end-- def down- # nothing to do- end-- def unfixed_journals_found(journable_type, relation, count)- unless ENV["SKIP_MISSING_JOURNALS"] == "true"- warning = <<~WARNING- There shouldn't be any missing data left for #{journable_type}, but found #{count}.-- You can choose to ignore this error by setting the environment variable `SKIP_MISSING_JOURNALS=true`- and re-run the migration / configure step.-- This will allow the migration to continue and print the affected journals.- Please report them to this bug ticket in our community: https://community.openproject.org/wp/43839-- Aborting the migration at this point.- WARNING-- raise warning- end-- warning = ["SKIP_MISSING_JOURNALS was set to true."]- warning << "Please add the following output to the bug ticket in our community: https://community.openproject.org/wp/43839"-- warning << "--- BEGIN ---"- relation.find_each do |journal|- warning << "Journal -> #{journal.inspect}"- warning << "Journable? -> #{journal.journable.inspect}"- warning << "Predecessor? -> #{journal.previous.inspect}"- warning << "Successor? -> #{journal.successor.inspect}"- end-- warning << "--- END ---"- warn warning.join("\n")- end-- def fix_journal_data(journal)- # Best case, no successor- # restore data from work package itself- if journal.successor.nil?- raise "Previous also has data nil" if journal.previous && journal.previous.data.nil?-- insert_journal_data(journal, write_message: false)- elsif (predecessor = journal.previous)- # Case 2, we do have a predecessor- take_over_from_source(journal, predecessor)- elsif journal.successor- # Case 3, We are the first, but have a successor- # Look for data in the successor- take_over_from_successor(journal)- else- raise "This should not happen for #{journal.inspect}"- end- end-- def insert_journal_data(journal, write_message: false)- service = Journals::CreateService.new(journal.journable, User.system)- insert_sql = service.instance_eval { insert_data_sql("placeholder", nil) }-- result = Journal.connection.uncached do- ::Journal- .connection- .select_one(insert_sql)- end-- raise "ID is missing #{result.inspect}" unless result["id"]-- if write_message- update_with_new_data!(journal, result["id"])- else- journal.update_column(:data_id, result["id"])- end- end-- def get_missing_journals- Journal- .pluck("DISTINCT(journable_type)")- .to_h do |journable_type|- journal_class, table_name = lookup_journal_class_table(journable_type)- relation = Journal- .joins("LEFT OUTER JOIN #{table_name} ON journals.data_type = '#{journal_class}' AND #{table_name}.id = journals.data_id")- .where("#{table_name}.id IS NULL")- .where(journable_type:)- .where.not(data_type: nil) # Ignore special tenants with data_type nil errors- .order("journals.version ASC")- .includes(:journable)-- [journable_type, relation]- end- end-- # Lookup table for items that were already deleted- def lookup_journal_class_table(journable_type)- unmigratable_journal_classes.fetch(journable_type) do- journal_class = journable_type.constantize.journal_class- [journal_class.to_s, journal_class.table_name]- end- end-- def unmigratable_journal_classes- {- "WikiContent" => %w[Journal::WikiContentJournal wiki_content_journals]- }- end-- def take_over_from_successor(journal)- # The successors may also have their data deleted.- # in this case, look for the first journal with data. If non can be found, instantiate from the journaled object.- first_journal_with_data = journal.journable.journals.detect { |j| j.data.present? }-- if first_journal_with_data.nil?- insert_journal_data(journal, write_message: true)- else- take_over_from_source(journal, first_journal_with_data)- end- end-- def take_over_from_source(journal, source)- raise "Related journal does not have data, this shouldn't be!" if source.data.nil?-- new_data = source.data.dup- new_data.save!-- update_with_new_data!(journal, new_data.id)- end-- def update_with_new_data!(journal, data_id)- notes = journal.notes || ""- notes << "\n" unless notes.empty?- notes << "_(This activity had to be modified by the system and may be missing some changes or contain changes from previous or following activities.)_"-- journal.update_columns(notes:, data_id:)- end-enddiff --git a/db/migrate/20220830074821_add_ignore_non_working_days_to_work_package_journals.rb b/db/migrate/20220830074821_add_ignore_non_working_days_to_work_package_journals.rbdeleted file mode 100644index 5e081bbfd81..00000000000--- a/db/migrate/20220830074821_add_ignore_non_working_days_to_work_package_journals.rb+++ /dev/null@@ -1,43 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddIgnoreNonWorkingDaysToWorkPackageJournals < ActiveRecord::Migration[7.0]- def change- add_column :work_package_journals, :ignore_non_working_days, :boolean-- reversible do |dir|- dir.up do- execute <<~SQL.squish- UPDATE work_package_journals SET ignore_non_working_days = TRUE- SQL- end- end-- change_column_null :work_package_journals, :ignore_non_working_days, false- end-enddiff --git a/db/migrate/20220830092057_change_default_for_non_working_days.rb b/db/migrate/20220830092057_change_default_for_non_working_days.rbdeleted file mode 100644index 9752a0c6507..00000000000--- a/db/migrate/20220830092057_change_default_for_non_working_days.rb+++ /dev/null@@ -1,41 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class ChangeDefaultForNonWorkingDays < ActiveRecord::Migration[7.0]- def change- change_column_default :work_packages, :ignore_non_working_days, from: true, to: false-- reversible do |dir|- dir.up do- execute <<~SQL.squish- UPDATE work_packages SET ignore_non_working_days = TRUE- SQL- end- end- end-enddiff --git a/db/migrate/20220831073113_work_package_project_foreign_key.rb b/db/migrate/20220831073113_work_package_project_foreign_key.rbdeleted file mode 100644index 87d5f9b8f64..00000000000--- a/db/migrate/20220831073113_work_package_project_foreign_key.rb+++ /dev/null@@ -1,61 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class WorkPackageProjectForeignKey < ActiveRecord::Migration[7.0]- # Note: rails 7.1 breaks the class' ancestor chain, and raises an error, when a class- # with an enum definition without a database field is being referenced.- # Re-defining the Project class without the enum to avoid the issue.- class Project < ApplicationRecord; end-- def change- reversible do |dir|- dir.up do- cleanup_invalid_work_packages- end- end-- add_foreign_key :work_packages, :projects- end-- private-- def cleanup_invalid_work_packages- WorkPackage- .where.not(project_id: Project.select(:id))- .find_each do |work_package|- WorkPackages::DeleteService- .new(user: User.system, model: work_package)- .call- .on_success { Rails.logger.info "Deleted stale work package #{work_package.inspect}" }- .on_failure { Rails.logger.error "Failed to delete stale work package #{work_package.inspect}" }- rescue ::ActiveRecord::RecordNotFound- # raised by #reload if work package no longer exists- # nothing to do, work package was already deleted (eg. by a parent)- end- end-enddiff --git a/db/migrate/20220831081937_migrate_timestamps_to_with_timezone.rb b/db/migrate/20220831081937_migrate_timestamps_to_with_timezone.rbdeleted file mode 100644index 97506f3c9ce..00000000000--- a/db/migrate/20220831081937_migrate_timestamps_to_with_timezone.rb+++ /dev/null@@ -1,77 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class MigrateTimestampsToWithTimezone < ActiveRecord::Migration[7.0]- def up- migrate_to_timestampz- end-- def down- migrate_to_timestamp- end-- private-- def migrate_to_timestampz- execute <<~SQL.squish- DO $$- DECLARE- t record;- BEGIN- FOR t IN- SELECT column_name, table_name, data_type- FROM information_schema.columns- WHERE- table_schema = ANY (SELECT unnest(string_to_array(replace(setting, '"$user"', CURRENT_USER), ', ')) FROM pg_settings WHERE name = 'search_path')- AND data_type = 'timestamp without time zone'- LOOP- EXECUTE 'ALTER TABLE ' || t.table_name || ' ALTER COLUMN ' || t.column_name || ' TYPE timestamp with time zone USING ' || t.column_name || ' AT TIME ZONE ''UTC''';- END LOOP;- END$$;- SQL- end-- def migrate_to_timestamp- execute <<~SQL.squish- DO $$- DECLARE- t record;- BEGIN- FOR t IN- SELECT column_name, table_name, data_type- FROM information_schema.columns- WHERE- table_schema = ANY (SELECT unnest(string_to_array(replace(setting, '"$user"', CURRENT_USER), ', ')) FROM pg_settings WHERE name = 'search_path')- AND data_type = 'timestamp with time zone'- LOOP- EXECUTE 'ALTER TABLE ' || t.table_name || ' ALTER COLUMN ' || t.column_name || ' TYPE timestamp without time zone USING ' || t.column_name || ' AT TIME ZONE ''UTC''';- END LOOP;- END$$;- SQL- end-enddiff --git a/db/migrate/20220909153412_drop_week_days.rb b/db/migrate/20220909153412_drop_week_days.rbdeleted file mode 100644index 9d3e6bc2939..00000000000--- a/db/migrate/20220909153412_drop_week_days.rb+++ /dev/null@@ -1,49 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class DropWeekDays < ActiveRecord::Migration[7.0]- def up- drop_table :week_days- end-- def down- create_table :week_days do |t|- t.integer :day, null: false- t.boolean :working, null: false, default: true-- t.timestamps- end-- execute <<-SQL.squish- ALTER TABLE week_days- ADD CONSTRAINT unique_day_number UNIQUE (day);- ALTER TABLE week_days- ADD CHECK (day >= 1 AND day <=7);- SQL- end-enddiff --git a/db/migrate/20220911182835_create_default_working_days_setting_entry.rb b/db/migrate/20220911182835_create_default_working_days_setting_entry.rbdeleted file mode 100644index 4f95f86fbe9..00000000000--- a/db/migrate/20220911182835_create_default_working_days_setting_entry.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class CreateDefaultWorkingDaysSettingEntry < ActiveRecord::Migration[7.0]- def change- Setting.where(name: "working_days").first_or_create!(value: Setting.working_days)- end-enddiff --git a/db/migrate/20220918165443_add_start_date_due_date_and_overdue_to_notification_settings.rb b/db/migrate/20220918165443_add_start_date_due_date_and_overdue_to_notification_settings.rbdeleted file mode 100644index 5c915cac155..00000000000--- a/db/migrate/20220918165443_add_start_date_due_date_and_overdue_to_notification_settings.rb+++ /dev/null@@ -1,37 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddStartDateDueDateAndOverdueToNotificationSettings < ActiveRecord::Migration[7.0]- def change- change_table :notification_settings, bulk: true do |t|- t.column :start_date, :integer, default: 24- t.column :due_date, :integer, default: 24- t.column :overdue, :integer, default: nil- end- end-enddiff --git a/db/migrate/20220922200908_split_involved_notification_setting.rb b/db/migrate/20220922200908_split_involved_notification_setting.rbdeleted file mode 100644index ebedb280a06..00000000000--- a/db/migrate/20220922200908_split_involved_notification_setting.rb+++ /dev/null@@ -1,48 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class SplitInvolvedNotificationSetting < ActiveRecord::Migration[7.0]- def change- change_table :notification_settings, bulk: true do |t|- t.column :assignee, :boolean, default: false, null: false- t.column :responsible, :boolean, default: false, null: false- end-- reversible do |change|- change.up do- NotificationSetting.where(involved: true).update_all(assignee: true, responsible: true)- end-- change.down do- NotificationSetting.where(assignee: true).or(NotificationSetting.where(responsible: true)).update_all(involved: true)- end- end-- remove_column :notification_settings, :involved, :boolean- end-enddiff --git a/db/migrate/20220926124435_constrain_work_package_dates.rb b/db/migrate/20220926124435_constrain_work_package_dates.rbdeleted file mode 100644index 1a888666eb3..00000000000--- a/db/migrate/20220926124435_constrain_work_package_dates.rb+++ /dev/null@@ -1,46 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class ConstrainWorkPackageDates < ActiveRecord::Migration[7.0]- def change- reversible do |dir|- dir.up do- WorkPackage.where("start_date > due_date").in_batches.each_record do |work_package|- User.execute_as(User.system) do- work_package.start_date = work_package.due_date- work_package.duration = 1- work_package.journal_notes = "_Resetting the start date automatically to fix inconsistent dates._"- work_package.save!(validate: false)- end- end- end- end-- add_check_constraint :work_packages, "due_date >= start_date", name: "work_packages_due_larger_start_date"- end-enddiff --git a/db/migrate/20220929114423_add_unique_index_to_ldap_groups_membership.rb b/db/migrate/20220929114423_add_unique_index_to_ldap_groups_membership.rbdeleted file mode 100644index 6df2b8ef2c5..00000000000--- a/db/migrate/20220929114423_add_unique_index_to_ldap_groups_membership.rb+++ /dev/null@@ -1,45 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddUniqueIndexToLdapGroupsMembership < ActiveRecord::Migration[7.0]- def change- reversible do |dir|- dir.up { remove_duplicate_memberships! }- end-- add_index :ldap_groups_memberships, %i[user_id group_id], unique: true- end-- def remove_duplicate_memberships!- ActiveRecord::Base.connection.execute <<~SQL.squish- DELETE FROM ldap_groups_memberships m1- USING ldap_groups_memberships m2- WHERE m1.id < m2.id AND m1.user_id = m2.user_id AND m1.group_id = m2.group_id;- SQL- end-enddiff --git a/db/migrate/20220930133418_set_duration_for_milestone_work_packages.rb b/db/migrate/20220930133418_set_duration_for_milestone_work_packages.rbdeleted file mode 100644index 33e3b51ed64..00000000000--- a/db/migrate/20220930133418_set_duration_for_milestone_work_packages.rb+++ /dev/null@@ -1,52 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class SetDurationForMilestoneWorkPackages < ActiveRecord::Migration[7.0]- def up- set_duration(:work_packages)- set_duration(:work_package_journals)- end-- private-- def set_duration(table)- execute <<~SQL.squish- UPDATE- #{table}- SET- duration = 1- WHERE- EXISTS (- SELECT * FROM types type- WHERE- type.is_milestone = TRUE AND- type.id = #{table}.type_id- )- SQL- end-enddiff --git a/db/migrate/20221017073431_remove_orphaned_tokens.rb b/db/migrate/20221017073431_remove_orphaned_tokens.rbdeleted file mode 100644index fb798fe76e2..00000000000--- a/db/migrate/20221017073431_remove_orphaned_tokens.rb+++ /dev/null@@ -1,53 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require_relative "migration_utils/column"--class RemoveOrphanedTokens < ActiveRecord::Migration[7.0]- def up- Token::Base.where.not(user_id: User.select(:id)).delete_all-- # Make sure we have bigint columns on both sides so the foreign key can be added.- # It could be that they are of type numeric if the data was migrated from MySQL once.- change_column_type! :users, :id, :bigint- change_column_type! :tokens, :user_id, :bigint-- add_foreign_key :tokens, :users-- User.reset_column_information- Token::Base.reset_column_information- end-- def down- remove_foreign_key :tokens, :users- end-- def change_column_type!(table, column, type)- Migration::MigrationUtils::Column.new(connection, table, column).change_type! type- end-enddiff --git a/db/migrate/20221017184204_change_defaults_for_notification_settings.rb b/db/migrate/20221017184204_change_defaults_for_notification_settings.rbdeleted file mode 100644index 126c3b15543..00000000000--- a/db/migrate/20221017184204_change_defaults_for_notification_settings.rb+++ /dev/null@@ -1,38 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class ChangeDefaultsForNotificationSettings < ActiveRecord::Migration[7.0]- def change- change_table :notification_settings, bulk: true do |t|- t.change_default :assignee, from: false, to: true- t.change_default :responsible, from: false, to: true- t.change_default :mentioned, from: false, to: true- t.change_default :watched, from: false, to: true- end- end-enddiff --git a/db/migrate/20221018160449_add_logged_by_to_cost_entries.rb b/db/migrate/20221018160449_add_logged_by_to_cost_entries.rbdeleted file mode 100644index 43dcfa59be0..00000000000--- a/db/migrate/20221018160449_add_logged_by_to_cost_entries.rb+++ /dev/null@@ -1,43 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddLoggedByToCostEntries < ActiveRecord::Migration[7.0]- def change- add_reference :cost_entries, :logged_by, foreign_key: { to_table: :users }, index: true-- reversible do |dir|- dir.up do- CostEntry- .where.not(user_id: User.select(:id))- .update_all(user_id: DeletedUser.first.id)-- CostEntry.update_all("logged_by_id = user_id")- end- end- end-enddiff --git a/db/migrate/20221026132134_bigint_primary_and_foreign_keys.rb b/db/migrate/20221026132134_bigint_primary_and_foreign_keys.rbdeleted file mode 100644index b6ba4cef570..00000000000--- a/db/migrate/20221026132134_bigint_primary_and_foreign_keys.rb+++ /dev/null@@ -1,226 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require_relative "migration_utils/column"--class BigintPrimaryAndForeignKeys < ActiveRecord::Migration[7.0]- KEY_CHANGES = {- Announcement => [:id],- Journal::AttachableJournal => %i[id journal_id attachment_id],- Journal::AttachmentJournal => %i[id container_id author_id],- Attachment => %i[id container_id author_id],- AttributeHelpText => [:id],- :auth_sources => [:id],- Journal::BudgetJournal => %i[id project_id author_id],- Budget => %i[id project_id author_id],- Category => %i[id project_id assigned_to_id],- Change => %i[id changeset_id],- Journal::ChangesetJournal => %i[id repository_id user_id],- Changeset => %i[id repository_id user_id],- :changesets_work_packages => %i[changeset_id work_package_id],- Color => [:id],- Comment => %i[id commented_id author_id],- CostEntry => %i[id user_id project_id work_package_id cost_type_id rate_id],- CostQuery => %i[id user_id project_id],- CostType => [:id],- CustomAction => [:id],- :custom_actions_projects => %i[id project_id custom_action_id],- :custom_actions_roles => %i[id role_id custom_action_id],- :custom_actions_statuses => %i[id status_id custom_action_id],- :custom_actions_types => %i[id type_id custom_action_id],- CustomField => [:id],- :custom_fields_projects => %i[custom_field_id project_id],- :custom_fields_types => %i[custom_field_id type_id],- CustomOption => %i[id custom_field_id],- CustomStyle => [:id],- CustomValue => %i[id customized_id custom_field_id],- Journal::CustomizableJournal => %i[id journal_id custom_field_id],- DesignColor => [:id],- :delayed_jobs => [:id], # delayed job removed in favour of good_job see WP #42 or PR #42- Journal::DocumentJournal => %i[id project_id category_id],- Document => %i[id project_id category_id],- :done_statuses_for_project => %i[project_id status_id],- EnabledModule => %i[id project_id],- EnterpriseToken => [:id],- Enumeration => %i[id project_id parent_id color_id],- Forum => %i[id project_id last_message_id],- Grids::Widget => [:grid_id],- Grids::Grid => %i[user_id project_id],- GroupUser => %i[group_id user_id],- Journal => %i[id journable_id user_id],- LaborBudgetItem => %i[id budget_id user_id],- LdapGroups::Membership => %i[id user_id group_id],- LdapGroups::SynchronizedGroup => %i[id group_id auth_source_id],- MaterialBudgetItem => %i[id budget_id cost_type_id],- Journal::MeetingContentJournal => %i[id meeting_id author_id],- :meeting_contents => %i[id meeting_id author_id],- Journal::MeetingJournal => %i[id project_id author_id],- MeetingParticipant => %i[id user_id meeting_id],- Meeting => %i[id author_id project_id],- MemberRole => %i[id member_id role_id inherited_from],- Member => %i[id user_id project_id],- MenuItem => %i[id parent_id navigatable_id],- Journal::MessageJournal => %i[id forum_id parent_id author_id],- Message => %i[id forum_id parent_id author_id last_reply_id],- News => %i[id project_id author_id],- Journal::NewsJournal => %i[id project_id author_id],- Doorkeeper::AccessGrant => %i[resource_owner_id application_id],- Doorkeeper::AccessToken => %i[resource_owner_id application_id],- Doorkeeper::Application => %i[owner_id client_credentials_user_id],- OrderedWorkPackage => %i[query_id work_package_id],- Project => %i[id parent_id],- :projects_types => %i[project_id type_id],- Query => %i[id project_id user_id],- Rate => %i[id project_id user_id cost_type_id],- Relation => [:id],- Repository => %i[id project_id],- RolePermission => %i[id role_id],- Role => [:id],- :sessions => %i[id user_id],- Setting => [:id],- Status => %i[id color_id],- TimeEntry => %i[id project_id user_id work_package_id activity_id rate_id],- Journal::TimeEntryJournal => %i[id project_id user_id work_package_id activity_id rate_id],- Token::Base => [:id],- ::TwoFactorAuthentication::Device => %i[id user_id],- Type => %i[id color_id],- UserPassword => %i[id user_id],- UserPreference => %i[id user_id],- User => %i[id auth_source_id],- VersionSetting => %i[id project_id version_id],- Version => %i[id project_id],- Watcher => %i[id watchable_id user_id],- Webhooks::Event => %i[id webhooks_webhook_id],- Webhooks::Log => %i[id webhooks_webhook_id],- Webhooks::Project => %i[id project_id webhooks_webhook_id],- Webhooks::Webhook => [:id],- :wiki_content_journals => %i[id page_id author_id],- :wiki_contents => %i[id page_id author_id],- WikiPage => %i[id wiki_id parent_id],- WikiRedirect => %i[id wiki_id],- Wiki => %i[id project_id],- Journal::WorkPackageJournal => %i[id- type_id- project_id- category_id- status_id- assigned_to_id- priority_id- version_id- author_id- parent_id- responsible_id- budget_id],- WorkPackage => %i[id- type_id- project_id- category_id- status_id- assigned_to_id- priority_id- version_id- author_id- parent_id- responsible_id- budget_id],- Workflow => %i[id type_id old_status_id new_status_id role_id]- }.freeze-- DEFAULT_CHANGES = {- Journal::AttachmentJournal => [:author_id],- Attachment => [:author_id],- Category => [:project_id],- Comment => %i[commented_id author_id],- :custom_fields_projects => %i[custom_field_id project_id],- :custom_fields_types => %i[custom_field_id type_id],- CustomValue => %i[customized_id custom_field_id],- Journal::DocumentJournal => %i[project_id category_id],- Document => %i[project_id category_id],- Journal => [:user_id],- Member => [:user_id],- News => [:author_id],- Journal::NewsJournal => [:author_id],- :projects_types => %i[project_id type_id],- Query => [:user_id],- Repository => [:project_id],- UserPreference => [:user_id],- Version => [:project_id],- Watcher => [:watchable_id],- Journal::WorkPackageJournal => %i[type_id project_id status_id priority_id author_id],- WorkPackage => %i[type_id project_id status_id priority_id author_id],- Workflow => %i[type_id old_status_id new_status_id role_id]- }.freeze-- def up- KEY_CHANGES.each do |klass, columns|- change_columns_type(klass, columns, :bigint)- end-- DEFAULT_CHANGES.each do |klass, columns|- change_columns_default(klass, columns, from: 0, to: nil)- end- end-- def down- KEY_CHANGES.each do |klass, columns|- change_columns_type(klass, columns, :integer)- end-- DEFAULT_CHANGES.each do |klass, columns|- change_columns_default(klass, columns, from: nil, to: 0)- end- end-- private-- def change_columns_type(klass, columns, type)- for_each_klass_and_columns(klass, columns) do |table, column|- change_column_type(table, column, type)- end- end-- def change_columns_default(klass, columns, from:, to:)- for_each_klass_and_columns(klass, columns) do |table, column|- change_column_default(table, column, from:, to:)- end- end-- def change_column_type(table, column, type)- Migration::MigrationUtils::Column.new(connection, table, column).change_type! type- end-- def for_each_klass_and_columns(klass, columns)- table = klass.respond_to?(:table_name) ? klass.table_name : klass-- columns.each do |column|- yield table, column- end-- klass.reset_column_information if klass.respond_to?(:reset_column_information)- end-enddiff --git a/db/migrate/20221027151959_remove_plaintext_tokens.rb b/db/migrate/20221027151959_remove_plaintext_tokens.rbdeleted file mode 100644index 4e65a466cc6..00000000000--- a/db/migrate/20221027151959_remove_plaintext_tokens.rb+++ /dev/null@@ -1,40 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RemovePlaintextTokens < ActiveRecord::Migration[7.0]- def change- drop_table :plaintext_tokens do |t|- t.integer :user_id, default: 0, null: false- t.string :action, limit: 30, default: "", null: false- t.string :value, limit: 40, default: "", null: false- t.datetime :created_on, null: false-- t.index :user_id, name: "index_plaintext_tokens_on_user_id"- end- end-enddiff --git a/db/migrate/20221028070534_change_notification_settings_start_date_due_date_and_overdue_duration_unit_to_days.rb b/db/migrate/20221028070534_change_notification_settings_start_date_due_date_and_overdue_duration_unit_to_days.rbdeleted file mode 100644index f2fb65bf669..00000000000--- a/db/migrate/20221028070534_change_notification_settings_start_date_due_date_and_overdue_duration_unit_to_days.rb+++ /dev/null@@ -1,68 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class ChangeNotificationSettingsStartDateDueDateAndOverdueDurationUnitToDays < ActiveRecord::Migration[7.0]- def change- change_table :notification_settings, bulk: true do |t|- t.change_default :start_date, from: 24, to: 1- t.change_default :due_date, from: 24, to: 1- end-- reversible do |dir|- dir.up do- update_durations_from_hours_to_days- end-- dir.down do- update_durations_from_days_to_hours- end- end- end-- def update_durations_from_hours_to_days- execute <<~SQL.squish- UPDATE- notification_settings- SET- start_date = CASE WHEN start_date IS NOT NULL THEN start_date / 24 END,- due_date = CASE WHEN due_date IS NOT NULL THEN due_date / 24 END,- overdue = CASE WHEN overdue IS NOT NULL THEN overdue / 24 END- SQL- end-- def update_durations_from_days_to_hours- execute <<~SQL.squish- UPDATE- notification_settings- SET- start_date = CASE WHEN start_date IS NOT NULL THEN start_date * 24 END,- due_date = CASE WHEN due_date IS NOT NULL THEN due_date * 24 END,- overdue = CASE WHEN overdue IS NOT NULL THEN overdue * 24 END- SQL- end-enddiff --git a/db/migrate/20221029194419_add_timestamps_to_queries.rb b/db/migrate/20221029194419_add_timestamps_to_queries.rbdeleted file mode 100644index 9743be9c4f0..00000000000--- a/db/migrate/20221029194419_add_timestamps_to_queries.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddTimestampsToQueries < ActiveRecord::Migration[7.0]- def change- add_column :queries, :timestamps, :string- end-enddiff --git a/db/migrate/20221115082403_add_ldap_tls_options.rb b/db/migrate/20221115082403_add_ldap_tls_options.rbdeleted file mode 100644index 898576e4472..00000000000--- a/db/migrate/20221115082403_add_ldap_tls_options.rb+++ /dev/null@@ -1,65 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddLdapTlsOptions < ActiveRecord::Migration[7.0]- class MigratingAuthSource < ApplicationRecord- self.table_name = "auth_sources"- end-- def change- change_table :auth_sources, bulk: true do |t|- t.boolean :verify_peer, default: true, null: false- t.text :tls_certificate_string- end-- reversible do |dir|- dir.up do- # Current LDAP library default is to not verify the certificate- MigratingAuthSource.reset_column_information-- ldap_settings = Setting.where(name: "ldap_tls_options").pick :value- migrate_ldap_settings(ldap_settings)- end- end- end-- private-- def migrate_ldap_settings(ldap_settings)- return if ldap_settings.blank?-- parsed = Setting.deserialize_hash(ldap_settings)- verify_peer = parsed["verify_mode"] == OpenSSL::SSL::VERIFY_PEER-- MigratingAuthSource.update_all(verify_peer:)- rescue StandardError => e- Rails.logger.error do- "Failed to set LDAP verify_mode from settings: #{e.message}. Please double check your LDAP configuration."- end- end-enddiff --git a/db/migrate/20221129074635_remove_activity_type_from_journals_table.rb b/db/migrate/20221129074635_remove_activity_type_from_journals_table.rbdeleted file mode 100644index 2580c69687d..00000000000--- a/db/migrate/20221129074635_remove_activity_type_from_journals_table.rb+++ /dev/null@@ -1,72 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RemoveActivityTypeFromJournalsTable < ActiveRecord::Migration[7.0]- def up- remove_column :journals, :activity_type- end-- def down- add_column :journals, :activity_type, :string-- execute <<-SQL.squish- UPDATE- journals- SET- activity_type =- CASE- WHEN journable_type = 'Attachment' THEN 'attachments'- WHEN journable_type = 'Budget' THEN 'budgets'- WHEN journable_type = 'Changeset' THEN 'changesets'- WHEN journable_type = 'Document' THEN 'documents'- WHEN journable_type = 'Meeting' THEN 'meetings'- WHEN journable_type = 'Message' THEN 'messages'- WHEN journable_type = 'News' THEN 'news'- WHEN journable_type = 'TimeEntry' THEN 'time_entries'- WHEN journable_type = 'WikiContent' THEN 'wiki_edits'- WHEN journable_type = 'WorkPackage' THEN 'work_packages'- END- WHERE journable_type != 'MeetingContent'- SQL-- execute <<-SQL.squish- UPDATE- journals- SET- activity_type =- CASE- WHEN meeting_contents.type = 'MeetingMinutes' THEN 'meeting_minutes'- WHEN meeting_contents.type = 'MeetingAgenda' THEN 'meeting_agenda'- ELSE 'meetings'- END- FROM meeting_contents- WHERE journable_type = 'MeetingContent'- AND journable_id = meeting_contents.id- SQL- end-enddiff --git a/db/migrate/20221201140825_add_non_null_constraint_on_projects_identifier.rb b/db/migrate/20221201140825_add_non_null_constraint_on_projects_identifier.rbdeleted file mode 100644index 0114481e93c..00000000000--- a/db/migrate/20221201140825_add_non_null_constraint_on_projects_identifier.rb+++ /dev/null@@ -1,44 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddNonNullConstraintOnProjectsIdentifier < ActiveRecord::Migration[7.0]- def change- reversible do |dir|- dir.up do- # should not be needed as all identifiers should be present- execute <<~SQL.squish- UPDATE projects- SET identifier = 'project-' || id- WHERE identifier IS NULL- SQL- end- end-- change_column_null :projects, :identifier, false- end-enddiff --git a/db/migrate/20221202130039_fill_project_journals_with_existing_data.rb b/db/migrate/20221202130039_fill_project_journals_with_existing_data.rbdeleted file mode 100644index 3ae4390625d..00000000000--- a/db/migrate/20221202130039_fill_project_journals_with_existing_data.rb+++ /dev/null@@ -1,144 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class FillProjectJournalsWithExistingData < ActiveRecord::Migration[7.0]- def up- make_sure_journals_notes_is_nullable- # On some user instances, invalid custom values were encountered. Those- # custom_values belonged to projects which had been deleted in the meantime.- delete_invalid_custom_values- create_journal_entries_for_projects- end-- def down- delete_journal_entries_for_projects- end-- private-- def make_sure_journals_notes_is_nullable- change_column_null(:journals, :notes, true)- end-- def create_journal_entries_for_projects- sql = <<~SQL.squish- WITH project_journals_insertion AS (- INSERT INTO project_journals(- name,- description,- public,- parent_id,- identifier,- active,- templated- )- SELECT name,- description,- public,- parent_id,- identifier,- active,- templated- FROM projects- RETURNING id,- identifier- ),- journals_insertion AS (- INSERT into journals (- journable_id,- journable_type,- user_id,- created_at,- updated_at,- version,- data_type,- data_id- )- SELECT projects.id,- 'Project',- :user_id,- projects.created_at,- projects.updated_at,- 1,- 'Journal::ProjectJournal',- project_journals_insertion.id- FROM projects- FULL JOIN project_journals_insertion ON projects.identifier = project_journals_insertion.identifier- RETURNING id,- journable_id- ),- customizable_journals_insertion AS (- INSERT into customizable_journals (- journal_id,- custom_field_id,- value- )- SELECT journals_insertion.id,- custom_field_id,- value- FROM custom_values- FULL JOIN journals_insertion ON custom_values.customized_id = journals_insertion.journable_id- WHERE custom_values.customized_type = 'Project'- )- SELECT COUNT(1)- FROM journals_insertion;- SQL- sql = ::ActiveRecord::Base.sanitize_sql_array([sql, { user_id: User.system.id }])- execute(sql)- end-- def delete_journal_entries_for_projects- execute(<<~SQL.squish)- DELETE- FROM customizable_journals- WHERE journal_id IN (- SELECT id FROM journals WHERE journable_type = 'Project'- )- SQL- execute(<<~SQL.squish)- DELETE- FROM journals- WHERE journable_type = 'Project'- SQL- execute(<<~SQL.squish)- DELETE- FROM project_journals- SQL- end-- def delete_invalid_custom_values- execute(<<~SQL.squish)- DELETE- FROM- custom_values- WHERE- custom_values.customized_type = 'Project'- AND NOT EXISTS (SELECT 1 FROM projects WHERE projects.id = custom_values.customized_id)- SQL- end-enddiff --git a/db/migrate/20221213092910_remove_default_values_from_journal_tables_definition.rb b/db/migrate/20221213092910_remove_default_values_from_journal_tables_definition.rbdeleted file mode 100644index 0a48fd0a203..00000000000--- a/db/migrate/20221213092910_remove_default_values_from_journal_tables_definition.rb+++ /dev/null@@ -1,68 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RemoveDefaultValuesFromJournalTablesDefinition < ActiveRecord::Migration[7.0]- # rubocop:disable Metrics/AbcSize- def change- change_table :attachable_journals, bulk: true do |t|- t.change_default :filename, from: "", to: nil- end-- change_table :attachment_journals, bulk: true do |t|- t.change_default :filename, from: "", to: nil- t.change_default :disk_filename, from: "", to: nil- t.change_default :filesize, from: 0, to: nil- t.change_default :content_type, from: "", to: nil- t.change_default :digest, from: "", to: nil- t.change_default :downloads, from: 0, to: nil- end-- change_table :document_journals, bulk: true do |t|- t.change_default :title, from: "", to: nil- end-- change_table :message_journals, bulk: true do |t|- t.change_default :subject, from: "", to: nil- t.change_default :locked, from: false, to: nil- t.change_default :sticky, from: 0, to: nil- end-- change_table :news_journals, bulk: true do |t|- t.change_default :title, from: "", to: nil- t.change_default :summary, from: "", to: nil- t.change_default :comments_count, from: 0, to: nil- end-- change_table :work_package_journals, bulk: true do |t|- t.change_default :subject, from: "", to: nil- t.change_default :done_ratio, from: 0, to: nil- t.change_default :schedule_manually, from: false, to: nil- end- end- # rubocop:enable Metrics/AbcSize-enddiff --git a/db/migrate/20230105073117_remove_renamed_date_alert_job.rb b/db/migrate/20230105073117_remove_renamed_date_alert_job.rbdeleted file mode 100644index f6ede044445..00000000000--- a/db/migrate/20230105073117_remove_renamed_date_alert_job.rb+++ /dev/null@@ -1,35 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RemoveRenamedDateAlertJob < ActiveRecord::Migration[6.0]- def up- # The job has been renamed to Notifications::ScheduleDateAlertsNotificationsJob.- # The new job will be added on restarting the application.- execute("DELETE FROM delayed_jobs WHERE handler LIKE '%job_class: Notifications::CreateDateAlertsNotificationsJob%'")- end-enddiff --git a/db/migrate/20230105134940_work_package_date_indices.rb b/db/migrate/20230105134940_work_package_date_indices.rbdeleted file mode 100644index c20a24d0d7f..00000000000--- a/db/migrate/20230105134940_work_package_date_indices.rb+++ /dev/null@@ -1,34 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class WorkPackageDateIndices < ActiveRecord::Migration[7.0]- def change- add_index :work_packages, :start_date- add_index :work_packages, :due_date- end-enddiff --git a/db/migrate/20230130134630_add_index_for_work_package_journals_project_id.rb b/db/migrate/20230130134630_add_index_for_work_package_journals_project_id.rbdeleted file mode 100644index 434cd17c90a..00000000000--- a/db/migrate/20230130134630_add_index_for_work_package_journals_project_id.rb+++ /dev/null@@ -1,35 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddIndexForWorkPackageJournalsProjectId < ActiveRecord::Migration[7.0]- def change- add_index :news_journals, :project_id- add_index :time_entry_journals, :project_id- add_index :work_package_journals, :project_id- end-enddiff --git a/db/migrate/20230306083203_non_null_data_reference_on_journals.rb b/db/migrate/20230306083203_non_null_data_reference_on_journals.rbdeleted file mode 100644index e8741dcfa79..00000000000--- a/db/migrate/20230306083203_non_null_data_reference_on_journals.rb+++ /dev/null@@ -1,71 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class NonNullDataReferenceOnJournals < ActiveRecord::Migration[7.0]- def change- reversible do |direction|- direction.up do- change_on_delete_on_notification_fk(true)- cleanup_invalid_journals- end- direction.down do- change_on_delete_on_notification_fk(false)- end- end-- change_non_null_data_columns- end-- private-- def change_non_null_data_columns- change_column_null :journals, :data_id, false- change_column_null :journals, :data_type, false- end-- def cleanup_invalid_journals- execute <<~SQL.squish- DELETE FROM journals- WHERE data_id IS NULL OR data_type IS NULL- SQL- end-- def change_on_delete_on_notification_fk(cascade)- options = if cascade- { on_delete: :cascade }- else- {}- end-- remove_foreign_key :notifications, :journals-- add_foreign_key :notifications,- :journals,- **options- end-enddiff --git a/db/migrate/20230309104056_unique_index_on_custom_fields_projects.rb b/db/migrate/20230309104056_unique_index_on_custom_fields_projects.rbdeleted file mode 100644index a208b3c6acc..00000000000--- a/db/migrate/20230309104056_unique_index_on_custom_fields_projects.rb+++ /dev/null@@ -1,79 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class UniqueIndexOnCustomFieldsProjects < ActiveRecord::Migration[7.0]- def change- reversible do |direction|- direction.up { remove_duplicates }- end-- remove_index :custom_fields_projects,- %i[custom_field_id project_id]-- add_index :custom_fields_projects,- %i[custom_field_id project_id],- unique: true- end-- private-- # Selects all distinct tuples of (project_id, custom_field_id), then removes the whole content- # of custom_fields_projects to then add the distinct tuples again.- def remove_duplicates- execute <<~SQL.squish- WITH selection AS (- SELECT- project_id,- custom_field_id- FROM- custom_fields_projects- GROUP BY- (project_id, custom_field_id)- ),- deletion AS (- DELETE FROM- custom_fields_projects- ),- insertion AS (- INSERT INTO- custom_fields_projects- (- project_id,- custom_field_id- )- SELECT- project_id,- custom_field_id- FROM- selection- )-- SELECT 1- SQL- end-enddiff --git a/db/migrate/20230314093106_add_update_delete_cascade_to_work_packages_project_id.rb b/db/migrate/20230314093106_add_update_delete_cascade_to_work_packages_project_id.rbdeleted file mode 100644index 287bf7e7c3d..00000000000--- a/db/migrate/20230314093106_add_update_delete_cascade_to_work_packages_project_id.rb+++ /dev/null@@ -1,39 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddUpdateDeleteCascadeToWorkPackagesProjectId < ActiveRecord::Migration[7.0]- def up- remove_foreign_key :work_packages, :projects- add_foreign_key :work_packages, :projects, on_delete: :cascade, on_update: :cascade- end-- def down- remove_foreign_key :work_packages, :projects- add_foreign_key :work_packages, :projects- end-enddiff --git a/db/migrate/20230314165213_add_foreign_keys_to_work_packages.rb b/db/migrate/20230314165213_add_foreign_keys_to_work_packages.rbdeleted file mode 100644index b529225592e..00000000000--- a/db/migrate/20230314165213_add_foreign_keys_to_work_packages.rb+++ /dev/null@@ -1,41 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddForeignKeysToWorkPackages < ActiveRecord::Migration[7.0]- def up- WorkPackage.where.not(type: Type.all).destroy_all- add_foreign_key :work_packages, :types, on_delete: :cascade, on_update: :cascade- WorkPackage.where.not(status: Status.all).destroy_all- add_foreign_key :work_packages, :statuses, on_delete: :cascade, on_update: :cascade- end-- def down- remove_foreign_key :work_packages, :types- remove_foreign_key :work_packages, :statuses- end-enddiff --git a/db/migrate/20230315103437_add_foreign_keys_to_workflows.rb b/db/migrate/20230315103437_add_foreign_keys_to_workflows.rbdeleted file mode 100644index 42a4f6f9aba..00000000000--- a/db/migrate/20230315103437_add_foreign_keys_to_workflows.rb+++ /dev/null@@ -1,45 +0,0 @@-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddForeignKeysToWorkflows < ActiveRecord::Migration[7.0]- def up- Workflow.where.not(type: Type.all).destroy_all- add_foreign_key :workflows, :types, on_delete: :cascade, on_update: :cascade- Workflow.where.not(old_status_id: Status.all).or(Workflow.where.not(new_status_id: Status.all)).destroy_all- add_foreign_key :workflows, :statuses, column: "old_status_id", on_delete: :cascade, on_update: :cascade- add_foreign_key :workflows, :statuses, column: "new_status_id", on_delete: :cascade, on_update: :cascade- Workflow.where.not(role: Role.all).destroy_all- add_foreign_key :workflows, :roles, on_delete: :cascade, on_update: :cascade- end-- def down- remove_foreign_key :workflows, :types- remove_foreign_key :workflows, :statuses- remove_foreign_key :workflows, :statuses- remove_foreign_key :workflows, :roles- end-enddiff --git a/db/migrate/20230315183431_add_foreign_keys_to_projects_types.rb b/db/migrate/20230315183431_add_foreign_keys_to_projects_types.rbdeleted file mode 100644index c794651fa8b..00000000000--- a/db/migrate/20230315183431_add_foreign_keys_to_projects_types.rb+++ /dev/null@@ -1,42 +0,0 @@-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddForeignKeysToProjectsTypes < ActiveRecord::Migration[7.0]- def up- execute <<~SQL.squish- DELETE FROM projects_types- WHERE type_id NOT IN (SELECT id FROM types) OR- project_id NOT IN (SELECT id FROM projects)- SQL- add_foreign_key :projects_types, :types, on_delete: :cascade, on_update: :cascade- add_foreign_key :projects_types, :projects, on_delete: :cascade, on_update: :cascade- end-- def down- remove_foreign_key :projects_types, :types- remove_foreign_key :projects_types, :projects- end-enddiff --git a/db/migrate/20230315184533_add_foreign_keys_to_custom_fields_projects.rb b/db/migrate/20230315184533_add_foreign_keys_to_custom_fields_projects.rbdeleted file mode 100644index a5aea3d1831..00000000000--- a/db/migrate/20230315184533_add_foreign_keys_to_custom_fields_projects.rb+++ /dev/null@@ -1,44 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddForeignKeysToCustomFieldsProjects < ActiveRecord::Migration[7.0]- def up- execute <<~SQL.squish- DELETE FROM custom_fields_projects- WHERE custom_field_id NOT IN (SELECT id FROM custom_fields) OR- project_id NOT IN (SELECT id FROM projects)- SQL- add_foreign_key :custom_fields_projects, :custom_fields, on_delete: :cascade, on_update: :cascade- add_foreign_key :custom_fields_projects, :projects, on_delete: :cascade, on_update: :cascade- end-- def down- remove_foreign_key :custom_fields_projects, :custom_fields- remove_foreign_key :custom_fields_projects, :projects- end-enddiff --git a/db/migrate/20230322135932_merge_wiki_content_into_page.rb b/db/migrate/20230322135932_merge_wiki_content_into_page.rbdeleted file mode 100644index 926cf11e906..00000000000--- a/db/migrate/20230322135932_merge_wiki_content_into_page.rb+++ /dev/null@@ -1,185 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require_relative "migration_utils/utils"--class MergeWikiContentIntoPage < ActiveRecord::Migration[7.0]- include ::Migration::Utils-- def change- add_contents_columns_to_pages-- reversible do |dir|- dir.up do- change_null_values_on_contents- update_wiki_pages_from_contents- update_journals_to_pages- end- dir.down do- insert_wiki_contents- update_journals_to_contents- end- end-- change_null_values_on_pages-- drop_wiki_contents-- rename_and_adapt_journal_data- end-- private-- def add_contents_columns_to_pages- change_table :wiki_pages, bulk: true do |t|- # null: false is set later on after the data is migrated- t.references :author, index: true, null: true, foreign_key: { to_table: :users }- t.text :text, limit: 16.megabytes- # null: false is set later on after the data is migrated- t.integer :lock_version, null: true- end-- add_index :wiki_pages, :updated_at- end-- def drop_wiki_contents- drop_table :wiki_contents do |t|- t.integer :page_id, null: false- t.integer :author_id- t.text :text, limit: 16.megabytes- t.datetime :updated_at, null: false- t.integer :lock_version, null: false-- t.index :author_id, name: "index_wiki_contents_on_author_id"- t.index :page_id, name: "wiki_contents_page_id"- t.index %i[page_id updated_at]- end- end-- def change_null_values_on_contents- execute_sql(- "- UPDATE wiki_contents SET author_id = :deleted_user_id- WHERE author_id NOT IN (SELECT id from users)- ",- deleted_user_id:- )- end-- def change_null_values_on_pages- change_column_null :wiki_pages, :lock_version, false-- execute_sql("UPDATE wiki_pages SET author_id = :deleted_user_id WHERE author_id IS NULL", deleted_user_id:)-- change_column_null :wiki_pages, :author_id, false- end-- def deleted_user_id- # We use the model to make sure one is created in case it doesn't exist yet- @deleted_user_id ||= DeletedUser.first.id- end-- def rename_and_adapt_journal_data- rename_table :wiki_content_journals, :wiki_page_journals- remove_column :wiki_page_journals, :page_id, :bigint- end-- def update_journals_to_pages- execute <<~SQL.squish- UPDATE- journals- SET- journable_id = wiki_contents.page_id,- journable_type = 'WikiPage',- data_type = 'Journal::WikiPageJournal'- FROM- wiki_contents- WHERE- journals.journable_id = wiki_contents.id- AND- journals.journable_type = 'WikiContent'- AND- journals.data_type = 'Journal::WikiContentJournal'- SQL- end-- def update_journals_to_contents- execute <<~SQL.squish- UPDATE- journals- SET- journable_id = wiki_contents.id,- journable_type = 'WikiContent',- data_type = 'Journal::WikiContentJournal'- FROM- wiki_contents- WHERE- journals.journable_id = wiki_contents.page_id- AND- journals.journable_type = 'WikiPage'- AND- journals.data_type = 'Journal::WikiPageJournal'- SQL- end-- def update_wiki_pages_from_contents- execute <<~SQL.squish- UPDATE- wiki_pages- SET- text = wiki_contents.text,- author_id = wiki_contents.author_id,- lock_version = wiki_contents.lock_version- FROM- wiki_contents- WHERE- wiki_contents.page_id = wiki_pages.id- SQL- end-- def insert_wiki_contents- execute <<~SQL.squish- INSERT INTO- wiki_contents (- page_id,- author_id,- text,- updated_at,- lock_version- )- SELECT- id,- author_id,- text,- updated_at,- lock_version- FROM- wiki_pages- SQL- end-enddiff --git a/db/migrate/20230328154645_add_gin_trgm_index_on_journals_and_custom_values.rb b/db/migrate/20230328154645_add_gin_trgm_index_on_journals_and_custom_values.rbdeleted file mode 100644index ef80a866f8e..00000000000--- a/db/migrate/20230328154645_add_gin_trgm_index_on_journals_and_custom_values.rb+++ /dev/null@@ -1,71 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddGinTrgmIndexOnJournalsAndCustomValues < ActiveRecord::Migration[7.0]- def up- safe_enable_pg_trgm_extension-- if extensions.include?("pg_trgm")- add_index(:journals, :notes, using: "gin", opclass: :gin_trgm_ops)- add_index(:custom_values, :value, using: "gin", opclass: :gin_trgm_ops)- end- end-- def down- remove_index(:journals, :notes, if_exists: true)- remove_index(:custom_values, :value, if_exists: true)- drop_pg_trgm_extension- end-- private-- def safe_enable_pg_trgm_extension- ActiveRecord::Base.connection.execute("CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA pg_catalog;")- rescue StandardError => e- raise unless e.message.include?("pg_trgm")-- # Rollback the transaction in order to recover from the error.- ActiveRecord::Base.connection.execute "ROLLBACK"-- warn <<~MESSAGE--- \e[33mWARNING:\e[0m Could not find the `pg_trgm` extension for PostgreSQL.- In order to benefit from this performance improvement, please install the postgresql-contrib module- for your PostgreSQL installation and re-run this migration.-- Read more about the contrib module at `https://www.postgresql.org/docs/current/contrib.html` .- To re-run this migration use the following command `bin/rails db:migrate:redo VERSION=20230328154645`-- MESSAGE- end-- def drop_pg_trgm_extension- ActiveRecord::Base.connection.execute("DROP EXTENSION IF EXISTS pg_trgm CASCADE;")- end-enddiff --git a/db/migrate/20230508150835_copy_project_status_into_projects_and_journals.rb b/db/migrate/20230508150835_copy_project_status_into_projects_and_journals.rbdeleted file mode 100644index b11c81b1371..00000000000--- a/db/migrate/20230508150835_copy_project_status_into_projects_and_journals.rb+++ /dev/null@@ -1,124 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class CopyProjectStatusIntoProjectsAndJournals < ActiveRecord::Migration[7.0]- def change- add_status_columns_to_projects- add_status_columns_to_project_journals-- reversible do |dir|- dir.up do- copy_project_status_into_projects- copy_project_status_into_journals- end-- dir.down do- clear_status_from_project_journals- restore_project_statuses- end- end-- drop_project_statuses_table- end-- private-- def add_status_columns_to_projects- change_table :projects, bulk: true do |table|- table.integer :status_code- table.text :status_explanation- end- end-- def add_status_columns_to_project_journals- change_table :project_journals, bulk: true do |table|- table.integer :status_code- table.text :status_explanation- end- end-- def copy_project_status_into_projects- execute <<~SQL.squish- UPDATE projects- SET status_code = project_statuses.code,- status_explanation = project_statuses.explanation- FROM project_statuses- WHERE project_statuses.project_id = projects.id- SQL- end-- def copy_project_status_into_journals- execute <<~SQL.squish- UPDATE project_journals- SET status_code = projects.status_code,- status_explanation = projects.status_explanation- FROM projects- JOIN journals ON journals.journable_id = projects.id- AND journals.journable_type = 'Project'- WHERE project_journals.id = journals.data_id- AND journals.data_type = 'Journal::ProjectJournal'- SQL- end-- def clear_status_from_project_journals- execute <<~SQL.squish- UPDATE project_journals- SET status_code = NULL,- status_explanation = NULL- SQL- end-- def restore_project_statuses- execute <<~SQL.squish- INSERT INTO project_statuses (- project_id,- code,- explanation,- created_at,- updated_at- )- SELECT id,- status_code,- status_explanation,- created_at,- updated_at- FROM projects- WHERE projects.status_code IS NOT NULL- OR projects.status_explanation IS NOT NULL- SQL- end-- def drop_project_statuses_table- drop_table :project_statuses do |table|- table.references :project, null: false, foreign_key: true, index: { unique: true }- table.text :explanation- table.integer :code- table.timestamps- end- end-enddiff --git a/db/migrate/20230531093004_remove_default_from_query_name.rb b/db/migrate/20230531093004_remove_default_from_query_name.rbdeleted file mode 100644index f974e9ec9ff..00000000000--- a/db/migrate/20230531093004_remove_default_from_query_name.rb+++ /dev/null@@ -1,5 +0,0 @@-class RemoveDefaultFromQueryName < ActiveRecord::Migration[7.0]- def change- change_column_default :queries, :name, to: nil, from: ""- end-enddiff --git a/db/migrate/20230606083221_add_cause_to_journal.rb b/db/migrate/20230606083221_add_cause_to_journal.rbdeleted file mode 100644index 43d0603b6f0..00000000000--- a/db/migrate/20230606083221_add_cause_to_journal.rb+++ /dev/null@@ -1,5 +0,0 @@-class AddCauseToJournal < ActiveRecord::Migration[7.0]- def change- add_column :journals, :cause, :jsonb, default: {}- end-enddiff --git a/db/migrate/20230608151123_add_validity_period_to_journals.rb b/db/migrate/20230608151123_add_validity_period_to_journals.rbdeleted file mode 100644index c5170a1f17b..00000000000--- a/db/migrate/20230608151123_add_validity_period_to_journals.rb+++ /dev/null@@ -1,150 +0,0 @@-class AddValidityPeriodToJournals < ActiveRecord::Migration[7.0]- def change- add_column :journals, :validity_period, :tstzrange-- reversible do |direction|- direction.up do- create_successor_journals_utility_table-- fix_all_journal_timestamps- write_validity_period-- drop_successor_journals_utility_table-- add_validity_period_constraint- end- end-- add_check_constraint :journals,- "NOT isempty(validity_period) AND validity_period IS NOT NULL",- name: "journals_validity_period_not_empty"- end-- def fix_all_journal_timestamps- return unless current_max_journal_version-- say "Fixing potential timestamp inconsistencies on existing journals."-- current_max_journal_version.downto(1).each do |version|- say_with_time "Fixing timestamps for journals with version #{version}." do- fixed_journals = fix_journal_timestamps(version)-- say "Fixed timestamps for #{fixed_journals.cmdtuples} journals.", true if fixed_journals.cmdtuples.positive?- end- end-- say "Done."- end-- def create_successor_journals_utility_table- say_with_time "Creating utility table to improve the performance of subsequent actions." do- suppress_messages do- create_table :successor_journals, id: false do |t|- t.references :predecessor, null: true, index: false- t.references :successor, null: true, index: false- end-- execute <<~SQL.squish- INSERT INTO- successor_journals- SELECT- predecessors.id predecessor_id,- successors.id successor_id- FROM- journals predecessors- LEFT JOIN LATERAL (SELECT DISTINCT ON (journable_type, journable_id) *- FROM journals successors- WHERE successors.version > predecessors.version- AND successors.journable_id = predecessors.journable_id- AND successors.journable_type = predecessors.journable_type- ORDER BY successors.journable_type ASC,- successors.journable_id ASC,- successors.version ASC) successors- ON successors.journable_id = predecessors.journable_id- AND successors.journable_type = predecessors.journable_type- SQL-- add_index :successor_journals, :predecessor_id- add_index :successor_journals, :successor_id- end- end- end-- def drop_successor_journals_utility_table- suppress_messages do- drop_table :successor_journals- end- end-- def current_max_journal_version- @current_max_journal_version ||= suppress_messages { select_one("SELECT MAX(version) FROM journals")["max"] }- end-- # Update journals with their timestamps after the timestamp of their successor- # (as identified by the journal belonging to the same journable and having the smallest version- # larger than the journal's).- # If one such is found, the:- # * created_at is set to be the minimum of the journal's and the successor's created_at. But of the successor's value some- # small amount needs to be subtracted as later on the validity_period is calculated as a range from the predecessor's- # created_at to the successor's created_at. If the two values would be equal, the range would be empty- # resulting in an error.- # * updated_at is only altered if created_at and updated_at are equal, meaning the journal has never been updated.- # A journal might very well be updated after its successor was created, because as a note can be updated- # by the user at anytime.- # This might have the consequence of the updated_at wrongfully being after the created_at of the successor,- # but this will not be invalid.- def fix_journal_timestamps(version)- suppress_messages do- execute <<~SQL.squish- UPDATE journals- SET- created_at = LEAST(journals.created_at, successors.created_at - INTERVAL '1ms'),- updated_at = CASE- WHEN journals.created_at = journals.updated_at- THEN LEAST(journals.created_at, successors.created_at - INTERVAL '1ms')- ELSE journals.updated_at- END- FROM successor_journals, journals successors- WHERE successor_journals.predecessor_id = journals.id AND successor_journals.successor_id = successors.id- AND successors.created_at <= journals.created_at- AND journals.version = #{version}- SQL- end- end-- def write_validity_period- say_with_time "Writing validity periods for journals." do- suppress_messages do- execute <<~SQL.squish- UPDATE journals- SET validity_period = values.validity_period- FROM (- SELECT- predecessors.id,- tstzrange(predecessors.created_at, successors.created_at) validity_period- FROM- journals predecessors- LEFT JOIN successor_journals- ON successor_journals.predecessor_id = predecessors.id- LEFT JOIN journals successors- ON successor_journals.successor_id = successors.id- ) values- WHERE values.id = journals.id- SQL- end- end-- say "Done."- end-- def add_validity_period_constraint- execute <<~SQL.squish- CREATE EXTENSION IF NOT EXISTS btree_gist WITH SCHEMA pg_catalog;-- ALTER TABLE journals- ADD CONSTRAINT non_overlapping_journals_validity_periods- EXCLUDE USING gist (journable_id WITH =, journable_type WITH =, validity_period WITH &&)- DEFERRABLE- SQL- end-enddiff --git a/db/migrate/20230613155001_add_export_logo_to_custom_style.rb b/db/migrate/20230613155001_add_export_logo_to_custom_style.rbdeleted file mode 100644index 2a7de08852a..00000000000--- a/db/migrate/20230613155001_add_export_logo_to_custom_style.rb+++ /dev/null@@ -1,8 +0,0 @@-class AddExportLogoToCustomStyle < ActiveRecord::Migration[7.0]- def change- add_column :custom_styles,- :export_logo,- :string,- default: nil- end-enddiff --git a/db/migrate/20230717104700_drop_export_card_configurations.rb b/db/migrate/20230717104700_drop_export_card_configurations.rbdeleted file mode 100644index a3bc4155d26..00000000000--- a/db/migrate/20230717104700_drop_export_card_configurations.rb+++ /dev/null@@ -1,13 +0,0 @@-class DropExportCardConfigurations < ActiveRecord::Migration[7.0]- def change- drop_table :export_card_configurations, if_exists: true do |t|- t.string :name- t.integer :per_page- t.string :page_size- t.string :orientation- t.text :rows- t.text :description- t.boolean :active, default: true- end- end-enddiff --git a/db/migrate/20230718084649_add_create_user_permission_to_roles.rb b/db/migrate/20230718084649_add_create_user_permission_to_roles.rbdeleted file mode 100644index b91e0ceb4bd..00000000000--- a/db/migrate/20230718084649_add_create_user_permission_to_roles.rb+++ /dev/null@@ -1,17 +0,0 @@-class AddCreateUserPermissionToRoles < ActiveRecord::Migration[7.0]- class MigrationRolePermission < ApplicationRecord- self.table_name = "role_permissions"- end-- def up- role_ids = MigrationRolePermission.where(permission: "manage_user").pluck(:role_id)-- role_ids.each do |role_id|- MigrationRolePermission.create(permission: "create_user", role_id:)- end- end-- def down- MigrationRolePermission.where(permission: "create_user").delete_all- end-enddiff --git a/db/migrate/20230725165505_add_storage_name_to_storages_file_links_journals.rb b/db/migrate/20230725165505_add_storage_name_to_storages_file_links_journals.rbdeleted file mode 100644index 6c00dd82b23..00000000000--- a/db/migrate/20230725165505_add_storage_name_to_storages_file_links_journals.rb+++ /dev/null@@ -1,35 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddStorageNameToStoragesFileLinksJournals < ActiveRecord::Migration[7.0]- def change- add_column :storages_file_links_journals, :storage_name, :string- end-enddiff --git a/db/migrate/20230726061920_rename_auth_source_to_ldap_auth_source.rb b/db/migrate/20230726061920_rename_auth_source_to_ldap_auth_source.rbdeleted file mode 100644index 444a0e11c89..00000000000--- a/db/migrate/20230726061920_rename_auth_source_to_ldap_auth_source.rb+++ /dev/null@@ -1,8 +0,0 @@-class RenameAuthSourceToLdapAuthSource < ActiveRecord::Migration[7.0]- def change- rename_table :auth_sources, :ldap_auth_sources- rename_column :users, :auth_source_id, :ldap_auth_source_id- rename_column :ldap_groups_synchronized_groups, :auth_source_id, :ldap_auth_source_id- rename_column :ldap_groups_synchronized_filters, :auth_source_id, :ldap_auth_source_id- end-enddiff --git a/db/migrate/20230726112130_remove_type_from_ldap_auth_sources.rb b/db/migrate/20230726112130_remove_type_from_ldap_auth_sources.rbdeleted file mode 100644index 89f044b6d71..00000000000--- a/db/migrate/20230726112130_remove_type_from_ldap_auth_sources.rb+++ /dev/null@@ -1,5 +0,0 @@-class RemoveTypeFromLdapAuthSources < ActiveRecord::Migration[7.0]- def change- remove_column :ldap_auth_sources, :type, :string, null: false- end-enddiff --git a/db/migrate/20230803113215_add_indices_to_work_package_journals.rb b/db/migrate/20230803113215_add_indices_to_work_package_journals.rbdeleted file mode 100644index 8c836910e7a..00000000000--- a/db/migrate/20230803113215_add_indices_to_work_package_journals.rb+++ /dev/null@@ -1,16 +0,0 @@-class AddIndicesToWorkPackageJournals < ActiveRecord::Migration[7.0]- def change- add_index :work_package_journals, :assigned_to_id- add_index :work_package_journals, :author_id- add_index :work_package_journals, :category_id- add_index :work_package_journals, :parent_id- add_index :work_package_journals, :responsible_id- add_index :work_package_journals, :status_id- add_index :work_package_journals, :type_id- add_index :work_package_journals, :version_id-- add_index :work_package_journals, :schedule_manually- add_index :work_package_journals, :start_date- add_index :work_package_journals, :due_date- end-enddiff --git a/db/migrate/20230808080001_remove_some_string_length_constraints.rb b/db/migrate/20230808080001_remove_some_string_length_constraints.rbdeleted file mode 100644index 5675e442552..00000000000--- a/db/migrate/20230808080001_remove_some_string_length_constraints.rb+++ /dev/null@@ -1,17 +0,0 @@-class RemoveSomeStringLengthConstraints < ActiveRecord::Migration[7.0]- def up- change_column(:categories, :name, :string, limit: nil)- change_column(:enumerations, :name, :string, limit: nil)- change_column(:news, :title, :string, limit: nil)- change_column(:roles, :name, :string, limit: nil)- change_column(:statuses, :name, :string, limit: nil)- end-- def down- change_column(:categories, :name, :string, limit: 256)- change_column(:enumerations, :name, :string, limit: 30)- change_column(:news, :title, :string, limit: 60)- change_column(:roles, :name, :string, limit: 30)- change_column(:statuses, :name, :string, limit: 30)- end-enddiff --git a/db/migrate/20230810074642_add_optional_entity_to_members.rb b/db/migrate/20230810074642_add_optional_entity_to_members.rbdeleted file mode 100644index 95fa693d3d5..00000000000--- a/db/migrate/20230810074642_add_optional_entity_to_members.rb+++ /dev/null@@ -1,16 +0,0 @@-class AddOptionalEntityToMembers < ActiveRecord::Migration[7.0]- def change- add_reference :members, :entity, foreign_key: false, polymorphic: true, index: true- remove_index :members, %i[user_id project_id], unique: true-- add_index :members, %i[user_id project_id],- unique: true,- where: "entity_type IS NULL AND entity_id IS NULL",- name: "index_members_on_user_id_and_project_without_entity"-- add_index :members, %i[user_id project_id entity_type entity_id],- unique: true,- where: "entity_type IS NOT NULL AND entity_id IS NOT NULL",- name: "index_members_on_user_id_and_project_with_entity"- end-enddiff --git a/db/migrate/20230905126002_add_export_cover_to_custom_style.rb b/db/migrate/20230905126002_add_export_cover_to_custom_style.rbdeleted file mode 100644index 16e8c511739..00000000000--- a/db/migrate/20230905126002_add_export_cover_to_custom_style.rb+++ /dev/null@@ -1,12 +0,0 @@-class AddExportCoverToCustomStyle < ActiveRecord::Migration[7.0]- def change- add_column :custom_styles,- :export_cover,- :string,- default: nil- add_column :custom_styles,- :export_cover_text_color,- :string,- default: nil- end-enddiff --git a/db/migrate/20230911093530_remove_news_journals_title_length_constraint.rb b/db/migrate/20230911093530_remove_news_journals_title_length_constraint.rbdeleted file mode 100644index 62c3d812064..00000000000--- a/db/migrate/20230911093530_remove_news_journals_title_length_constraint.rb+++ /dev/null@@ -1,9 +0,0 @@-class RemoveNewsJournalsTitleLengthConstraint < ActiveRecord::Migration[7.0]- def up- change_column(:news_journals, :title, :string, limit: nil)- end-- def down- change_column(:news_journals, :title, :string, limit: 60)- end-enddiff --git a/db/migrate/20230912185647_add_view_shared_work_packages_permission.rb b/db/migrate/20230912185647_add_view_shared_work_packages_permission.rbdeleted file mode 100644index 36754a671ba..00000000000--- a/db/migrate/20230912185647_add_view_shared_work_packages_permission.rb+++ /dev/null@@ -1,44 +0,0 @@-# -- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-# ++--require_relative "migration_utils/permission_adder"--class AddViewSharedWorkPackagesPermission < ActiveRecord::Migration[7.0]- # Decouple ActiveRecord model from Migration- class MigrationRolePermission < ApplicationRecord- self.table_name = "role_permissions"- end-- def up- ::Migration::MigrationUtils::PermissionAdder.add(:share_work_packages, :view_shared_work_packages)- end-- def down- MigrationRolePermission.where(permission: "share_work_packages").delete_all- end-enddiff --git a/db/migrate/20231002141527_fix_default_language_value_for_chinese_simplified.rb b/db/migrate/20231002141527_fix_default_language_value_for_chinese_simplified.rbdeleted file mode 100644index 384677737c9..00000000000--- a/db/migrate/20231002141527_fix_default_language_value_for_chinese_simplified.rb+++ /dev/null@@ -1,5 +0,0 @@-class FixDefaultLanguageValueForChineseSimplified < ActiveRecord::Migration[7.0]- def up- Setting.where(name: "default_language", value: "zh").update_all(value: "zh-CN")- end-enddiff --git a/db/migrate/20231003151656_create_meeting_agenda_item_journals.rb b/db/migrate/20231003151656_create_meeting_agenda_item_journals.rbdeleted file mode 100644index 55e6c0f07e1..00000000000--- a/db/migrate/20231003151656_create_meeting_agenda_item_journals.rb+++ /dev/null@@ -1,18 +0,0 @@-class CreateMeetingAgendaItemJournals < ActiveRecord::Migration[7.0]- # rubocop:disable Rails/CreateTableWithTimestamps(RuboCop)- def change- create_table :meeting_agenda_item_journals do |t|- t.integer :journal_id- t.integer :agenda_item_id- t.integer :author_id- t.string :title- t.text :notes- t.integer :position- t.integer :duration_in_minutes- t.datetime :start_time- t.datetime :end_time- t.integer :work_package_id- end- end- # rubocop:enable Rails/CreateTableWithTimestamps(RuboCop)-enddiff --git a/db/migrate/20231005113307_role_to_project_role.rb b/db/migrate/20231005113307_role_to_project_role.rbdeleted file mode 100644index 0b1e101c34d..00000000000--- a/db/migrate/20231005113307_role_to_project_role.rb+++ /dev/null@@ -1,17 +0,0 @@-class RoleToProjectRole < ActiveRecord::Migration[7.0]- def up- rename_role("Role", "ProjectRole")- end-- def down- rename_role("ProjectRole", "Role")- end-- private-- def rename_role(from, to)- Role- .where(type: from)- .update_all(type: to)- end-enddiff --git a/db/migrate/20231012124745_add_item_type_to_meeting_agenda_items.rb b/db/migrate/20231012124745_add_item_type_to_meeting_agenda_items.rbdeleted file mode 100644index 7ccdbdd6e8a..00000000000--- a/db/migrate/20231012124745_add_item_type_to_meeting_agenda_items.rb+++ /dev/null@@ -1,10 +0,0 @@-class AddItemTypeToMeetingAgendaItems < ActiveRecord::Migration[7.0]- def change- add_column :meeting_agenda_items, :item_type, :integer, limit: 1, default: 0-- MeetingAgendaItem- .where.not(work_package_id: nil)- .or(MeetingAgendaItem.where(title: nil))- .update_all(item_type: :work_package)- end-enddiff --git a/db/migrate/20231013114720_add_item_type_to_meeting_agenda_item_journal.rb b/db/migrate/20231013114720_add_item_type_to_meeting_agenda_item_journal.rbdeleted file mode 100644index a55d1517a5f..00000000000--- a/db/migrate/20231013114720_add_item_type_to_meeting_agenda_item_journal.rb+++ /dev/null@@ -1,14 +0,0 @@-class AddItemTypeToMeetingAgendaItemJournal < ActiveRecord::Migration[7.0]- def change- add_column :meeting_agenda_item_journals, :item_type, :integer, limit: 1-- Journal::MeetingAgendaItemJournal- .where.not(work_package_id: nil)- .or(Journal::MeetingAgendaItemJournal.where(title: nil))- .update_all(item_type: :work_package)-- Journal::MeetingAgendaItemJournal- .where(item_type: nil)- .update_all(item_type: :simple)- end-enddiff --git a/db/migrate/20231017093339_add_allow_non_open_versions_to_custom_fields.rb b/db/migrate/20231017093339_add_allow_non_open_versions_to_custom_fields.rbdeleted file mode 100644index 91e6abb15d2..00000000000--- a/db/migrate/20231017093339_add_allow_non_open_versions_to_custom_fields.rb+++ /dev/null@@ -1,5 +0,0 @@-class AddAllowNonOpenVersionsToCustomFields < ActiveRecord::Migration[7.0]- def change- add_column :custom_fields, :allow_non_open_versions, :boolean, default: false- end-enddiff --git a/db/migrate/20231020154219_add_trgm_index_to_meeting_agenda_item_notes.rb b/db/migrate/20231020154219_add_trgm_index_to_meeting_agenda_item_notes.rbdeleted file mode 100644index 6a13b16c0f5..00000000000--- a/db/migrate/20231020154219_add_trgm_index_to_meeting_agenda_item_notes.rb+++ /dev/null@@ -1,11 +0,0 @@-class AddTrgmIndexToMeetingAgendaItemNotes < ActiveRecord::Migration[7.0]- def change- # A previous migration 20230328154645_add_gin_trgm_index_on_journals_and_custom_values- # already enabled on the extension. Hence we do not attempt to enable it here, just- # to use it if its available.-- if extensions.include?("pg_trgm")- add_index(:meeting_agenda_items, :notes, using: "gin", opclass: :gin_trgm_ops)- end- end-enddiff --git a/db/migrate/20231024150429_add_shared_to_notification_settings.rb b/db/migrate/20231024150429_add_shared_to_notification_settings.rbdeleted file mode 100644index 5d936873f8e..00000000000--- a/db/migrate/20231024150429_add_shared_to_notification_settings.rb+++ /dev/null@@ -1,5 +0,0 @@-class AddSharedToNotificationSettings < ActiveRecord::Migration[7.0]- def change- add_column :notification_settings, :shared, :boolean, default: false, null: false- end-enddiff --git a/db/migrate/20231025144701_migrate_agenda_item_permissions.rb b/db/migrate/20231025144701_migrate_agenda_item_permissions.rbdeleted file mode 100644index 74fa9ef447c..00000000000--- a/db/migrate/20231025144701_migrate_agenda_item_permissions.rb+++ /dev/null@@ -1,37 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class MigrateAgendaItemPermissions < ActiveRecord::Migration[7.0]- def up- RolePermission.where(permission: "create_meeting_agendas").update_all(permission: "manage_agendas")- end-- def down- RolePermission.where(permission: "manage_agendas").update_all(permission: "create_meeting_agendas")- end-enddiff --git a/db/migrate/20231026111049_add_public_permissions_to_project_roles.rb b/db/migrate/20231026111049_add_public_permissions_to_project_roles.rbdeleted file mode 100644index 207ddd433fe..00000000000--- a/db/migrate/20231026111049_add_public_permissions_to_project_roles.rb+++ /dev/null@@ -1,13 +0,0 @@-class AddPublicPermissionsToProjectRoles < ActiveRecord::Migration[7.0]- def up- ProjectRole.find_each do |role|- role.add_permission! *OpenProject::AccessControl.public_permissions.map(&:name)- end- end-- def down- ProjectRole.find_each do |role|- role.remove_permission! *OpenProject::AccessControl.public_permissions.map(&:name)- end- end-enddiff --git a/db/migrate/20231027102747_rollback_create_meeting_agendas_and_split_edit_meeting_role.rb b/db/migrate/20231027102747_rollback_create_meeting_agendas_and_split_edit_meeting_role.rbdeleted file mode 100644index a873bdf8d09..00000000000--- a/db/migrate/20231027102747_rollback_create_meeting_agendas_and_split_edit_meeting_role.rb+++ /dev/null@@ -1,46 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require Rails.root.join("db/migrate/migration_utils/permission_adder")--class RollbackCreateMeetingAgendasAndSplitEditMeetingRole < ActiveRecord::Migration[7.0]- def up- # Rollback the create_meeting_agendas permission- RolePermission.where(permission: "manage_agendas").update_all(permission: "create_meeting_agendas")-- # Introduce manage_agendas permission, that is being split from the edit_meeting permission- ::Migration::MigrationUtils::PermissionAdder- .add(:edit_meetings,- :manage_agendas)- end-- def down- RolePermission.where(permission: "manage_agendas").destroy_all- RolePermission.where(permission: "create_meeting_agendas").update_all(permission: "manage_agendas")- end-enddiff --git a/db/migrate/20231031133334_create_project_custom_field_project_mappings.rb b/db/migrate/20231031133334_create_project_custom_field_project_mappings.rbdeleted file mode 100644index ff9580a45df..00000000000--- a/db/migrate/20231031133334_create_project_custom_field_project_mappings.rb+++ /dev/null@@ -1,34 +0,0 @@-class CreateProjectCustomFieldProjectMappings < ActiveRecord::Migration[7.0]- def up- create_table :project_custom_field_project_mappings do |t|- t.references :custom_field, foreign_key: true, index: {- name: "index_project_cf_project_mappings_on_custom_field_id"- }- t.references :project, foreign_key: true-- t.timestamps- end-- create_default_mapping- end-- def down- drop_table :project_custom_field_project_mappings- end-- private-- def create_default_mapping- project_ids = Project.pluck(:id)- custom_field_ids = ProjectCustomField.pluck(:id)- mappings = []-- project_ids.each do |project_id|- custom_field_ids.each do |custom_field_id|- mappings << { custom_field_id:, project_id: }- end- end-- ProjectCustomFieldProjectMapping.create!(mappings)- end-enddiff --git a/db/migrate/20231105194747_add_data_to_tokens.rb b/db/migrate/20231105194747_add_data_to_tokens.rbdeleted file mode 100644index fd828475cb9..00000000000--- a/db/migrate/20231105194747_add_data_to_tokens.rb+++ /dev/null@@ -1,5 +0,0 @@-class AddDataToTokens < ActiveRecord::Migration[7.0]- def change- add_column :tokens, :data, :json, null: true- end-enddiff --git a/db/migrate/20231119192222_add_locking_to_meeting.rb b/db/migrate/20231119192222_add_locking_to_meeting.rbdeleted file mode 100644index e113c0bce58..00000000000--- a/db/migrate/20231119192222_add_locking_to_meeting.rb+++ /dev/null@@ -1,6 +0,0 @@-class AddLockingToMeeting < ActiveRecord::Migration[7.0]- def change- add_column :meetings, :lock_version, :integer, default: 0, null: false- add_column :meeting_agenda_items, :lock_version, :integer, default: 0, null: false- end-enddiff --git a/db/migrate/20231123111357_create_custom_field_sections.rb b/db/migrate/20231123111357_create_custom_field_sections.rbdeleted file mode 100644index 924583439f9..00000000000--- a/db/migrate/20231123111357_create_custom_field_sections.rb+++ /dev/null@@ -1,87 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require_relative "migration_utils/utils"--class CreateCustomFieldSections < ActiveRecord::Migration[7.0]- include ::Migration::Utils-- def up- create_table :custom_field_sections do |t|- t.integer :position- t.string :name- t.string :type # project or nil (-> work_package)-- t.timestamps- end-- add_reference :custom_fields, :custom_field_section- add_column :custom_fields, :position_in_custom_field_section, :integer, null: true-- create_and_assign_default_section- end-- def down- remove_reference :custom_fields, :custom_field_section- remove_column :custom_fields, :position_in_custom_field_section- drop_table :custom_field_sections- end-- private-- def create_and_assign_default_section- create_section_sql = <<~SQL.squish- INSERT INTO "custom_field_sections" ("position", "name", "type", "created_at", "updated_at")- VALUES (:position, :name, :type, :created_at, :updated_at)- RETURNING "id"- SQL-- now = Time.current-- insert_result =- execute_sql create_section_sql, type: "ProjectCustomFieldSection", name: "Project attributes",- position: 1, created_at: now, updated_at: now-- update_sql = <<~SQL.squish- UPDATE "custom_fields"- SET- "position_in_custom_field_section" = "mapping"."new_position",- "custom_field_section_id" = :section_id- FROM (- SELECT- id,- ROW_NUMBER() OVER (ORDER BY updated_at) AS new_position- FROM "custom_fields"- WHERE "custom_fields"."type" = 'ProjectCustomField'- ) AS "mapping"- WHERE "custom_fields"."id" = "mapping"."id";- SQL-- execute_sql(update_sql, section_id: insert_result.first["id"])- end-enddiff --git a/db/migrate/20231128080650_add_work_package_roles.rb b/db/migrate/20231128080650_add_work_package_roles.rbdeleted file mode 100644index 4143842141a..00000000000--- a/db/migrate/20231128080650_add_work_package_roles.rb+++ /dev/null@@ -1,65 +0,0 @@-class AddWorkPackageRoles < ActiveRecord::Migration[7.0]- def up- # This is how the role was seeded in the first iteration of seeds- editor_role = WorkPackageRole.find_by(builtin: Role::NON_BUILTIN, name: "Work Package Editor")- # If we couldn't find a WP from the first iteration of the seeds, find it by the builtin- editor_role ||= WorkPackageRole.find_or_initialize_by(builtin: Role::BUILTIN_WORK_PACKAGE_EDITOR)-- editor_role.update!(- builtin: Role::BUILTIN_WORK_PACKAGE_EDITOR,- name: I18n.t("seeds.common.work_package_roles.item_0.name", default: "Work package editor"),- permissions: %i[- view_work_packages- edit_work_packages- work_package_assigned- add_work_package_notes- edit_own_work_package_notes- manage_work_package_relations- copy_work_packages- export_work_packages- view_own_time_entries- log_own_time- edit_own_time_entries- show_github_content- view_file_links- ]- )-- # This is how the role was seeded in the first iteration of seeds- commenter_role = WorkPackageRole.find_by(builtin: Role::NON_BUILTIN, name: "Work Package Commenter")- # If we couldn't find a WP from the first iteration of the seeds, find it by the builtin- commenter_role ||= WorkPackageRole.find_or_initialize_by(builtin: Role::BUILTIN_WORK_PACKAGE_COMMENTER)- commenter_role.update!(- builtin: Role::BUILTIN_WORK_PACKAGE_COMMENTER,- name: I18n.t("seeds.common.work_package_roles.item_1.name", default: "Work package commenter"),- permissions: %i[- view_work_packages- work_package_assigned- add_work_package_notes- add_work_package_attachments- edit_own_work_package_notes- export_work_packages- view_own_time_entries- log_own_time- edit_own_time_entries- show_github_content- view_file_links- ]- )-- # This is how the role was seeded in the first iteration of seeds- viewer_role = WorkPackageRole.find_by(builtin: Role::NON_BUILTIN, name: "Work Package Viewer")- # If we couldn't find a WP from the first iteration of the seeds, find it by the builtin- viewer_role ||= WorkPackageRole.find_or_initialize_by(builtin: Role::BUILTIN_WORK_PACKAGE_VIEWER)- # Set up attributes- viewer_role.update!(- builtin: Role::BUILTIN_WORK_PACKAGE_VIEWER,- name: I18n.t("seeds.common.work_package_roles.item_2.name", default: "Work package viewer"),- permissions: %i[- view_work_packages- export_work_packages- show_github_content- ]- )- end-enddiff --git a/db/migrate/20231201085450_change_view_of_queries_with_timeline_to_gantt.rb b/db/migrate/20231201085450_change_view_of_queries_with_timeline_to_gantt.rbdeleted file mode 100644index d8d220a7a58..00000000000--- a/db/migrate/20231201085450_change_view_of_queries_with_timeline_to_gantt.rb+++ /dev/null@@ -1,32 +0,0 @@-class ChangeViewOfQueriesWithTimelineToGantt < ActiveRecord::Migration[7.0]- class MigrationQuery < ApplicationRecord- self.table_name = "queries"- end-- class MigrationView < ApplicationRecord- self.table_name = "views"-- # disable STI- self.inheritance_column = :_type_disabled-- belongs_to :query, class_name: "MigrationQuery"- end-- def up- update_view_type_for_timeline_queries(from_view_type: "work_packages_table", to_view_type: "gantt")- end-- def down- update_view_type_for_timeline_queries(from_view_type: "gantt", to_view_type: "work_packages_table")- end-- private-- def update_view_type_for_timeline_queries(from_view_type:, to_view_type:)- MigrationView- .joins(:query)- .where("queries.timeline_visible": true)- .where(type: from_view_type)- .update_all(type: to_view_type)- end-enddiff --git a/db/migrate/20231205143648_add_add_work_package_attachment_permission_to_commenters.rb b/db/migrate/20231205143648_add_add_work_package_attachment_permission_to_commenters.rbdeleted file mode 100644index 517e4fe678e..00000000000--- a/db/migrate/20231205143648_add_add_work_package_attachment_permission_to_commenters.rb+++ /dev/null@@ -1,9 +0,0 @@-class AddAddWorkPackageAttachmentPermissionToCommenters < ActiveRecord::Migration[7.0]- def up- WorkPackageRole.find_by(builtin: Role::BUILTIN_WORK_PACKAGE_COMMENTER).add_permission! :add_work_package_attachments- end-- def down- WorkPackageRole.find_by(builtin: Role::BUILTIN_WORK_PACKAGE_COMMENTER).remove_permission! :add_work_package_attachments- end-enddiff --git a/db/migrate/20231212131603_set_custom_fields_filter_default_true.rb b/db/migrate/20231212131603_set_custom_fields_filter_default_true.rbdeleted file mode 100644index dedb75a252e..00000000000--- a/db/migrate/20231212131603_set_custom_fields_filter_default_true.rb+++ /dev/null@@ -1,9 +0,0 @@-class SetCustomFieldsFilterDefaultTrue < ActiveRecord::Migration[7.0]- def up- change_column_default :custom_fields, :is_filter, true- end-- def down- change_column_default :custom_fields, :is_filter, false- end-enddiff --git a/db/migrate/20231227100753_fix_derived_work_and_remaining_work_values.rb b/db/migrate/20231227100753_fix_derived_work_and_remaining_work_values.rbdeleted file mode 100644index 4a8c3028870..00000000000--- a/db/migrate/20231227100753_fix_derived_work_and_remaining_work_values.rb+++ /dev/null@@ -1,71 +0,0 @@-class FixDerivedWorkAndRemainingWorkValues < ActiveRecord::Migration[7.0]- def up- execute(update_derived_values_as_sum_of_self_and_descendants_sql)- end-- def down- execute(update_derived_values_as_sum_of_descendants_sql)- execute(update_leaf_derived_values_to_null_sql)- end-- def update_derived_values_as_sum_of_self_and_descendants_sql- <<~SQL.squish- WITH wp_derived AS (- SELECT- wph.ancestor_id AS id,- sum(wp.estimated_hours) AS estimated_hours_sum,- sum(wp.remaining_hours) AS remaining_hours_sum- FROM work_package_hierarchies wph- LEFT JOIN work_packages wp ON wph.descendant_id = wp.id- GROUP BY wph.ancestor_id- )- UPDATE- work_packages- SET- derived_estimated_hours = wp_derived.estimated_hours_sum,- derived_remaining_hours = wp_derived.remaining_hours_sum- FROM- wp_derived- WHERE work_packages.id = wp_derived.id- SQL- end-- def update_derived_values_as_sum_of_descendants_sql- <<~SQL.squish- WITH wp_derived AS (- SELECT- wph.ancestor_id AS id,- sum(wp.estimated_hours) AS estimated_hours_sum,- sum(wp.remaining_hours) AS remaining_hours_sum- FROM work_package_hierarchies wph- LEFT JOIN work_packages wp ON wph.descendant_id = wp.id- WHERE wph.ancestor_id != wph.descendant_id- GROUP BY wph.ancestor_id- )- UPDATE- work_packages- SET- derived_estimated_hours = wp_derived.estimated_hours_sum,- derived_remaining_hours = wp_derived.remaining_hours_sum- FROM- wp_derived- WHERE work_packages.id = wp_derived.id- SQL- end-- def update_leaf_derived_values_to_null_sql- <<~SQL.squish- UPDATE- work_packages- SET- derived_estimated_hours = NULL,- derived_remaining_hours = NULL- WHERE- id NOT IN (- SELECT ancestor_id- FROM work_package_hierarchies- WHERE generations > 0- )- SQL- end-enddiff --git a/db/migrate/20240104172050_add_project_queries.rb b/db/migrate/20240104172050_add_project_queries.rbdeleted file mode 100644index 4295cac5f50..00000000000--- a/db/migrate/20240104172050_add_project_queries.rb+++ /dev/null@@ -1,13 +0,0 @@-class AddProjectQueries < ActiveRecord::Migration[7.0]- def change- create_table :project_queries do |t|- t.string :name, null: false- t.references :user, null: false- t.json :filters, default: []- t.json :columns, default: []- t.json :orders, default: []-- t.timestamps- end- end-enddiff --git a/db/migrate/20240115112549_fix_spent_time_widget_identifier.rb b/db/migrate/20240115112549_fix_spent_time_widget_identifier.rbdeleted file mode 100644index eb1e7e62ace..00000000000--- a/db/migrate/20240115112549_fix_spent_time_widget_identifier.rb+++ /dev/null@@ -1,9 +0,0 @@-class FixSpentTimeWidgetIdentifier < ActiveRecord::Migration[7.0]- def up- execute("UPDATE grid_widgets SET identifier = 'time_entries_list' WHERE identifier = 'time_entries_project'")- end-- def down- execute("UPDATE grid_widgets SET identifier = 'time_entries_project' WHERE identifier = 'time_entries_list'")- end-enddiff --git a/db/migrate/20240123151246_create_good_jobs.rb b/db/migrate/20240123151246_create_good_jobs.rbdeleted file mode 100644index a476bd5069d..00000000000--- a/db/migrate/20240123151246_create_good_jobs.rb+++ /dev/null@@ -1,43 +0,0 @@-# frozen_string_literal: true--class CreateGoodJobs < ActiveRecord::Migration[7.0]- def change- # Uncomment for Postgres v12 or earlier to enable gen_random_uuid() support- # enable_extension 'pgcrypto'-- create_table :good_jobs, id: :uuid do |t|- t.text :queue_name- t.integer :priority- t.jsonb :serialized_params- t.datetime :scheduled_at- t.datetime :performed_at- t.datetime :finished_at- t.text :error-- t.timestamps-- t.uuid :active_job_id- t.text :concurrency_key- t.text :cron_key- t.uuid :retried_good_job_id- t.datetime :cron_at- end-- create_table :good_job_processes, id: :uuid do |t|- t.timestamps- t.jsonb :state- end-- add_index :good_jobs, :scheduled_at, where: "(finished_at IS NULL)", name: :index_good_jobs_on_scheduled_at- add_index :good_jobs, %i[queue_name scheduled_at], where: "(finished_at IS NULL)",- name: :index_good_jobs_on_queue_name_and_scheduled_at- add_index :good_jobs, %i[active_job_id created_at], name: :index_good_jobs_on_active_job_id_and_created_at- add_index :good_jobs, :concurrency_key, where: "(finished_at IS NULL)",- name: :index_good_jobs_on_concurrency_key_when_unfinished- add_index :good_jobs, %i[cron_key created_at], name: :index_good_jobs_on_cron_key_and_created_at- add_index :good_jobs, %i[cron_key cron_at], name: :index_good_jobs_on_cron_key_and_cron_at, unique: true- add_index :good_jobs, [:active_job_id], name: :index_good_jobs_on_active_job_id- add_index :good_jobs, [:finished_at], where: "retried_good_job_id IS NULL AND finished_at IS NOT NULL",- name: :index_good_jobs_jobs_on_finished_at- end-enddiff --git a/db/migrate/20240123151247_create_good_job_settings.rb b/db/migrate/20240123151247_create_good_job_settings.rbdeleted file mode 100644index fa3540174a6..00000000000--- a/db/migrate/20240123151247_create_good_job_settings.rb+++ /dev/null@@ -1,20 +0,0 @@-# frozen_string_literal: true--class CreateGoodJobSettings < ActiveRecord::Migration[7.0]- def change- reversible do |dir|- dir.up do- # Ensure this incremental update migration is idempotent- # with monolithic install migration.- return if connection.table_exists?(:good_job_settings)- end- end-- create_table :good_job_settings, id: :uuid do |t|- t.timestamps- t.text :key- t.jsonb :value- t.index :key, unique: true- end- end-enddiff --git a/db/migrate/20240123151248_create_index_good_jobs_jobs_on_priority_created_at_when_unfinished.rb b/db/migrate/20240123151248_create_index_good_jobs_jobs_on_priority_created_at_when_unfinished.rbdeleted file mode 100644index aaa5a52cd1c..00000000000--- a/db/migrate/20240123151248_create_index_good_jobs_jobs_on_priority_created_at_when_unfinished.rb+++ /dev/null@@ -1,20 +0,0 @@-# frozen_string_literal: true--class CreateIndexGoodJobsJobsOnPriorityCreatedAtWhenUnfinished < ActiveRecord::Migration[7.0]- disable_ddl_transaction!-- def change- reversible do |dir|- dir.up do- # Ensure this incremental update migration is idempotent- # with monolithic install migration.- return if connection.index_name_exists?(:good_jobs, :index_good_jobs_jobs_on_priority_created_at_when_unfinished)- end- end-- add_index :good_jobs, %i[priority created_at], order: { priority: "DESC NULLS LAST", created_at: :asc },- where: "finished_at IS NULL",- name: :index_good_jobs_jobs_on_priority_created_at_when_unfinished,- algorithm: :concurrently- end-enddiff --git a/db/migrate/20240123151249_create_good_job_batches.rb b/db/migrate/20240123151249_create_good_job_batches.rbdeleted file mode 100644index ac6c5b37e98..00000000000--- a/db/migrate/20240123151249_create_good_job_batches.rb+++ /dev/null@@ -1,35 +0,0 @@-# frozen_string_literal: true--class CreateGoodJobBatches < ActiveRecord::Migration[7.0]- def change- reversible do |dir|- dir.up do- # Ensure this incremental update migration is idempotent- # with monolithic install migration.- return if connection.table_exists?(:good_job_batches)- end- end-- create_table :good_job_batches, id: :uuid do |t|- t.timestamps- t.text :description- t.jsonb :serialized_properties- t.text :on_finish- t.text :on_success- t.text :on_discard- t.text :callback_queue_name- t.integer :callback_priority- t.datetime :enqueued_at- t.datetime :discarded_at- t.datetime :finished_at- end-- change_table :good_jobs do |t|- t.uuid :batch_id- t.uuid :batch_callback_id-- t.index :batch_id, where: "batch_id IS NOT NULL"- t.index :batch_callback_id, where: "batch_callback_id IS NOT NULL"- end- end-enddiff --git a/db/migrate/20240123151250_create_good_job_executions.rb b/db/migrate/20240123151250_create_good_job_executions.rbdeleted file mode 100644index 5722a38edc5..00000000000--- a/db/migrate/20240123151250_create_good_job_executions.rb+++ /dev/null@@ -1,33 +0,0 @@-# frozen_string_literal: true--class CreateGoodJobExecutions < ActiveRecord::Migration[7.0]- def change- reversible do |dir|- dir.up do- # Ensure this incremental update migration is idempotent- # with monolithic install migration.- return if connection.table_exists?(:good_job_executions)- end- end-- create_table :good_job_executions, id: :uuid do |t|- t.timestamps-- t.uuid :active_job_id, null: false- t.text :job_class- t.text :queue_name- t.jsonb :serialized_params- t.datetime :scheduled_at- t.datetime :finished_at- t.text :error-- t.index %i[active_job_id created_at], name: :index_good_job_executions_on_active_job_id_and_created_at- end-- change_table :good_jobs do |t|- t.boolean :is_discrete- t.integer :executions_count- t.text :job_class- end- end-enddiff --git a/db/migrate/20240123151251_create_good_jobs_error_event.rb b/db/migrate/20240123151251_create_good_jobs_error_event.rbdeleted file mode 100644index b07e0f14e7f..00000000000--- a/db/migrate/20240123151251_create_good_jobs_error_event.rb+++ /dev/null@@ -1,16 +0,0 @@-# frozen_string_literal: true--class CreateGoodJobsErrorEvent < ActiveRecord::Migration[7.0]- def change- reversible do |dir|- dir.up do- # Ensure this incremental update migration is idempotent- # with monolithic install migration.- return if connection.column_exists?(:good_jobs, :error_event)- end- end-- add_column :good_jobs, :error_event, :integer, limit: 2- add_column :good_job_executions, :error_event, :integer, limit: 2- end-enddiff --git a/db/migrate/20240123151252_recreate_good_job_cron_indexes_with_conditional.rb b/db/migrate/20240123151252_recreate_good_job_cron_indexes_with_conditional.rbdeleted file mode 100644index 83c94a8a605..00000000000--- a/db/migrate/20240123151252_recreate_good_job_cron_indexes_with_conditional.rb+++ /dev/null@@ -1,49 +0,0 @@-# frozen_string_literal: true--class RecreateGoodJobCronIndexesWithConditional < ActiveRecord::Migration[7.0]- disable_ddl_transaction!-- def change- reversible do |dir|- dir.up do- unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_created_at_cond)- add_index :good_jobs, %i[cron_key created_at], where: "(cron_key IS NOT NULL)",- name: :index_good_jobs_on_cron_key_and_created_at_cond,- algorithm: :concurrently- end- unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_cron_at_cond)- add_index :good_jobs, %i[cron_key cron_at], where: "(cron_key IS NOT NULL)",- unique: true,- name: :index_good_jobs_on_cron_key_and_cron_at_cond,- algorithm: :concurrently- end-- if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_created_at)- remove_index :good_jobs, name: :index_good_jobs_on_cron_key_and_created_at- end- if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_cron_at)- remove_index :good_jobs, name: :index_good_jobs_on_cron_key_and_cron_at- end- end-- dir.down do- unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_created_at)- add_index :good_jobs, %i[cron_key created_at], name: :index_good_jobs_on_cron_key_and_created_at,- algorithm: :concurrently- end- unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_cron_at)- add_index :good_jobs, %i[cron_key cron_at], unique: true,- name: :index_good_jobs_on_cron_key_and_cron_at,- algorithm: :concurrently- end-- if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_created_at_cond)- remove_index :good_jobs, name: :index_good_jobs_on_cron_key_and_created_at_cond- end- if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_cron_at_cond)- remove_index :good_jobs, name: :index_good_jobs_on_cron_key_and_cron_at_cond- end- end- end- end-enddiff --git a/db/migrate/20240131130134_fix_inherited_group_memberships.rb b/db/migrate/20240131130134_fix_inherited_group_memberships.rbdeleted file mode 100644index 5740d8e2e2f..00000000000--- a/db/migrate/20240131130134_fix_inherited_group_memberships.rb+++ /dev/null@@ -1,19 +0,0 @@-class FixInheritedGroupMemberships < ActiveRecord::Migration[7.0]- def up- # Recreate member_roles for all group members- # due to regression https://community.openproject.org/work_packages/52528- Group.reset_column_information- Group- .where(id: Member.where(project_id: nil, user_id: Group.select(:id)).select(:user_id))- .find_each do |group|- warn "Creating inherited roles for group ##{group.id}"- Groups::CreateInheritedRolesService- .new(group, current_user: User.system, contract_class: EmptyContract)- .call(user_ids: group.user_ids, send_notifications: false, project_ids: nil)- end- end-- def down- # Nothing to do- end-enddiff --git a/db/migrate/20240131130149_enable_gantt_module_for_all_projects.rb b/db/migrate/20240131130149_enable_gantt_module_for_all_projects.rbdeleted file mode 100644index ef7c1484219..00000000000--- a/db/migrate/20240131130149_enable_gantt_module_for_all_projects.rb+++ /dev/null@@ -1,19 +0,0 @@-require_relative "migration_utils/utils"--class EnableGanttModuleForAllProjects < ActiveRecord::Migration[7.0]- include ::Migration::Utils-- def up- execute_sql "- INSERT INTO enabled_modules (project_id, name)- SELECT id, 'gantt' FROM projects- WHERE id NOT IN (SELECT project_id FROM enabled_modules WHERE name = 'gantt')- AND id IN (SELECT project_id FROM enabled_modules WHERE name = 'work_package_tracking')- AND active;- "- end-- def down- execute_sql "DELETE FROM enabled_modules WHERE name = 'gantt'"- end-enddiff --git a/db/migrate/20240201115019_add_gantt_module_to_default_modules.rb b/db/migrate/20240201115019_add_gantt_module_to_default_modules.rbdeleted file mode 100644index 2e745e036b5..00000000000--- a/db/migrate/20240201115019_add_gantt_module_to_default_modules.rb+++ /dev/null@@ -1,11 +0,0 @@-class AddGanttModuleToDefaultModules < ActiveRecord::Migration[7.0]- def up- if Setting.default_projects_modules_writable? && Setting.default_projects_modules&.exclude?("gantt")- Setting.default_projects_modules = Setting.default_projects_modules + ["gantt"]- end- end-- def down- # Nothing to do- end-enddiff --git a/db/migrate/20240206085104_remove_enums.rb b/db/migrate/20240206085104_remove_enums.rbdeleted file mode 100644index c8970601044..00000000000--- a/db/migrate/20240206085104_remove_enums.rb+++ /dev/null@@ -1,73 +0,0 @@-class RemoveEnums < ActiveRecord::Migration[7.1]- def up- change_column(:storages, :health_status, :string, default: "pending")- add_check_constraint(:storages,- "health_status IN ('pending', 'healthy', 'unhealthy')",- name: "storages_health_status_check")-- change_column(:last_project_folders, :mode, :string, default: "inactive")- add_check_constraint(:last_project_folders,- "mode IN ('inactive', 'manual', 'automatic')",- name: "last_project_folders_mode_check")-- change_column(:project_storages, :project_folder_mode, :string)- add_check_constraint(:project_storages,- "project_folder_mode IN ('inactive', 'manual', 'automatic')",- name: "project_storages_project_folder_mode_check")-- change_column(:delayed_job_statuses, :status, :string, default: "in_queue")- add_check_constraint(:delayed_job_statuses,- "status IS NULL OR status IN ('in_queue', 'error', 'in_process', 'success', 'failure', 'cancelled')",- name: "delayed_job_statuses_status_check")-- execute <<~SQL.squish- DROP TYPE delayed_job_status RESTRICT;- DROP TYPE project_folder_modes RESTRICT;- DROP TYPE storage_health_statuses RESTRICT;- SQL- end-- def down- execute <<~SQL.squish- CREATE TYPE delayed_job_status AS ENUM (- 'in_queue',- 'error',- 'in_process',- 'success',- 'failure',- 'cancelled'- );-- CREATE TYPE project_folder_modes AS ENUM (- 'inactive',- 'manual',- 'automatic'- );-- CREATE TYPE storage_health_statuses AS ENUM (- 'pending',- 'healthy',- 'unhealthy'- );- SQL-- remove_check_constraint(:storages, name: "storages_health_status_check")- change_column(:storages, :health_status, :storage_health_statuses, default: nil,- using: "health_status::storage_health_statuses")-- remove_check_constraint(:last_project_folders, name: "last_project_folders_mode_check")-- change_column_default(:storages, :health_status, "pending")-- change_column(:last_project_folders, :mode, :project_folder_modes, default: nil, using: "mode::project_folder_modes")- change_column_default(:last_project_folders, :mode, "inactive")-- remove_check_constraint(:project_storages, name: "project_storages_project_folder_mode_check")- change_column(:project_storages, :project_folder_mode, :project_folder_modes, default: nil,- using: "project_folder_mode::project_folder_modes")-- remove_check_constraint(:delayed_job_statuses, name: "delayed_job_statuses_status_check")- change_column(:delayed_job_statuses, :status, :delayed_job_status, default: nil, using: "status::delayed_job_status")- change_column_default(:delayed_job_statuses, :status, "in_queue")- end-enddiff --git a/db/migrate/20240206173841_fix_untranslated_work_package_roles.rb b/db/migrate/20240206173841_fix_untranslated_work_package_roles.rbdeleted file mode 100644index 5e485681155..00000000000--- a/db/migrate/20240206173841_fix_untranslated_work_package_roles.rb+++ /dev/null@@ -1,14 +0,0 @@-class FixUntranslatedWorkPackageRoles < ActiveRecord::Migration[7.1]- def up- seed_work_package_roles_data.each_value do |work_package_role_data|- work_package_role = WorkPackageRole.find_by(builtin: work_package_role_data[:builtin])- work_package_role&.update(name: work_package_role_data[:name])- end- end-- def seed_work_package_roles_data- seed_data = RootSeeder.new.translated_seed_data_for("work_package_roles", "modules_permissions")- seeder = BasicData::WorkPackageRoleSeeder.new(seed_data)- seeder.mapped_models_data- end-enddiff --git a/db/migrate/20240207075946_add_status_to_attachment.rb b/db/migrate/20240207075946_add_status_to_attachment.rbdeleted file mode 100644index 316644ce3af..00000000000--- a/db/migrate/20240207075946_add_status_to_attachment.rb+++ /dev/null@@ -1,5 +0,0 @@-class AddStatusToAttachment < ActiveRecord::Migration[7.1]- def change- add_column :attachments, :status, :integer, default: 0, null: false- end-enddiff --git a/db/migrate/20240208100316_enable_required_project_custom_fields_in_all_projects.rb b/db/migrate/20240208100316_enable_required_project_custom_fields_in_all_projects.rbdeleted file mode 100644index 66e98d87c49..00000000000--- a/db/migrate/20240208100316_enable_required_project_custom_fields_in_all_projects.rb+++ /dev/null@@ -1,28 +0,0 @@-class EnableRequiredProjectCustomFieldsInAllProjects < ActiveRecord::Migration[7.1]- def up- required_custom_field_ids = ProjectCustomField.required.ids-- # Gather the custom_field_ids for every project, then add a new mapping- # of {project_id:, custom_field_id:} for every project that does not have- # the required required_custom_field_ids activated.- missing_custom_field_attributes =- Project- .includes(:project_custom_field_project_mappings)- .pluck(:id, "project_custom_field_project_mappings.custom_field_id")- .group_by(&:first)- .transform_values { |values| values.map(&:last) }- .reduce([]) do |acc, (project_id, custom_field_ids)|- missing_custom_field_ids = required_custom_field_ids - custom_field_ids-- acc + missing_custom_field_ids.map do |custom_field_id|- { project_id:, custom_field_id: }- end- end-- ProjectCustomFieldProjectMapping.insert_all!(missing_custom_field_attributes)- end-- def down- # reversing this migration is not possible as we don't store the original state- end-enddiff --git a/db/migrate/20240222155909_rename_columns_on_project_queries.rb b/db/migrate/20240222155909_rename_columns_on_project_queries.rbdeleted file mode 100644index 1df6de61730..00000000000--- a/db/migrate/20240222155909_rename_columns_on_project_queries.rb+++ /dev/null@@ -1,21 +0,0 @@-class RenameColumnsOnProjectQueries < ActiveRecord::Migration[7.1]- def change- rename_column :project_queries, :columns, :selects-- reversible do |dir|- dir.up do- execute <<~SQL.squish- UPDATE project_queries- SET selects = '#{Setting.enabled_projects_columns}'- SQL- end-- dir.down do- execute <<~SQL.squish- UPDATE project_queries- SET selects = '[]'- SQL- end- end- end-enddiff --git a/db/migrate/20240227154544_remove_delayed_jobs.rb b/db/migrate/20240227154544_remove_delayed_jobs.rbdeleted file mode 100644index 58c06b87dcd..00000000000--- a/db/migrate/20240227154544_remove_delayed_jobs.rb+++ /dev/null@@ -1,89 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RemoveDelayedJobs < ActiveRecord::Migration[7.1]- # it is needed, because ActiveJob::QueueAdapters::DelayedJobAdapter::JobWrapper- # can not be used without required delayed_job- # See https://github.com/rails/rails/blob/6f0d1ad14b92b9f5906e44740fce8b4f1c7075dc/activejob/lib/active_job/queue_adapters/delayed_job_adapter.rb- class JobWrapperDeserializationMock- attr_accessor :job_data-- def initialize(job_data)- @job_data = job_data- end- end-- def change- reversible do |direction|- direction.up do- tuples = execute <<~SQL- select * from delayed_jobs- where locked_by is null -- not in progress- and handler NOT LIKE '%job_class: Storages::ManageNextcloudIntegrationEventsJob%' -- no need to migrate. It will be run later with cron.- and cron is null -- not cron schedule- FOR UPDATE; -- to prevent potentialy running delayed_job process working on these jobs(delayed_job uses SELECT FOR UPDATE to get workable jobs)- SQL- tuples.each do |tuple|- handler = tuple["handler"].gsub("ruby/object:ActiveJob::QueueAdapters::DelayedJobAdapter::JobWrapper",- "ruby/object:#{RemoveDelayedJobs::JobWrapperDeserializationMock.name}")- job_data = YAML.load(handler, permitted_classes: [RemoveDelayedJobs::JobWrapperDeserializationMock])- .job_data- new_uuid = SecureRandom.uuid- good_job_record = GoodJob::BaseExecution.new- good_job_record.id = new_uuid- good_job_record.serialized_params = job_data- good_job_record.serialized_params["job_id"] = new_uuid- good_job_record.queue_name = job_data["queue_name"]- good_job_record.priority = job_data["priority"]- good_job_record.scheduled_at = job_data["scheduled_at"]- good_job_record.active_job_id = new_uuid- good_job_record.concurrency_key = nil- good_job_record.job_class = job_data["job_class"]- good_job_record.save!- end- end- direction.down {}- end-- drop_table :delayed_jobs do |t|- t.integer :priority, default: 0- t.integer :attempts, default: 0- t.text :handler- t.text :last_error- t.datetime :run_at- t.datetime :locked_at- t.datetime :failed_at- t.string :locked_by- t.timestamps null: true- t.string :queue- t.string :cron-- t.index %i[priority run_at], name: "delayed_jobs_priority"- end- end-enddiff --git a/db/migrate/20240229133250_rename_delayed_job_statuses.rb b/db/migrate/20240229133250_rename_delayed_job_statuses.rbdeleted file mode 100644index 1c8527da459..00000000000--- a/db/migrate/20240229133250_rename_delayed_job_statuses.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RenameDelayedJobStatuses < ActiveRecord::Migration[7.1]- def change- rename_table :delayed_job_statuses, :job_statuses- end-enddiff --git a/db/migrate/20240306083241_change_default_value_of_alternative_color.rb b/db/migrate/20240306083241_change_default_value_of_alternative_color.rbdeleted file mode 100644index 5b6c6a90bce..00000000000--- a/db/migrate/20240306083241_change_default_value_of_alternative_color.rb+++ /dev/null@@ -1,19 +0,0 @@-class ChangeDefaultValueOfAlternativeColor < ActiveRecord::Migration[7.1]- class MigrationDesignColor < ApplicationRecord- self.table_name = "design_colors"- end-- def up- alternative_color = MigrationDesignColor.find_by(variable: "alternative-color")- if alternative_color&.hexcode == OpenProject::CustomStyles::ColorThemes::DEPRECATED_ALTERNATIVE_COLOR- alternative_color.update(hexcode: OpenProject::CustomStyles::ColorThemes::PRIMER_PRIMARY_BUTTON_COLOR)- end- end-- def down- alternative_color = MigrationDesignColor.find_by(variable: "alternative-color")- if alternative_color&.hexcode == OpenProject::CustomStyles::ColorThemes::PRIMER_PRIMARY_BUTTON_COLOR- alternative_color.update(hexcode: OpenProject::CustomStyles::ColorThemes::DEPRECATED_ALTERNATIVE_COLOR)- end- end-enddiff --git a/db/migrate/20240306154735_create_good_job_labels_index.rb b/db/migrate/20240306154735_create_good_job_labels_index.rbdeleted file mode 100644index c1980765868..00000000000--- a/db/migrate/20240306154735_create_good_job_labels_index.rb+++ /dev/null@@ -1,52 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class CreateGoodJobLabelsIndex < ActiveRecord::Migration[7.1]- disable_ddl_transaction!-- def change- reversible do |dir|- dir.up do- unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_labels)- add_index :good_jobs, :labels, using: :gin,- where: "(labels IS NOT NULL)",- name: :index_good_jobs_on_labels,- algorithm: :concurrently- end- end-- dir.down do- if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_labels)- remove_index :good_jobs, name: :index_good_jobs_on_labels- end- end- end- end-enddiff --git a/db/migrate/20240306154736_remove_good_job_active_id_index.rb b/db/migrate/20240306154736_remove_good_job_active_id_index.rbdeleted file mode 100644index 37fba7d296f..00000000000--- a/db/migrate/20240306154736_remove_good_job_active_id_index.rb+++ /dev/null@@ -1,49 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RemoveGoodJobActiveIdIndex < ActiveRecord::Migration[7.1]- disable_ddl_transaction!-- def change- reversible do |dir|- dir.up do- if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_active_job_id)- remove_index :good_jobs, name: :index_good_jobs_on_active_job_id- end- end-- dir.down do- unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_active_job_id)- add_index :good_jobs, :active_job_id, name: :index_good_jobs_on_active_job_id- end- end- end- end-enddiff --git a/db/migrate/20240307094432_change_done_ratio_default_value_to_null.rb b/db/migrate/20240307094432_change_done_ratio_default_value_to_null.rbdeleted file mode 100644index a8373662d44..00000000000--- a/db/migrate/20240307094432_change_done_ratio_default_value_to_null.rb+++ /dev/null@@ -1,8 +0,0 @@-class ChangeDoneRatioDefaultValueToNull < ActiveRecord::Migration[7.1]- def change- change_column_null :work_packages, :done_ratio, true- change_column_default :work_packages, :done_ratio, from: 0, to: nil- change_column_null :work_package_journals, :done_ratio, true- change_column_default :work_package_journals, :done_ratio, from: 0, to: nil- end-enddiff --git a/db/migrate/20240307102541_reduce_configurable_design_variables.rb b/db/migrate/20240307102541_reduce_configurable_design_variables.rbdeleted file mode 100644index bf0ac9a36ae..00000000000--- a/db/migrate/20240307102541_reduce_configurable_design_variables.rb+++ /dev/null@@ -1,37 +0,0 @@-class ReduceConfigurableDesignVariables < ActiveRecord::Migration[7.1]- class MigrationDesignColor < ApplicationRecord- self.table_name = "design_colors"- end-- def up- # Delete "primary-color" and "primary-color-dark"- MigrationDesignColor- .where(variable: %w(primary-color primary-color-dark))- .delete_all-- # Rename "alternative-color" to "primary-button-color"- MigrationDesignColor- .where(variable: "alternative-color")- .update(variable: "primary-button-color")-- # Rename "content-link-color" to "accent-color"- MigrationDesignColor- .where(variable: "content-link-color")- .update(variable: "accent-color")- end-- def down- MigrationDesignColor- .create(variable: "primary-color", hexcode: OpenProject::CustomStyles::ColorThemes::DEPRECATED_PRIMARY_COLOR)- MigrationDesignColor- .create(variable: "primary-color-dark", hexcode: OpenProject::CustomStyles::ColorThemes::DEPRECATED_PRIMARY_DARK_COLOR)-- MigrationDesignColor- .where(variable: "primary-button-color")- .update(variable: "alternative-color")-- MigrationDesignColor- .where(variable: "accent-color")- .update(variable: "content-link-color")- end-enddiff --git a/db/migrate/20240307190126_rename_portuguese_locale.rb b/db/migrate/20240307190126_rename_portuguese_locale.rbdeleted file mode 100644index 32fed764f80..00000000000--- a/db/migrate/20240307190126_rename_portuguese_locale.rb+++ /dev/null@@ -1,24 +0,0 @@-class RenamePortugueseLocale < ActiveRecord::Migration[7.1]- def up- execute "UPDATE users SET language = 'pt-BR' WHERE language = 'pt'"- execute "UPDATE settings SET value = 'pt-BR' WHERE name = 'default_language' AND value = 'pt'"- modify_available_languages!("pt", "pt-BR")- end-- def down- execute "UPDATE users SET language = 'pt' WHERE language = 'pt-BR'"- execute "UPDATE settings SET value = 'pt' WHERE name = 'default_language' AND value = 'pt-BR'"- modify_available_languages!("pt-BR", "pt")- end-- private-- def modify_available_languages!(from, to)- languages = Setting.available_languages- if languages.include?(from)- languages << to- languages.delete(from)- Setting.available_languages = languages- end- end-enddiff --git a/db/migrate/20240311111957_enable_unaccent_extension.rb b/db/migrate/20240311111957_enable_unaccent_extension.rbdeleted file mode 100644index c365df7e14b..00000000000--- a/db/migrate/20240311111957_enable_unaccent_extension.rb+++ /dev/null@@ -1,53 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class EnableUnaccentExtension < ActiveRecord::Migration[7.1]- def up- ActiveRecord::Base.connection.execute("CREATE EXTENSION IF NOT EXISTS unaccent WITH SCHEMA pg_catalog;")- rescue StandardError => e- raise unless e.message.include?("unaccent")-- raise <<~MESSAGE- \e[33mWARNING:\e[0m Could not find or enable the `unaccent` extension for PostgreSQL.- This is needed for filtering users with accents, please install the postgresql-contrib module- for your PostgreSQL installation using the package manager of your operating system.-- Once this package is installed, please re-run this migration like so:-- - Packaged installation: openproject run bundle exec rake db:migrate:redo 20240311111957- - Docker installation: docker exec -it "container_id" bundle exec rake db:migrate:redo 20240311111957- - Docker-compose installation: docker-compose exec app bundle exec rake db:migrate:redo 20240311111957-- Read more about the contrib module at `https://www.postgresql.org/docs/current/contrib.html`.- MESSAGE- end-- def down- ActiveRecord::Base.connection.execute("DROP EXTENSION IF EXISTS unaccent CASCADE;")- end-enddiff --git a/db/migrate/20240325150312_change_derived_done_ratio_default_value_to_null.rb b/db/migrate/20240325150312_change_derived_done_ratio_default_value_to_null.rbdeleted file mode 100644index ec7bac50d93..00000000000--- a/db/migrate/20240325150312_change_derived_done_ratio_default_value_to_null.rb+++ /dev/null@@ -1,8 +0,0 @@-class ChangeDerivedDoneRatioDefaultValueToNull < ActiveRecord::Migration[7.1]- def change- change_column_null :work_packages, :derived_done_ratio, true- change_column_default :work_packages, :derived_done_ratio, from: 0, to: nil- change_column_null :work_package_journals, :derived_done_ratio, true- change_column_default :work_package_journals, :derived_done_ratio, from: 0, to: nil- end-enddiff --git a/db/migrate/20240328154805_change_status_default_done_ratio_to_zero.rb b/db/migrate/20240328154805_change_status_default_done_ratio_to_zero.rbdeleted file mode 100644index b430e096694..00000000000--- a/db/migrate/20240328154805_change_status_default_done_ratio_to_zero.rb+++ /dev/null@@ -1,11 +0,0 @@-class ChangeStatusDefaultDoneRatioToZero < ActiveRecord::Migration[7.1]- def change- change_column_default :statuses, :default_done_ratio, from: nil, to: 0- reversible do |dir|- dir.up do- execute "UPDATE statuses SET default_done_ratio = 0 WHERE default_done_ratio IS NULL"- end- end- change_column_null :statuses, :default_done_ratio, false- end-enddiff --git a/db/migrate/20240402065214_remove_ldap_tls_setting.rb b/db/migrate/20240402065214_remove_ldap_tls_setting.rbdeleted file mode 100644index 98a77feca5a..00000000000--- a/db/migrate/20240402065214_remove_ldap_tls_setting.rb+++ /dev/null@@ -1,9 +0,0 @@-class RemoveLdapTlsSetting < ActiveRecord::Migration[7.1]- def up- execute "DELETE FROM settings WHERE name = 'ldap_tls_options'"- end-- def down- # Nothing to do- end-enddiff --git a/db/migrate/20240402072213_update_progress_calculation.rb b/db/migrate/20240402072213_update_progress_calculation.rbdeleted file mode 100644index 036cb97ef4a..00000000000--- a/db/migrate/20240402072213_update_progress_calculation.rb+++ /dev/null@@ -1,26 +0,0 @@-class UpdateProgressCalculation < ActiveRecord::Migration[7.1]- # See https://community.openproject.org/wp/40749 for migration details- def up- current_mode = progress_calculation_mode- if current_mode == "disabled"- set_progress_calculation_mode_to_work_based- previous_mode = "disabled"- current_mode = "field"- end-- perform_method = Rails.env.development? ? :perform_now : :perform_later- WorkPackages::Progress::MigrateValuesJob.public_send(perform_method, current_mode:, previous_mode:)- end-- def progress_calculation_mode- value_from_db = ActiveRecord::Base.connection- .execute("SELECT value FROM settings WHERE name = 'work_package_done_ratio'")- .first- &.fetch("value", nil)- value_from_db || "field"- end-- def set_progress_calculation_mode_to_work_based- ActiveRecord::Base.connection.execute("UPDATE settings SET value = 'field' WHERE name = 'work_package_done_ratio'")- end-enddiff --git a/db/migrate/20240404074025_create_favorite.rb b/db/migrate/20240404074025_create_favorite.rbdeleted file mode 100644index 2827dea096c..00000000000--- a/db/migrate/20240404074025_create_favorite.rb+++ /dev/null@@ -1,13 +0,0 @@-class CreateFavorite < ActiveRecord::Migration[7.1]- def change- create_table :favorites do |t|- t.references :user, null: false, foreign_key: true, index: true- t.references :favored, null: false, polymorphic: true-- t.timestamps- end-- add_index :favorites, %i[favored_type favored_id]- add_index :favorites, %i[user_id favored_type favored_id], unique: true- end-enddiff --git a/db/migrate/20240408093541_change_default_accent_and_bim_primary_color.rb b/db/migrate/20240408093541_change_default_accent_and_bim_primary_color.rbdeleted file mode 100644index 73c32a26ac8..00000000000--- a/db/migrate/20240408093541_change_default_accent_and_bim_primary_color.rb+++ /dev/null@@ -1,32 +0,0 @@-class ChangeDefaultAccentAndBimPrimaryColor < ActiveRecord::Migration[7.1]- class MigrationDesignColor < ApplicationRecord- self.table_name = "design_colors"- end-- def up- # The default Bim value was forgotten in previous migrations- if OpenProject::Configuration.bim?- MigrationDesignColor- .where(variable: "primary-button-color", hexcode: OpenProject::CustomStyles::ColorThemes::DEPRECATED_BIM_ALTERNATIVE_COLOR)- .update_all(hexcode: OpenProject::CustomStyles::ColorThemes::PRIMER_PRIMARY_BUTTON_COLOR)- end-- # When merging the old "primary" and "link" color into the new "accent" color,- # it was forgotten to use the value of "primary" for it.- MigrationDesignColor- .where(variable: "accent-color", hexcode: OpenProject::CustomStyles::ColorThemes::DEPRECATED_LINK_COLOR)- .update_all(hexcode: OpenProject::CustomStyles::ColorThemes::ACCENT_COLOR)- end-- def down- if OpenProject::Configuration.bim?- MigrationDesignColor- .where(variable: "primary-button-color", hexcode: OpenProject::CustomStyles::ColorThemes::PRIMER_PRIMARY_BUTTON_COLOR)- .update_all(hexcode: OpenProject::CustomStyles::ColorThemes::DEPRECATED_BIM_ALTERNATIVE_COLOR)- end-- MigrationDesignColor- .where(variable: "accent-color", hexcode: OpenProject::CustomStyles::ColorThemes::ACCENT_COLOR)- .update_all(hexcode: OpenProject::CustomStyles::ColorThemes::DEPRECATED_LINK_COLOR)- end-enddiff --git a/db/migrate/20240408132459_rename_delay_to_lag.rb b/db/migrate/20240408132459_rename_delay_to_lag.rbdeleted file mode 100644index 386790aefb8..00000000000--- a/db/migrate/20240408132459_rename_delay_to_lag.rb+++ /dev/null@@ -1,8 +0,0 @@-class RenameDelayToLag < ActiveRecord::Migration[7.1]- def change- rename_column :relations, :delay, :lag-- # TODO remove after 14.0- add_column :relations, :delay, :virtual, type: :integer, as: "lag", stored: true- end-enddiff --git a/db/migrate/20240410060041_remove_virtual_delay_column.rb b/db/migrate/20240410060041_remove_virtual_delay_column.rbdeleted file mode 100644index 5fc36f3cd66..00000000000--- a/db/migrate/20240410060041_remove_virtual_delay_column.rb+++ /dev/null@@ -1,5 +0,0 @@-class RemoveVirtualDelayColumn < ActiveRecord::Migration[7.1]- def change- remove_column :relations, :delay, :virtual, type: :integer, as: "lag", stored: true- end-enddiff --git a/db/migrate/20240422141623_rename_estimate_and_time_attribute_group.rb b/db/migrate/20240422141623_rename_estimate_and_time_attribute_group.rbdeleted file mode 100644index fbc4a01debc..00000000000--- a/db/migrate/20240422141623_rename_estimate_and_time_attribute_group.rb+++ /dev/null@@ -1,15 +0,0 @@-class RenameEstimateAndTimeAttributeGroup < ActiveRecord::Migration[7.1]- def up- execute <<~SQL.squish- UPDATE types- SET attribute_groups = REPLACE(attribute_groups, '- - :estimates_and_time', '- - :estimates_and_progress')- SQL- end-- def down- execute <<~SQL.squish- UPDATE types- SET attribute_groups = REPLACE(attribute_groups, '- - :estimates_and_progress', '- - :estimates_and_time')- SQL- end-enddiff --git a/db/migrate/20240424093311_add_excluded_from_totals_to_statuses.rb b/db/migrate/20240424093311_add_excluded_from_totals_to_statuses.rbdeleted file mode 100644index dd3e6fbb96d..00000000000--- a/db/migrate/20240424093311_add_excluded_from_totals_to_statuses.rb+++ /dev/null@@ -1,5 +0,0 @@-class AddExcludedFromTotalsToStatuses < ActiveRecord::Migration[7.1]- def change- add_column :statuses, :excluded_from_totals, :boolean, default: false, null: false- end-enddiff --git a/db/migrate/20240430143313_update_default_project_columns.rb b/db/migrate/20240430143313_update_default_project_columns.rbdeleted file mode 100644index 914ca9077df..00000000000--- a/db/migrate/20240430143313_update_default_project_columns.rb+++ /dev/null@@ -1,43 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class UpdateDefaultProjectColumns < ActiveRecord::Migration[7.1]- def up- return unless Setting.where(name: "enabled_projects_columns").exists? # rubocop:disable Rails/WhereExists-- columns = Setting.enabled_projects_columns- columns.unshift("name") if columns.exclude?("name")- columns.unshift("favored") if columns.exclude?("favored")-- Setting.enabled_projects_columns = columns- end-- def down- # Nothing to do- end-enddiff --git a/db/migrate/20240506091102_remove_totals_from_childless_work_packages.rb b/db/migrate/20240506091102_remove_totals_from_childless_work_packages.rbdeleted file mode 100644index 902d0985003..00000000000--- a/db/migrate/20240506091102_remove_totals_from_childless_work_packages.rb+++ /dev/null@@ -1,6 +0,0 @@-class RemoveTotalsFromChildlessWorkPackages < ActiveRecord::Migration[7.1]- def up- perform_method = Rails.env.development? ? :perform_now : :perform_later- WorkPackages::Progress::MigrateRemoveTotalsFromChildlessWorkPackagesJob.public_send(perform_method)- end-enddiff --git a/db/migrate/20240513135928_extend_oauth_applications.rb b/db/migrate/20240513135928_extend_oauth_applications.rbdeleted file mode 100644index 18ec11c1fe3..00000000000--- a/db/migrate/20240513135928_extend_oauth_applications.rb+++ /dev/null@@ -1,8 +0,0 @@-class ExtendOAuthApplications < ActiveRecord::Migration[7.1]- def change- change_table :oauth_applications, bulk: true do |t|- t.column :enabled, :boolean, default: true, null: false- t.column :builtin, :boolean, default: false, null: false- end- end-enddiff --git a/db/migrate/20240519123921_add_public_to_project_queries.rb b/db/migrate/20240519123921_add_public_to_project_queries.rbdeleted file mode 100644index fa2190b01b9..00000000000--- a/db/migrate/20240519123921_add_public_to_project_queries.rb+++ /dev/null@@ -1,6 +0,0 @@-class AddPublicToProjectQueries < ActiveRecord::Migration[7.1]- def change- add_column :project_queries, :public, :boolean, default: false, null: false- add_index :project_queries, :public- end-enddiff --git a/db/migrate/20240522073759_fix_status_excluded_from_totals_changed_journal_cause.rb b/db/migrate/20240522073759_fix_status_excluded_from_totals_changed_journal_cause.rbdeleted file mode 100644index 15f610b3ee4..00000000000--- a/db/migrate/20240522073759_fix_status_excluded_from_totals_changed_journal_cause.rb+++ /dev/null@@ -1,72 +0,0 @@-# Update journal entries from this:-#-# {-# "type" => "status_p_complete_changed",-# "status_name" => status.name,-# "status_id" => status.id,-# "status_p_complete_change" => [20, 40]-# }-#-# to this:-#-# {-# "type" => "status_changed",-# "status_name" => status.name,-# "status_id" => status.id,-# "status_changes" => { "default_done_ratio" => [20, 40] }-# }-#-# structure needed to handle multiple changes in one cause-class FixStatusExcludedFromTotalsChangedJournalCause < ActiveRecord::Migration[7.1]- def up- # With Postgres version 16+, it could be written as:- # json_object(- # 'type': 'status_changed',- # 'status_id': cause -> 'status_id',- # 'status_name': cause -> 'status_name',- # 'status_changes': json_object(- # 'default_done_ratio': cause -> 'status_p_complete_change'- # )- # )- execute(<<~SQL.squish)- UPDATE journals- SET cause = jsonb_set(- jsonb_set(- cause,- '{type}',- '"status_changed"'- ),- '{status_changes}',- jsonb_set(- '{"default_done_ratio": ""}'::jsonb,- '{default_done_ratio}',- cause -> 'status_p_complete_change'- )- ) - 'status_p_complete_change'- WHERE cause @> '{"type": "status_p_complete_changed"}';- SQL- end-- def down- # With Postgres version 16+, it could be written as:- # json_object(- # 'type': 'status_p_complete_changed',- # 'status_id': cause -> 'status_id',- # 'status_name': cause -> 'status_name',- # 'status_p_complete_change': cause #> '{status_changes,default_done_ratio}'- # )- execute(<<~SQL.squish)- UPDATE journals- SET cause = jsonb_set(- jsonb_set(- cause,- '{type}',- '"status_p_complete_changed"'- ),- '{status_p_complete_change}',- cause #> '{status_changes,default_done_ratio}'- ) - 'status_changes'- WHERE cause @> '{"type": "status_changed", "status_changes":{"default_done_ratio":[]}}';- SQL- end-enddiff --git a/db/migrate/20240527070439_add_project_query_roles.rb b/db/migrate/20240527070439_add_project_query_roles.rbdeleted file mode 100644index 0913d438ba5..00000000000--- a/db/migrate/20240527070439_add_project_query_roles.rb+++ /dev/null@@ -1,21 +0,0 @@-class AddProjectQueryRoles < ActiveRecord::Migration[7.1]- def up- view_role ||= ProjectQueryRole.find_or_initialize_by(builtin: Role::BUILTIN_PROJECT_QUERY_VIEW)-- view_role.update!(- name: I18n.t("seeds.common.project_query_roles.item_0.name", default: "Project query viewer"),- permissions: %i[- view_project_query- ]- )-- edit_role ||= ProjectQueryRole.find_or_initialize_by(builtin: Role::BUILTIN_PROJECT_QUERY_EDIT)- edit_role.update!(- name: I18n.t("seeds.common.project_query_roles.item_1.name", default: "Project query editor"),- permissions: %i[- view_project_query- edit_project_query- ]- )- end-enddiff --git a/db/migrate/20240611105232_set_watched_notification_setting_to_true.rb b/db/migrate/20240611105232_set_watched_notification_setting_to_true.rbdeleted file mode 100644index b2b851852d6..00000000000--- a/db/migrate/20240611105232_set_watched_notification_setting_to_true.rb+++ /dev/null@@ -1,15 +0,0 @@-class SetWatchedNotificationSettingToTrue < ActiveRecord::Migration[7.1]- def change- change_column_default :notification_settings, :shared, from: false, to: true-- reversible do |dir|- dir.up do- execute "UPDATE notification_settings SET shared = true"- end-- dir.down do- execute "UPDATE notification_settings SET shared = false"- end- end- end-enddiff --git a/db/migrate/20240620115412_add_project_attribute_roles.rb b/db/migrate/20240620115412_add_project_attribute_roles.rbdeleted file mode 100644index 296c3743c85..00000000000--- a/db/migrate/20240620115412_add_project_attribute_roles.rb+++ /dev/null@@ -1,39 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require Rails.root.join("db/migrate/migration_utils/permission_adder")--class AddProjectAttributeRoles < ActiveRecord::Migration[7.1]- def change- ::Migration::MigrationUtils::PermissionAdder- .add(:view_project, :view_project_attributes)-- ::Migration::MigrationUtils::PermissionAdder- .add(:edit_project, :edit_project_attributes)- end-enddiff --git a/db/migrate/20240624103354_create_emoji_reactions.rb b/db/migrate/20240624103354_create_emoji_reactions.rbdeleted file mode 100644index 0e3ab38496c..00000000000--- a/db/migrate/20240624103354_create_emoji_reactions.rb+++ /dev/null@@ -1,15 +0,0 @@-class CreateEmojiReactions < ActiveRecord::Migration[7.1]- def change- create_table :emoji_reactions do |t|- t.references :user, null: false, foreign_key: true- t.references :reactable, polymorphic: true, null: false- t.string :reaction, null: false- t.timestamps- end-- add_index :emoji_reactions, :reaction- add_index :emoji_reactions, %i[user_id reactable_type reactable_id reaction],- unique: true,- name: "index_emoji_reactions_uniqueness"- end-enddiff --git a/db/migrate/20240625075139_add_uniqueness_index_to_project_custom_field_project_mappings.rb b/db/migrate/20240625075139_add_uniqueness_index_to_project_custom_field_project_mappings.rbdeleted file mode 100644index c5b47e67fb0..00000000000--- a/db/migrate/20240625075139_add_uniqueness_index_to_project_custom_field_project_mappings.rb+++ /dev/null@@ -1,19 +0,0 @@-class AddUniquenessIndexToProjectCustomFieldProjectMappings < ActiveRecord::Migration[7.1]- def up- execute <<~SQL.squish- DELETE FROM project_custom_field_project_mappings AS pcfpm_1- USING project_custom_field_project_mappings AS pcfpm_2- WHERE pcfpm_1.project_id = pcfpm_2.project_id- AND pcfpm_1.custom_field_id = pcfpm_2.custom_field_id- AND pcfpm_1.id > pcfpm_2.id;- SQL-- add_index :project_custom_field_project_mappings, %i[project_id custom_field_id],- unique: true,- name: "index_project_custom_field_project_mappings_unique"- end-- def down- remove_index :project_custom_field_project_mappings, name: "index_project_custom_field_project_mappings_unique"- end-enddiff --git a/db/migrate/20240703131639_add_timestamps_to_user_preferences.rb b/db/migrate/20240703131639_add_timestamps_to_user_preferences.rbdeleted file mode 100644index c147e67efc8..00000000000--- a/db/migrate/20240703131639_add_timestamps_to_user_preferences.rb+++ /dev/null@@ -1,5 +0,0 @@-class AddTimestampsToUserPreferences < ActiveRecord::Migration[7.1]- def change- add_timestamps :user_preferences, default: DateTime.now- end-enddiff --git a/db/migrate/20240715183144_add_indexes_to_custom_options.rb b/db/migrate/20240715183144_add_indexes_to_custom_options.rbdeleted file mode 100644index 73d7b20669b..00000000000--- a/db/migrate/20240715183144_add_indexes_to_custom_options.rb+++ /dev/null@@ -1,13 +0,0 @@-class AddIndexesToCustomOptions < ActiveRecord::Migration[7.1]- def change- # A previous migration 20230328154645_add_gin_trgm_index_on_journals_and_custom_values- # already enabled on the extension. Hence we do not attempt to enable it here, just- # to use it if its available.-- if extensions.include?("pg_trgm")- add_index(:custom_options, :value, using: "gin", opclass: :gin_trgm_ops)- end-- add_index(:custom_options, :custom_field_id)- end-enddiff --git a/db/migrate/20240805104004_rename_visible_to_admin_only_in_custom_fields.rb b/db/migrate/20240805104004_rename_visible_to_admin_only_in_custom_fields.rbdeleted file mode 100644index be29d9ad42a..00000000000--- a/db/migrate/20240805104004_rename_visible_to_admin_only_in_custom_fields.rb+++ /dev/null@@ -1,40 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require_relative "migration_utils/utils"--class RenameVisibleToAdminOnlyInCustomFields < ActiveRecord::Migration[7.1]- include ::Migration::Utils-- def change- rename_column :custom_fields, :visible, :admin_only- change_column_default :custom_fields, :admin_only, from: true, to: false-- execute_sql("UPDATE custom_fields SET admin_only = NOT admin_only")- end-enddiff --git a/db/migrate/20240808125617_populate_remote_identities.rb b/db/migrate/20240808125617_populate_remote_identities.rbdeleted file mode 100644index e315596abee..00000000000--- a/db/migrate/20240808125617_populate_remote_identities.rb+++ /dev/null@@ -1,58 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require_relative "migration_utils/utils"--class PopulateRemoteIdentities < ActiveRecord::Migration[7.1]- include ::Migration::Utils-- def up- execute_sql <<~SQL.squish- INSERT INTO remote_identities(user_id, oauth_client_id, origin_user_id, created_at, updated_at)- SELECT DISTINCT ON (user_id, oauth_client_id) user_id, oauth_client_id, origin_user_id, created_at, updated_at- FROM oauth_client_tokens- WHERE oauth_client_tokens.origin_user_id IS NOT NULL- SQL-- execute_sql "UPDATE oauth_client_tokens SET origin_user_id = NULL"- end-- def down- execute_sql <<~SQL.squish- UPDATE oauth_client_tokens- SET origin_user_id = remote_identities.origin_user_id- FROM remote_identities- WHERE oauth_client_tokens.user_id = remote_identities.user_id- AND oauth_client_tokens.oauth_client_id = remote_identities.oauth_client_id- SQL-- execute_sql "DELETE FROM remote_identities"- end-enddiff --git a/db/migrate/20240808133947_add_lock_version_to_oauth_client_tokens.rb b/db/migrate/20240808133947_add_lock_version_to_oauth_client_tokens.rbdeleted file mode 100644index 6ed2a7ff4c1..00000000000--- a/db/migrate/20240808133947_add_lock_version_to_oauth_client_tokens.rb+++ /dev/null@@ -1,35 +0,0 @@-# frozen_string_literal:true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddLockVersionToOAuthClientTokens < ActiveRecord::Migration[7.1]- def change- add_column :oauth_client_tokens, :lock_version, :integer, default: 0, null: false- end-enddiff --git a/db/migrate/20240813131647_drop_origin_user_id_from_oauth_client_tokens.rb b/db/migrate/20240813131647_drop_origin_user_id_from_oauth_client_tokens.rbdeleted file mode 100644index f161716c257..00000000000--- a/db/migrate/20240813131647_drop_origin_user_id_from_oauth_client_tokens.rb+++ /dev/null@@ -1,5 +0,0 @@-class DropOriginUserIdFromOAuthClientTokens < ActiveRecord::Migration[7.1]- def change- remove_column :oauth_client_tokens, :origin_user_id, :string- end-enddiff --git a/db/migrate/20240820123011_remove_project_from_notification.rb b/db/migrate/20240820123011_remove_project_from_notification.rbdeleted file mode 100644index 107084f70f0..00000000000--- a/db/migrate/20240820123011_remove_project_from_notification.rb+++ /dev/null@@ -1,83 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RemoveProjectFromNotification < ActiveRecord::Migration[7.1]- def change- reversible do |direction|- direction.down do- execute <<~SQL.squish- UPDATE notifications- SET project_id = work_package_journals.project_id- FROM journals- JOIN work_package_journals- ON journals.data_id = work_package_journals.id AND journals.data_type = 'Journal::WorkPackageJournal'- WHERE notifications.journal_id = journals.id AND notifications.resource_type = 'WorkPackage'- SQL-- execute <<~SQL.squish- UPDATE notifications- SET project_id = forums.project_id- FROM journals- JOIN message_journals- ON journals.data_id = message_journals.id AND journals.data_type = 'Journal::MessageJournal'- JOIN forums ON message_journals.forum_id = forums.id- WHERE notifications.journal_id = journals.id AND notifications.resource_type = 'Message'- SQL-- execute <<~SQL.squish- UPDATE notifications- SET project_id = wikis.project_id- FROM wiki_pages- JOIN wikis- ON wiki_pages.wiki_id = wikis.id- WHERE notifications.resource_id = wiki_pages.id AND notifications.resource_type = 'WikiPage'- SQL-- execute <<~SQL.squish- UPDATE notifications- SET project_id = news_journals.project_id- FROM journals- JOIN news_journals- ON journals.data_id = news_journals.id AND journals.data_type = 'Journal::NewsJournal'- WHERE notifications.journal_id = journals.id AND notifications.resource_type = 'News'- SQL-- execute <<~SQL.squish- UPDATE notifications- SET project_id = news.project_id- FROM comments- JOIN news- ON comments.commented_id = news.id AND comments.commented_type = 'News'- WHERE notifications.resource_id = comments.id AND notifications.resource_type = 'Comment'- SQL- end- end-- remove_reference :notifications, :project- end-enddiff --git a/db/migrate/20240909151818_migrate_legacy_default_theme_to_light_theme.rb b/db/migrate/20240909151818_migrate_legacy_default_theme_to_light_theme.rbdeleted file mode 100644index 5dd23543215..00000000000--- a/db/migrate/20240909151818_migrate_legacy_default_theme_to_light_theme.rb+++ /dev/null@@ -1,59 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class MigrateLegacyDefaultThemeToLightTheme < ActiveRecord::Migration[7.1]- # Migrate legacy `default` theme to `light` theme- #- # Moving from:- # {- # "settings": {- # "theme": "default",- # "foo": "bar"- # }- # }- #- # To:- # {- # "settings": {- # "theme": "light", # current default theme- # "foo": "bar"- # }- # }- def up- execute <<-SQL.squish- UPDATE user_preferences- SET settings = jsonb_set(settings, '{theme}', '"light"')- WHERE settings->>'theme' = 'default';- SQL- end-- # no-op- def down; end-enddiff --git a/db/migrate/20240917105829_add_primary_key_to_custom_fields_projects.rb b/db/migrate/20240917105829_add_primary_key_to_custom_fields_projects.rbdeleted file mode 100644index 0e07746b175..00000000000--- a/db/migrate/20240917105829_add_primary_key_to_custom_fields_projects.rb+++ /dev/null@@ -1,35 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddPrimaryKeyToCustomFieldsProjects < ActiveRecord::Migration[7.1]- def change- # NOTE: Manually backfilling the `id` column is not necessary as the BIGSERIAL primary key will auto-populate- # the existing records with auto-incrementing values- add_column :custom_fields_projects, :id, :primary_key # rubocop:disable Rails/DangerousColumnNames- end-enddiff --git a/db/migrate/20240920152544_set_versions_name_collation.rb b/db/migrate/20240920152544_set_versions_name_collation.rbdeleted file mode 100644index cbfb9541b8c..00000000000--- a/db/migrate/20240920152544_set_versions_name_collation.rb+++ /dev/null@@ -1,28 +0,0 @@-class SetVersionsNameCollation < ActiveRecord::Migration[7.1]- def up- begin- execute <<-SQL.squish- CREATE COLLATION IF NOT EXISTS versions_name (provider = icu, locale = 'und-u-kn-true');- SQL- rescue StandardError => e- raise unless e.message.include?("encoding")-- abort <<~MESSAGE- \e[31mERROR:\e[0m Failed to create an ICU collation with current database encoding.- You need to change the database encoding before proceeding.-- Please check the instructions on how to do it:- https://www.openproject.org/docs/installation-and-operations/misc/changing-database-encoding/-- Original error:- #{e.message}- MESSAGE- end-- change_column :versions, :name, :string, collation: "versions_name"- end-- def down- change_column :versions, :name, :string- end-enddiff --git a/db/migrate/20240924114246_create_hierarchical_items.rb b/db/migrate/20240924114246_create_hierarchical_items.rbdeleted file mode 100644index deddfcd0c40..00000000000--- a/db/migrate/20240924114246_create_hierarchical_items.rb+++ /dev/null@@ -1,29 +0,0 @@-class CreateHierarchicalItems < ActiveRecord::Migration[7.1]- def change- create_table :hierarchical_items do |t|- t.integer :parent_id- t.integer :sort_order- t.string :label- t.string :short- t.boolean :is_deleted, default: false, null: false-- t.timestamps- end-- add_reference "hierarchical_items", :custom_field, foreign_key: true-- # auto-generated by closure_tree- create_table :hierarchical_item_hierarchies, id: false do |t|- t.integer :ancestor_id, null: false- t.integer :descendant_id, null: false- t.integer :generations, null: false- end-- add_index :hierarchical_item_hierarchies, %i[ancestor_id descendant_id generations],- unique: true,- name: "item_anc_desc_idx"-- add_index :hierarchical_item_hierarchies, [:descendant_id],- name: "item_desc_idx"- end-enddiff --git a/db/migrate/20240930122522_change_view_of_queries_with_timeline_to_gantt_again.rb b/db/migrate/20240930122522_change_view_of_queries_with_timeline_to_gantt_again.rbdeleted file mode 100644index dc138f71291..00000000000--- a/db/migrate/20240930122522_change_view_of_queries_with_timeline_to_gantt_again.rb+++ /dev/null@@ -1,16 +0,0 @@-require_relative "20231201085450_change_view_of_queries_with_timeline_to_gantt"--# Inherit from the original migration `ChangeViewOfQueriesWithTimelineToGantt`-# to avoid duplicating it.-#-# The original migration was fine, but it was applied too early: in OpenProject-# 13.2.0 the migration would already have been run and it was still possible to-# create Gantt queries inside the work packages module. Such queries were not-# migrated.-#-# This was registered as bug #56769.-#-# This migration runs the original migration again to ensure all queries-# displayed as Gantt charts are displayed in the right module.-class ChangeViewOfQueriesWithTimelineToGanttAgain < ChangeViewOfQueriesWithTimelineToGantt-enddiff --git a/db/migrate/20241001205821_add_standard_global_role.rb b/db/migrate/20241001205821_add_standard_global_role.rbdeleted file mode 100644index 586fe3f84db..00000000000--- a/db/migrate/20241001205821_add_standard_global_role.rb+++ /dev/null@@ -1,10 +0,0 @@-class AddStandardGlobalRole < ActiveRecord::Migration[7.1]- def change- standard_global_role ||= GlobalRole.find_or_initialize_by(builtin: Role::BUILTIN_STANDARD_GLOBAL)-- standard_global_role.update!(- name: I18n.t("seeds.common.global_roles.item_1.name", default: "Standard global role"),- permissions: []- )- end-enddiff --git a/db/migrate/20241002151949_remove_hide_mail_from_user_preferences.rb b/db/migrate/20241002151949_remove_hide_mail_from_user_preferences.rbdeleted file mode 100644index 3a9ccbca302..00000000000--- a/db/migrate/20241002151949_remove_hide_mail_from_user_preferences.rb+++ /dev/null@@ -1,8 +0,0 @@-class RemoveHideMailFromUserPreferences < ActiveRecord::Migration[7.1]- def up- execute <<~SQL.squish- UPDATE user_preferences- SET settings = settings - 'hide_mail'- SQL- end-enddiff --git a/db/migrate/20241015081341_remove_obsolete_design_variables.rb b/db/migrate/20241015081341_remove_obsolete_design_variables.rbdeleted file mode 100644index 641b7c1af75..00000000000--- a/db/migrate/20241015081341_remove_obsolete_design_variables.rb+++ /dev/null@@ -1,21 +0,0 @@-class RemoveObsoleteDesignVariables < ActiveRecord::Migration[7.1]- OBSOLETE_COLOR_VARIABLES = %w( main-menu-font-color- main-menu-selected-font-color- main-menu-hover-font-color- main-menu-border-color- header-item-font-color- header-item-font-hover-color- header-border-bottom-color ).freeze-- class MigrationDesignColor < ApplicationRecord- self.table_name = "design_colors"- end-- def up- MigrationDesignColor.where(variable: OBSOLETE_COLOR_VARIABLES).delete_all- end-- def down- # This is not revertible- end-enddiff --git a/db/migrate/20241025072902_remove_project_details_widget.rb b/db/migrate/20241025072902_remove_project_details_widget.rbdeleted file mode 100644index 352218ac0b3..00000000000--- a/db/migrate/20241025072902_remove_project_details_widget.rb+++ /dev/null@@ -1,13 +0,0 @@-class RemoveProjectDetailsWidget < ActiveRecord::Migration[7.1]- def up- # The joining of the overview grids is not strictly necessary- # but it ensures that only widgets of overview grids are removed.- execute <<~SQL.squish- DELETE FROM grid_widgets- USING grids- WHERE grids.id = grid_widgets.grid_id- AND grids.type = 'Grids::Overview'- AND grid_widgets.identifier = 'project_details'- SQL- end-enddiff --git a/db/migrate/aggregated/base.rb b/db/migrate/aggregated/base.rbdeleted file mode 100644index b8a0d8baa2b..00000000000--- a/db/migrate/aggregated/base.rb+++ /dev/null@@ -1,41 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--module Aggregated; end--class Aggregated::Base- def self.migrations- raise NotImplementedError- end-- def self.normalized_migrations- migrations.split.map do |m|- m.gsub(/_.*\z/, "").to_i- end- end-enddiff --git a/db/migrate/aggregated/to_3_0.rb b/db/migrate/aggregated/to_3_0.rbdeleted file mode 100644index d51736ea156..00000000000--- a/db/migrate/aggregated/to_3_0.rb+++ /dev/null@@ -1,233 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require_relative "base"--# rubocop:disable Naming/ClassAndModuleCamelCase-class Aggregated::To_3_0 < Aggregated::Base- def self.migrations- <<-MIGRATIONS- 001_setup.rb- 002_issue_move.rb- 003_issue_add_note.rb- 004_export_pdf.rb- 005_issue_start_date.rb- 006_calendar_and_activity.rb- 007_create_journals.rb- 008_create_user_preferences.rb- 009_add_hide_mail_pref.rb- 010_create_comments.rb- 011_add_news_comments_count.rb- 012_add_comments_permissions.rb- 013_create_queries.rb- 014_add_queries_permissions.rb- 015_create_repositories.rb- 016_add_repositories_permissions.rb- 017_create_settings.rb- 018_set_doc_and_files_notifications.rb- 019_add_issue_status_position.rb- 020_add_role_position.rb- 021_add_tracker_position.rb- 022_serialize_possibles_values.rb- 023_add_tracker_is_in_roadmap.rb- 024_add_roadmap_permission.rb- 025_add_search_permission.rb- 026_add_repository_login_and_password.rb- 027_create_wikis.rb- 028_create_wiki_pages.rb- 029_create_wiki_contents.rb- 030_add_projects_feeds_permissions.rb- 031_add_repository_root_url.rb- 032_create_time_entries.rb- 033_add_timelog_permissions.rb- 034_create_changesets.rb- 035_create_changes.rb- 036_add_changeset_commit_date.rb- 037_add_project_identifier.rb- 038_add_custom_field_is_filter.rb- 039_create_watchers.rb- 040_create_changesets_issues.rb- 041_rename_comment_to_comments.rb- 042_create_issue_relations.rb- 043_add_relations_permissions.rb- 044_set_language_length_to_five.rb- 045_create_boards.rb- 046_create_messages.rb- 047_add_boards_permissions.rb- 048_allow_null_version_effective_date.rb- 049_add_wiki_destroy_page_permission.rb- 050_add_wiki_attachments_permissions.rb- 051_add_project_status.rb- 052_add_changes_revision.rb- 053_add_changes_branch.rb- 054_add_changesets_scmid.rb- 055_add_repositories_type.rb- 056_add_repositories_changes_permission.rb- 057_add_versions_wiki_page_title.rb- 058_add_issue_categories_assigned_to_id.rb- 059_add_roles_assignable.rb- 060_change_changesets_committer_limit.rb- 061_add_roles_builtin.rb- 062_insert_builtin_roles.rb- 063_add_roles_permissions.rb- 064_drop_permissions.rb- 065_add_settings_updated_on.rb- 066_add_custom_value_customized_index.rb- 067_create_wiki_redirects.rb- 068_create_enabled_modules.rb- 069_add_issues_estimated_hours.rb- 070_change_attachments_content_type_limit.rb- 071_add_queries_column_names.rb- 072_add_enumerations_position.rb- 073_add_enumerations_is_default.rb- 074_add_auth_sources_tls.rb- 075_add_members_mail_notification.rb- 076_allow_null_position.rb- 077_remove_issue_statuses_html_color.rb- 078_add_custom_fields_position.rb- 079_add_user_preferences_time_zone.rb- 080_add_users_type.rb- 081_create_projects_trackers.rb- 082_add_messages_locked.rb- 083_add_messages_sticky.rb- 084_change_auth_sources_account_limit.rb- 085_add_role_tracker_old_status_index_to_workflows.rb- 086_add_custom_fields_searchable.rb- 087_change_projects_description_to_text.rb- 088_add_custom_fields_default_value.rb- 089_add_attachments_description.rb- 090_change_versions_name_limit.rb- 091_change_changesets_revision_to_string.rb- 092_change_changes_from_revision_to_string.rb- 093_add_wiki_pages_protected.rb- 094_change_projects_homepage_limit.rb- 095_add_wiki_pages_parent_id.rb- 096_add_commit_access_permission.rb- 097_add_view_wiki_edits_permission.rb- 098_set_topic_authors_as_watchers.rb- 099_add_delete_wiki_pages_attachments_permission.rb- 100_add_changesets_user_id.rb- 101_populate_changesets_user_id.rb- 102_add_custom_fields_editable.rb- 103_set_custom_fields_editable.rb- 104_add_projects_lft_and_rgt.rb- 105_build_projects_tree.rb- 106_remove_projects_projects_count.rb- 107_add_open_id_authentication_tables.rb- 108_add_identity_url_to_users.rb- 20090214190337_add_watchers_user_id_type_index.rb- 20090312172426_add_queries_sort_criteria.rb- 20090312194159_add_projects_trackers_unique_index.rb- 20090318181151_extend_settings_name.rb- 20090323224724_add_type_to_enumerations.rb- 20090401221305_update_enumerations_to_sti.rb- 20090401231134_add_active_field_to_enumerations.rb- 20090403001910_add_project_to_enumerations.rb- 20090406161854_add_parent_id_to_enumerations.rb- 20090425161243_add_queries_group_by.rb- 20090503121501_create_member_roles.rb- 20090503121505_populate_member_roles.rb- 20090503121510_drop_members_role_id.rb- 20090614091200_fix_messages_sticky_null.rb- 20090704172350_populate_users_type.rb- 20090704172355_create_groups_users.rb- 20090704172358_add_member_roles_inherited_from.rb- 20091010093521_fix_users_custom_values.rb- 20091017212227_add_missing_indexes_to_workflows.rb- 20091017212457_add_missing_indexes_to_custom_fields_projects.rb- 20091017212644_add_missing_indexes_to_messages.rb- 20091017212938_add_missing_indexes_to_repositories.rb- 20091017213027_add_missing_indexes_to_comments.rb- 20091017213113_add_missing_indexes_to_enumerations.rb- 20091017213151_add_missing_indexes_to_wiki_pages.rb- 20091017213228_add_missing_indexes_to_watchers.rb- 20091017213257_add_missing_indexes_to_auth_sources.rb- 20091017213332_add_missing_indexes_to_documents.rb- 20091017213444_add_missing_indexes_to_tokens.rb- 20091017213536_add_missing_indexes_to_changesets.rb- 20091017213642_add_missing_indexes_to_issue_categories.rb- 20091017213716_add_missing_indexes_to_member_roles.rb- 20091017213757_add_missing_indexes_to_boards.rb- 20091017213835_add_missing_indexes_to_user_preferences.rb- 20091017213910_add_missing_indexes_to_issues.rb- 20091017214015_add_missing_indexes_to_members.rb- 20091017214107_add_missing_indexes_to_custom_fields.rb- 20091017214136_add_missing_indexes_to_queries.rb- 20091017214236_add_missing_indexes_to_time_entries.rb- 20091017214308_add_missing_indexes_to_news.rb- 20091017214336_add_missing_indexes_to_users.rb- 20091017214406_add_missing_indexes_to_attachments.rb- 20091017214440_add_missing_indexes_to_wiki_contents.rb- 20091017214519_add_missing_indexes_to_custom_values.rb- 20091017214611_add_missing_indexes_to_journals.rb- 20091017214644_add_missing_indexes_to_issue_relations.rb- 20091017214720_add_missing_indexes_to_wiki_redirects.rb- 20091017214750_add_missing_indexes_to_custom_fields_trackers.rb- 20091025163651_add_activity_indexes.rb- 20091108092559_add_versions_status.rb- 20091114105931_add_view_issues_permission.rb- 20091123212029_add_default_done_ratio_to_issue_status.rb- 20091205124427_add_versions_sharing.rb- 20091220183509_add_lft_and_rgt_indexes_to_projects.rb- 20091220183727_add_index_to_settings_name.rb- 20091220184736_add_indexes_to_issue_status.rb- 20091225164732_remove_enumerations_opt.rb- 20091227112908_change_wiki_contents_text_limit.rb- 20100129193402_change_users_mail_notification_to_string.rb- 20100129193813_update_mail_notification_values.rb- 20100221100219_add_index_on_changesets_scmid.rb- 20100313132032_add_issues_nested_sets_columns.rb- 20100313171051_add_index_on_issues_nested_set.rb- 20100705164950_change_changes_path_length_limit.rb- 20100714111651_prepare_journals_for_acts_as_journalized.rb- 20100714111652_update_journals_for_acts_as_journalized.rb- 20100714111653_build_initial_journals_for_acts_as_journalized.rb- 20100714111654_add_changes_from_journal_details_for_acts_as_journalized.rb- 20100804112053_merge_wiki_versions_with_journals.rb- 20100819172912_enable_calendar_and_gantt_modules_where_appropriate.rb- 20101104182107_add_unique_index_on_members.rb- 20101107130441_add_custom_fields_visible.rb- 20101114115114_change_projects_name_limit.rb- 20101114115359_change_projects_identifier_limit.rb- 20110220160626_add_workflows_assignee_and_author.rb- 20110223180944_add_users_salt.rb- 20110223180953_salt_user_passwords.rb- 20110224000000_add_repositories_path_encoding.rb- 20110226120112_change_repositories_password_limit.rb- 20110226120132_change_auth_sources_account_password_limit.rb- 20110227125750_change_journal_details_values_to_text.rb- 20110228000000_add_repositories_log_encoding.rb- 20110228000100_copy_repositories_log_encoding.rb- 20110314014400_add_start_date_to_versions.rb- 20110401192910_add_index_to_users_type.rb- 20110519194936_remove_comments_from_wiki_content.rb- 20110729125454_remove_double_initial_wiki_content_journals.rb- MIGRATIONS- end-end-# rubocop:enable Naming/ClassAndModuleCamelCasediff --git a/db/migrate/aggregated/to_7_1.rb b/db/migrate/aggregated/to_7_1.rbdeleted file mode 100644index f132eacc749..00000000000--- a/db/migrate/aggregated/to_7_1.rb+++ /dev/null@@ -1,213 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require_relative "base"--# rubocop:disable Naming/ClassAndModuleCamelCase-class Aggregated::To_7_1 < Aggregated::Base- def self.migrations- <<-MIGRATIONS- 0_aggregated_migrations.rb- 20110211160100_add_summary_to_projects.rb- 20110817142220_add_display_sums_field_to_migration.rb- 20111114124552_add_user_first_logged_in_and_impaired_fields.rb- 20120319095930_localize_email_header_and_footer.rb- 20120319135006_add_custom_field_translation_table.rb- 20120529090411_create_delayed_jobs.rb- 20120731091543_use_the_full_sti_class_names_for_repositories.rb- 20120731135140_create_wiki_menu_items.rb- 20120802152122_rename_auth_source_ldap.rb- 20120809131659_create_wiki_menu_item_for_existing_wikis.rb- 20120828171423_make_groups_users_a_model.rb- 20121004054229_add_wiki_list_attachments.rb- 20121030111651_rename_acts_as_journalized_changes_column.rb- 20121101111303_add_missing_indexes_on_wiki_menu_items.rb- 20121114100641_aggregated_announcements_migrations.rb- 20130204140624_add_index_on_identifier_to_projects.rb- 20130315124655_add_longer_login_to_users.rb- 20130325165622_remove_gantt_related_data_from_database.rb- 20130409133700_add_timelines_project_type_id_to_projects.rb- 20130409133701_create_timelines_project_types.rb- 20130409133702_create_timelines_planning_element_types.rb- 20130409133703_create_timelines_planning_elements.rb- 20130409133704_create_timelines_scenarios.rb- 20130409133705_create_timelines_alternate_dates.rb- 20130409133706_add_timelines_responsible_id_to_projects.rb- 20130409133707_create_timelines_colors.rb- 20130409133708_create_timelines_reportings.rb- 20130409133709_create_timelines_available_project_statuses.rb- 20130409133710_create_timelines_project_associations.rb- 20130409133711_create_timelines_enabled_planning_element_types.rb- 20130409133712_create_timelines_default_planning_element_types.rb- 20130409133713_migrate_planning_element_type_to_project_association.rb- 20130409133714_remove_project_type_id_from_timelines_planning_element_types.rb- 20130409133715_create_timelines_timelines.rb- 20130409133717_add_options_to_timelines_timelines.rb- 20130409133718_remove_content_from_timelines_timelines.rb- 20130409133719_add_indexes_to_timelines_alternate_dates_to_secure_at_scope.rb- 20130409133720_add_deleted_at_to_timelines_planning_elements.rb- 20130409133721_allow_null_position_in_colors.rb- 20130409133722_allow_null_position_in_planning_element_types.rb- 20130409133723_allow_null_position_in_project_types.rb- 20130611154020_remove_timelines_namespace.rb- 20130612120042_migrate_serialized_yaml_from_syck_to_psych.rb- 20130613075253_add_force_password_change_to_user.rb- 20130619081234_create_user_passwords.rb- 20130620082322_create_work_packages.rb- 20130625124242_work_package_custom_field_data_migration.rb- 20130628092725_add_failed_login_count_last_failed_login_on_to_user.rb- 20130709084751_rename_end_date_on_alternate_dates.rb- 20130710145350_remove_end_date_from_work_packages.rb- 20130717134318_rename_changeset_wp_join_table.rb- 20130719133922_rename_trackers_to_types.rb- 20130722154555_rename_work_package_sti_column.rb- 20130723092240_add_activity_module.rb- 20130723134527_increase_journals_changed_data_limit.rb- 20130724143418_add_planning_element_type_properties_to_type.rb- 20130729114110_move_planning_element_types_to_legacy_planning_element_types.rb- 20130806075000_add_standard_column_to_type_table.rb- 20130807081927_move_journals_to_legacy_journals.rb- 20130807082645_create_normalized_journals.rb- 20130807083715_create_attachment_journals.rb- 20130807083716_change_attachment_journals_description_length.rb- 20130807084417_create_work_package_journals.rb- 20130807084708_create_message_journals.rb- 20130807085108_create_news_journals.rb- 20130807085245_create_wiki_content_journals.rb- 20130807085430_create_time_entry_journals.rb- 20130807085714_create_changeset_journals.rb- 20130807141542_remove_files_attached_to_projects_and_versions.rb- 20130813062401_add_attachable_journal.rb- 20130813062513_add_customizable_journal.rb- 20130813062523_fix_customizable_journal_value_column.rb- 20130814130142_remove_documents.rb- 20130828093647_remove_alternate_dates_and_scenarios.rb- 20130829084747_drop_model_journals_updated_on_column.rb- 20130916094339_legacy_issues_to_work_packages.rb- 20130916123916_planning_element_types_data_to_types.rb- 20130917101922_migrate_query_tracker_references_to_type.rb- 20130917122118_remove_is_in_chlog_from_types.rb- 20130917131710_planning_element_data_to_work_packages.rb- 20130918111753_migrate_user_rights.rb- 20130919105841_migrate_settings_to_work_package.rb- 20130919145142_rename_issue_relations_to_relations.rb- 20130920081120_journal_indices.rb- 20130920081135_legacy_attachment_journal_data.rb- 20130920085055_legacy_changeset_journal_data.rb- 20130920090201_legacy_news_journal_data.rb- 20130920090641_legacy_message_journal_data.rb- 20130920092800_legacy_time_entry_journal_data.rb- 20130920093823_legacy_wiki_content_journal_data.rb- 20130920094524_legacy_issue_journal_data.rb- 20130920095747_legacy_planning_element_journal_data.rb- 20130920142714_update_attachment_container.rb- 20130920150143_journal_activities_data.rb- 20131001075217_rename_issue_category_to_category.rb- 20131001105659_rename_issue_statuses_to_statuses.rb- 20131004141959_generalize_wiki_menu_items.rb- 20131007062401_migrate_text_references_to_issues_and_planning_elements.rb- 20131009083648_work_package_indices.rb- 20131015064141_migrate_timelines_end_date_property_in_options.rb- 20131015121430_index_on_users.rb- 20131016075650_add_queue_to_delayed_jobs.rb- 20131017064039_repair_work_packages_initial_attachable_journal.rb- 20131018134525_repair_messages_initial_attachable_journal.rb- 20131018134530_repair_customizable_journals.rb- 20131018134545_add_missing_attachable_journals.rb- 20131018134590_add_missing_customizable_journals.rb- 20131024115743_migrate_remaining_core_settings.rb- 20131024140048_migrate_timelines_options.rb- 20131031170857_fix_watcher_work_package_associations.rb- 20131101125921_migrate_default_values_in_work_package_journals.rb- 20131108124300_add_index_to_all_the_journals.rb- 20131114132911_migrate_planning_element_links_in_journal_notes.rb- 20131115155147_fix_parent_ids_in_work_package_journals_of_former_planning_elements.rb- 20131126112911_migrate_update_create_column_reference_in_queries.rb- 20131202094511_delete_former_deleted_planning_elements.rb- 20131210113056_repair_invalid_default_work_package_custom_values.rb- 20131216171110_migrate_timelines_enumerations.rb- 20131219084934_add_enabled_modules_name_index.rb- 20140122161742_remove_journal_columns.rb- 20140127134733_fix_issue_in_notifications.rb- 20140203141127_rename_modulename_issue_tracking.rb- 20140311120609_add_sticked_on_field_to_messages.rb- 20140411142338_clear_identity_urls_on_users.rb- 20140414141459_remove_openid_entirely.rb- 20140429152018_add_sessions_table.rb- 20140430125956_reset_content_types.rb- 20140602112515_drop_work_packages_priority_not_null_constraint.rb- 20140610125207_add_updated_at_index_to_work_packages.rb- 20141215104802_migrate_attachments_to_carrier_wave.rb- 20150116095004_patch_corrupt_attachments.rb- 20150623151337_hide_mail_by_default.rb- 20150629075221_add_scm_type_to_repositories.rb- 20150716133712_add_unique_index_on_journals.rb- 20150716163704_remove_filesystem_repositories.rb- 20150729145732_add_storage_information_to_repository.rb- 20150819143300_underscore_scm_settings.rb- 20150820133700_denullify_display_sums.rb- 20150827133700_remove_project_homepage.rb- 20151005113102_remove_summary_from_project.rb- 20151028063433_boolearlize_bool_custom_values.rb- 20151116110245_fix_customizable_bool_values.rb- 20160125143638_index_member_roles_inherited_from.rb- 20160419103544_add_attribute_visibility_to_types.rb- 20160503150449_add_indexes_for_latest_activity.rb- 20160726090624_add_slug_to_wiki_pages.rb- 20160803094931_wiki_menu_titles_to_slug.rb- 20160824121151_add_user_id_to_sessions.rb- 20160829225633_introduce_bcrypt_passwords.rb- 20160907113604_normalize_permissions.rb- 20160913081236_type_attribute_visibility_to_hash.rb- 20160913125802_timeline_options_to_hash.rb- 20160914124514_harmonize_bool_custom_values.rb- 20160926102618_setting_value_to_hash.rb- 20161017102547_add_description_to_relations.rb- 20161025135400_query_empty_column_names_to_array.rb- 20161102160032_create_enterprise_token.rb- 20161116130657_create_custom_styles.rb- 20161213191919_remove_category_name_restriction.rb- 20161219134700_add_attr_admin_to_ldap.rb- 20170116105342_add_custom_options.rb- 20170117112648_create_design_colors.rb- 20170222094032_add_attribute_groups_to_type.rb- 20170308120915_migrate_missed_list_custom_values.rb- 20170330084810_remove_translations_from_custom_fields.rb- 20170404110156_extend_query_model.rb- 20170407074032_add_hierarchy_to_query.rb- 20170411065946_v3_to_internal_group_by.rb- 20170418064453_add_timestamp_to_custom_fields.rb- 20170420082944_remove_legacy_tables.rb- 20170421071136_set_empty_columns_to_null.rb- 20170421071137_migrate_query_custom_field_filters.rb- 20170602073043_save_zoom_level_in_query.rb- 20170614131555_add_favicon_touch_icon_to_custom_style.rb- MIGRATIONS- end-end-# rubocop:enable Naming/ClassAndModuleCamelCasediff --git a/db/migrate/20240306154737_create_index_good_job_jobs_for_candidate_lookup.rb b/db/migrate/extensions/base.rbsimilarity index 59%rename from db/migrate/20240306154737_create_index_good_job_jobs_for_candidate_lookup.rbrename to db/migrate/extensions/base.rbindex d62d826c7f6..63060ec763c 100644--- a/db/migrate/20240306154737_create_index_good_job_jobs_for_candidate_lookup.rb+++ b/db/migrate/extensions/base.rb@@ -1,6 +1,6 @@# frozen_string_literal: true-#-- copyright+# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -26,23 +26,45 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++-class CreateIndexGoodJobJobsForCandidateLookup < ActiveRecord::Migration[7.1]- disable_ddl_transaction!+module Extensions; end- def change- reversible do |dir|- dir.up do- # Ensure this incremental update migration is idempotent- # with monolithic install migration.- return if connection.index_name_exists?(:good_jobs, :index_good_job_jobs_for_candidate_lookup)+class Extensions::Base+ class << self+ def extension(name)+ @extension = name+ end++ def creation_sql(sql = nil)+ if sql+ @creation_sql = sql+ else+ @creation_sql ||= <<~SQL.squish+ CREATE EXTENSION IF NOT EXISTS #{@extension} WITH SCHEMA pg_catalog;+ SQLendend- add_index :good_jobs, %i[priority created_at], order: { priority: "ASC NULLS LAST", created_at: :asc },- where: "finished_at IS NULL",- name: :index_good_job_jobs_for_candidate_lookup,- algorithm: :concurrently+ def module_text(text = nil)+ if text+ @module_text = text+ else+ @module_text ||= <<~MESSAGE++ \e[33mWARNING:\e[0m Could not find the `#{@extension}` extension for PostgreSQL.+ Please install the postgresql-contrib module for your PostgreSQL installation and re-run the migrations.++ MESSAGE+ end+ end++ def create(migration)+ migration.execute(creation_sql)+ rescue StandardError => e+ raise unless e.message.include?(@extension)++ abort module_text+ endendenddiff --git a/db/migrate/20180903110212_add_highlighting_to_query.rb b/db/migrate/extensions/btree_gist.rbsimilarity index 88%rename from db/migrate/20180903110212_add_highlighting_to_query.rbrename to db/migrate/extensions/btree_gist.rbindex 6ff7268e8da..2f58a17dcce 100644--- a/db/migrate/20180903110212_add_highlighting_to_query.rb+++ b/db/migrate/extensions/btree_gist.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,10 +26,10 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++++require_relative "base"-class AddHighlightingToQuery < ActiveRecord::Migration[5.1]- def change- add_column :queries, :highlighting_mode, :text- end+class Extensions::BtreeGist < Extensions::Base+ extension "btree_gist"enddiff --git a/db/migrate/extensions/pg_trgm.rb b/db/migrate/extensions/pg_trgm.rbnew file mode 100644index 00000000000..2339a5cf664--- /dev/null+++ b/db/migrate/extensions/pg_trgm.rb@@ -0,0 +1,43 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require_relative "base"++class Extensions::PgTrgm < Extensions::Base+ extension "pg_trgm"+ module_text <<~MESSAGE++ \e[33mWARNING:\e[0m Could not find the `pg_trgm` extension for PostgreSQL.+ Please install the postgresql-contrib module for your PostgreSQL installation and re-run the migrations.++ Read more about the contrib module at `https://www.postgresql.org/docs/current/contrib.html`.++ MESSAGE+enddiff --git a/db/migrate/extensions/unaccent.rb b/db/migrate/extensions/unaccent.rbnew file mode 100644index 00000000000..9cc8569423a--- /dev/null+++ b/db/migrate/extensions/unaccent.rb@@ -0,0 +1,43 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require_relative "base"++class Extensions::Unaccent < Extensions::Base+ extension "unaccent"+ module_text <<~MESSAGE++ \e[33mWARNING:\e[0m Could not find the `unaccent` extension for PostgreSQL.+ Please install the postgresql-contrib module for your PostgreSQL installation and re-run the migrations.++ Read more about the contrib module at `https://www.postgresql.org/docs/current/contrib.html`.++ MESSAGE+enddiff --git a/db/migrate/20230731153909_add_file_link_journals_to_existing_containers.rb b/db/migrate/extensions/version_name_collation.rbsimilarity index 67%rename from db/migrate/20230731153909_add_file_link_journals_to_existing_containers.rbrename to db/migrate/extensions/version_name_collation.rbindex d4482548176..fb4ac7ee148 100644--- a/db/migrate/20230731153909_add_file_link_journals_to_existing_containers.rb+++ b/db/migrate/extensions/version_name_collation.rb@@ -1,6 +1,6 @@# frozen_string_literal: true-#-- copyright+# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -26,21 +26,22 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++-class AddFileLinkJournalsToExistingContainers < ActiveRecord::Migration[7.0]- def up- SystemUser.reset_column_information- system_user = SystemUser.first- containers = Storages::FileLink.includes(:container).map(&:container).uniq.compact+require_relative "base"- containers.each do |container|- next unless container.class.journaled?+class Extensions::VersionNameCollation < Extensions::Base+ creation_sql <<~SQL.squish+ CREATE COLLATION IF NOT EXISTS versions_name (provider = icu, locale = "und-u-kn-true")+ SQL+ extension "encoding"+ module_text <<~MESSAGE- Journals::CreateService.new(container, system_user)- .call(cause: Journal::CausedBySystemUpdate.new(feature: "file_links_journal"))- end- end+ \e[31mERROR:\e[0m Failed to create an ICU collation with current database encoding.+ You need to change the database encoding before proceeding.- def down; end+ Please check the instructions on how to do it:+ https://www.openproject.org/docs/installation-and-operations/misc/changing-database-encoding/++ MESSAGEenddiff --git a/db/migrate/migration_utils/migration_squasher.rb b/db/migrate/migration_utils/migration_squasher.rbindex bb3c05edce1..fdd690e90b2 100644--- a/db/migrate/migration_utils/migration_squasher.rb+++ b/db/migrate/migration_utils/migration_squasher.rb@@ -49,7 +49,7 @@ module Migration# All migrations that this migration aggregates have already# been applied. In this case, remove the information about those# migrations from the schema_migrations table and we're done.- ActiveRecord::Base.connection.execute <<-SQL + (intersection.map { |version| <<-CONDITIONS }).join(" OR ")+ ActiveRecord::Base.connection.execute <<-SQL.squish + (intersection.map { |version| <<-CONDITIONS }).join(" OR ")DELETE FROM#{quoted_schema_migrations_table_name}WHEREdiff --git a/modules/reporting/db/migrate/20180323130704_to_v710_aggregated_reporting_migrations.rb b/db/migrate/migration_utils/squashed_migration.rbsimilarity index 54%rename from modules/reporting/db/migrate/20180323130704_to_v710_aggregated_reporting_migrations.rbrename to db/migrate/migration_utils/squashed_migration.rbindex 2258b4a26bd..8960b60ad08 100644--- a/modules/reporting/db/migrate/20180323130704_to_v710_aggregated_reporting_migrations.rb+++ b/db/migrate/migration_utils/squashed_migration.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,40 +26,60 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++require Rails.root.join("db/migrate/migration_utils/migration_squasher").to_s-# This migration aggregates the migrations detailed in MIGRATION_FILES-class ToV710AggregatedReportingMigrations < ActiveRecord::Migration[5.1]- MIGRATION_FILES = <<-MIGRATIONS- 20110215143061_aggregated_reporting_migrations.rb- 20130612104243_reporting_migrate_serialized_yaml.rb- 20130925090243_cost_reports_migration.rb- MIGRATIONS- def up- Migration::MigrationSquasher.squash(migrations) do- create_table "cost_queries", id: :integer do |t|- t.integer "user_id", null: false- t.integer "project_id"- t.string "name", null: false- t.boolean "is_public", default: false, null: false- t.datetime "created_on", null: false- t.datetime "updated_on", null: false- t.string "serialized", limit: 2000, null: false- end+class SquashedMigration < ActiveRecord::Migration[8.0]+ class_attribute :minimum_version, default: "15"++ def self.squashed_migrations(*migrations)+ if migrations.any?+ @squashed_migrations = migrations+ else+ @squashed_migrations.map { |m| m.gsub(/_.*\z/, "") }endend- def down- drop_table "cost_queries"+ def self.tables(*tables)+ if tables.any?+ @tables = tables+ else+ @tables || []+ endend- private+ def self.extensions(*extensions)+ if extensions.any?+ @extensions = extensions+ else+ @extensions || []+ end+ end- def migrations- MIGRATION_FILES.split.map do |m|- m.gsub(/_.*\z/, "")+ def self.modifications(&block)+ if block_given?+ @modifications = block+ else+ @modificationsendend++ def up+ Migration::MigrationSquasher.squash(self.class.squashed_migrations) do+ self.class.extensions.each do |extension|+ extension.create(self)+ end++ self.class.tables.each do |table|+ table.create(self)+ end++ self.class.modifications&.call+ end+ end++ def down+ raise ActiveRecord::IrreversibleMigration, "Use OpenProject v#{self.class.minimum_version} for the down migrations"+ endenddiff --git a/db/migrate/tables/announcements.rb b/db/migrate/tables/announcements.rbindex b57a0567e5a..f7c007b2939 100644--- a/db/migrate/tables/announcements.rb+++ b/db/migrate/tables/announcements.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -34,7 +36,7 @@ class Tables::Announcements < Tables::Baset.text :textt.date :show_untilt.boolean :active, default: false- t.timestamps null: true # compatibility to pre 5.1 migrations+ t.timestamps precision: nil, null: true # compatibility to pre 5.1 migrationst.index %i[show_until active]enddiff --git a/db/migrate/tables/attachable_journals.rb b/db/migrate/tables/attachable_journals.rbindex 387dd44bffe..407ce8c8b90 100644--- a/db/migrate/tables/attachable_journals.rb+++ b/db/migrate/tables/attachable_journals.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -30,10 +32,10 @@ require_relative "base"class Tables::AttachableJournals < Tables::Basedef self.table(migration)- create_table migration do |t|- t.integer :journal_id, null: false- t.integer :attachment_id, null: false- t.string :filename, default: "", null: false+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestamps+ t.bigint :journal_id, null: false+ t.bigint :attachment_id, null: false+ t.string :filename, default: nil, null: falset.index :journal_idt.index :attachment_iddiff --git a/db/migrate/tables/attachment_journals.rb b/db/migrate/tables/attachment_journals.rbindex a6de976da94..8b06730f1da 100644--- a/db/migrate/tables/attachment_journals.rb+++ b/db/migrate/tables/attachment_journals.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -30,20 +32,17 @@ require_relative "base"class Tables::AttachmentJournals < Tables::Basedef self.table(migration)- create_table migration do |t|- t.integer :journal_id, null: false- t.integer :container_id, default: 0, null: false- t.string :container_type, limit: 30, default: "", null: false- t.string :filename, default: "", null: false- t.string :disk_filename, default: "", null: false- t.integer :filesize, default: 0, null: false- t.string :content_type, default: ""- t.string :digest, limit: 40, default: "", null: false- t.integer :downloads, default: 0, null: false- t.integer :author_id, default: 0, null: false+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestamps+ t.bigint :container_id, default: nil, null: true+ t.string :container_type, limit: 30, null: true+ t.string :filename, default: nil, null: false+ t.string :disk_filename, default: nil, null: false+ t.integer :filesize, default: nil, null: false, limit: 8+ t.string :content_type, default: nil+ t.string :digest, limit: 40, default: nil, null: false+ t.integer :downloads, default: nil, null: false+ t.bigint :author_id, null: falset.text :description-- t.index [:journal_id]endendenddiff --git a/db/migrate/tables/attachments.rb b/db/migrate/tables/attachments.rbindex 423a2c6bcf0..448aafee582 100644--- a/db/migrate/tables/attachments.rb+++ b/db/migrate/tables/attachments.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -29,24 +31,31 @@require_relative "base"class Tables::Attachments < Tables::Base- def self.table(migration)+ def self.table(migration) # rubocop:disable Metrics/AbcSizecreate_table migration do |t|- t.integer :container_id, default: 0, null: false- t.string :container_type, limit: 30, default: "", null: false+ t.bigint :container_id, default: nil, null: true+ t.string :container_type, limit: 30, null: truet.string :filename, default: "", null: falset.string :disk_filename, default: "", null: false- t.integer :filesize, default: 0, null: false+ t.integer :filesize, default: 0, null: false, limit: 8t.string :content_type, default: ""t.string :digest, limit: 40, default: "", null: falset.integer :downloads, default: 0, null: false- t.integer :author_id, default: 0, null: false- t.datetime :created_on+ t.bigint :author_id, null: false+ t.datetime :created_at, precision: nilt.string :descriptiont.string :file+ t.text :fulltext, limit: 4.megabytes+ t.tsvector :fulltext_tsv+ t.tsvector :file_tsv+ t.datetime :updated_at, precision: nil+ t.integer :status, default: 0, null: falset.index :author_id, name: "index_attachments_on_author_id"t.index %i[container_id container_type], name: "index_attachments_on_container_id_and_container_type"- t.index :created_on, name: "index_attachments_on_created_on"+ t.index :created_at, name: "index_attachments_on_created_at"+ t.index :fulltext_tsv, using: "gin"+ t.index :file_tsv, using: "gin"endendenddiff --git a/db/migrate/20170703075208_add_attribute_help_texts.rb b/db/migrate/tables/attribute_help_texts.rbsimilarity index 85%rename from db/migrate/20170703075208_add_attribute_help_texts.rbrename to db/migrate/tables/attribute_help_texts.rbindex 298506100ac..911c38365f2 100644--- a/db/migrate/20170703075208_add_attribute_help_texts.rb+++ b/db/migrate/tables/attribute_help_texts.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,16 +26,18 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++++require_relative "base"-class AddAttributeHelpTexts < ActiveRecord::Migration[5.1]- def change- create_table :attribute_help_texts, id: :integer do |t|+class Tables::AttributeHelpTexts < Tables::Base+ def self.table(migration)+ create_table migration do |t|t.text :help_text, null: falset.string :type, null: falset.string :attribute_name, null: false- t.timestamps+ t.timestamps precision: nilendendenddiff --git a/db/migrate/20240801105918_add_auth_providers.rb b/db/migrate/tables/auth_providers.rbsimilarity index 90%rename from db/migrate/20240801105918_add_auth_providers.rbrename to db/migrate/tables/auth_providers.rbindex 6acf6c240ff..55b381a9649 100644--- a/db/migrate/20240801105918_add_auth_providers.rb+++ b/db/migrate/tables/auth_providers.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,11 +26,13 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++++require_relative "base"-class AddAuthProviders < ActiveRecord::Migration[7.1]- def change- create_table :auth_providers do |t|+class Tables::AuthProviders < Tables::Base+ def self.table(migration)+ create_table migration do |t|t.string :type, null: falset.string :display_name, null: false, index: { unique: true }t.string :slug, null: false, index: { unique: true }diff --git a/db/migrate/tables/base.rb b/db/migrate/tables/base.rbindex 90eecb5e376..d5622b4663a 100644--- a/db/migrate/tables/base.rb+++ b/db/migrate/tables/base.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -37,12 +39,20 @@ class Tables::Basename.demodulize.underscore.to_send- def self.id_options- { id: :integer }+ def self.create_table(migration, id: :bigint, **, &)+ migration.create_table(table_name, id:, **, &)end- def self.create_table(migration, &)- migration.create_table table_name, **id_options.merge(bulk: true), &+ def self.create_unlogged_table(migration, id: :bigint, **, &)+ create_unlogged_tables = ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.create_unlogged_tables++ begin+ ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.create_unlogged_tables = true++ create_table(migration, id:, **, &) # rubocop:disable Rails/CreateTableWithTimestamps+ ensure+ ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.create_unlogged_tables = create_unlogged_tables+ endenddef self.table(_migration)diff --git a/db/migrate/tables/categories.rb b/db/migrate/tables/categories.rbindex e4a4e838ee3..4e6caa16c10 100644--- a/db/migrate/tables/categories.rb+++ b/db/migrate/tables/categories.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -31,9 +33,10 @@ require_relative "base"class Tables::Categories < Tables::Basedef self.table(migration)create_table migration do |t|- t.integer :project_id, default: 0, null: false- t.string :name, limit: 256, null: false, default: ""- t.integer :assigned_to_id+ t.bigint :project_id, null: false+ t.string :name, null: false, default: ""+ t.bigint :assigned_to_id+ t.timestamps precision: nilt.index :assigned_to_id, name: "index_categories_on_assigned_to_id"t.index :project_id, name: "issue_categories_project_id"diff --git a/db/migrate/tables/changes.rb b/db/migrate/tables/changes.rbindex 2cd42474041..3939db33ef8 100644--- a/db/migrate/tables/changes.rb+++ b/db/migrate/tables/changes.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -30,8 +32,8 @@ require_relative "base"class Tables::Changes < Tables::Basedef self.table(migration)- create_table migration do |t|- t.integer :changeset_id, null: false+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestamps+ t.bigint :changeset_id, null: falset.string :action, limit: 1, default: "", null: falset.text :path, null: falset.text :from_pathdiff --git a/db/migrate/tables/changeset_journals.rb b/db/migrate/tables/changeset_journals.rbindex a7b7847a0f6..cba0682b2e8 100644--- a/db/migrate/tables/changeset_journals.rb+++ b/db/migrate/tables/changeset_journals.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -30,18 +32,15 @@ require_relative "base"class Tables::ChangesetJournals < Tables::Basedef self.table(migration)- create_table migration do |t|- t.integer :journal_id, null: false- t.integer :repository_id, null: false+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestamps+ t.bigint :repository_id, null: falset.string :revision, null: falset.string :committer- t.datetime :committed_on, null: false+ t.datetime :committed_on, precision: nil, null: falset.text :commentst.date :commit_datet.string :scmid- t.integer :user_id-- t.index [:journal_id]+ t.bigint :user_idendendenddiff --git a/db/migrate/tables/changesets.rb b/db/migrate/tables/changesets.rbindex d6cd0e63b66..1ea71eb7f08 100644--- a/db/migrate/tables/changesets.rb+++ b/db/migrate/tables/changesets.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -30,15 +32,15 @@ require_relative "base"class Tables::Changesets < Tables::Basedef self.table(migration)- create_table migration do |t|- t.integer :repository_id, null: false+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestamps+ t.bigint :repository_id, null: falset.string :revision, null: falset.string :committer- t.datetime :committed_on, null: false+ t.datetime :committed_on, precision: nil, null: falset.text :commentst.date :commit_datet.string :scmid- t.integer :user_id+ t.bigint :user_idt.index :committed_on, name: "index_changesets_on_committed_on"t.index %i[repository_id revision], name: "changesets_repos_rev", unique: truediff --git a/db/migrate/tables/changesets_work_packages.rb b/db/migrate/tables/changesets_work_packages.rbindex 788990751b3..3f520167066 100644--- a/db/migrate/tables/changesets_work_packages.rb+++ b/db/migrate/tables/changesets_work_packages.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -29,14 +31,10 @@require_relative "base"class Tables::ChangesetsWorkPackages < Tables::Base- def self.id_options- { id: false }- end-def self.table(migration)- create_table migration do |t|- t.integer :changeset_id, null: false- t.integer :work_package_id, null: false+ create_table migration, id: false do |t|+ t.bigint :changeset_id, null: false+ t.bigint :work_package_id, null: falset.index %i[changeset_id work_package_id],unique: true,diff --git a/db/migrate/tables/timelines.rb b/db/migrate/tables/colors.rbsimilarity index 89%rename from db/migrate/tables/timelines.rbrename to db/migrate/tables/colors.rbindex d793c23af5d..a4e2f53035f 100644--- a/db/migrate/tables/timelines.rb+++ b/db/migrate/tables/colors.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -28,13 +30,13 @@require_relative "base"-class Tables::Timelines < Tables::Base+class Tables::Colors < Tables::Basedef self.table(migration)create_table migration do |t|t.string :name, null: false- t.belongs_to :project, type: :int- t.timestamps null: true- t.text :options+ t.string :hexcode, null: false++ t.timestamps precision: nil, null: trueendendenddiff --git a/db/migrate/tables/comments.rb b/db/migrate/tables/comments.rbindex 57ab69a942d..ce0b639ae6e 100644--- a/db/migrate/tables/comments.rb+++ b/db/migrate/tables/comments.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -32,11 +34,10 @@ class Tables::Comments < Tables::Basedef self.table(migration)create_table migration do |t|t.string :commented_type, limit: 30, default: "", null: false- t.integer :commented_id, default: 0, null: false- t.integer :author_id, default: 0, null: false+ t.bigint :commented_id, null: false+ t.bigint :author_id, null: falset.text :comments- t.datetime :created_on, null: false- t.datetime :updated_on, null: false+ t.timestamps precision: nil, default: -> { "CURRENT_TIMESTAMP" }t.index :author_id, name: "index_comments_on_author_id"t.index %i[commented_id commented_type], name: "index_comments_on_commented_id_and_commented_type"diff --git a/db/migrate/tables/custom_actions.rb b/db/migrate/tables/custom_actions.rbnew file mode 100644index 00000000000..922a2e55c20--- /dev/null+++ b/db/migrate/tables/custom_actions.rb@@ -0,0 +1,42 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require_relative "base"++class Tables::CustomActions < Tables::Base+ def self.table(migration)+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestamps+ t.string :name+ t.text :actions+ t.text :description+ t.integer :position+ end+ end+enddiff --git a/db/migrate/tables/custom_actions_projects.rb b/db/migrate/tables/custom_actions_projects.rbnew file mode 100644index 00000000000..5a1f5d3da4f--- /dev/null+++ b/db/migrate/tables/custom_actions_projects.rb@@ -0,0 +1,40 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require_relative "base"++class Tables::CustomActionsProjects < Tables::Base+ def self.table(migration)+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestamps+ t.belongs_to :project+ t.belongs_to :custom_action+ end+ end+enddiff --git a/db/migrate/tables/custom_actions_roles.rb b/db/migrate/tables/custom_actions_roles.rbnew file mode 100644index 00000000000..4cf3dee4284--- /dev/null+++ b/db/migrate/tables/custom_actions_roles.rb@@ -0,0 +1,40 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require_relative "base"++class Tables::CustomActionsRoles < Tables::Base+ def self.table(migration)+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestamps+ t.belongs_to :role+ t.belongs_to :custom_action+ end+ end+enddiff --git a/db/migrate/tables/custom_actions_statuses.rb b/db/migrate/tables/custom_actions_statuses.rbnew file mode 100644index 00000000000..a3268c9fb36--- /dev/null+++ b/db/migrate/tables/custom_actions_statuses.rb@@ -0,0 +1,40 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require_relative "base"++class Tables::CustomActionsStatuses < Tables::Base+ def self.table(migration)+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestamps+ t.belongs_to :status+ t.belongs_to :custom_action+ end+ end+enddiff --git a/db/migrate/tables/custom_actions_types.rb b/db/migrate/tables/custom_actions_types.rbnew file mode 100644index 00000000000..4873919b1cf--- /dev/null+++ b/db/migrate/tables/custom_actions_types.rb@@ -0,0 +1,40 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require_relative "base"++class Tables::CustomActionsTypes < Tables::Base+ def self.table(migration)+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestamps+ t.belongs_to :type+ t.belongs_to :custom_action+ end+ end+enddiff --git a/db/migrate/tables/project_associations.rb b/db/migrate/tables/custom_field_sections.rbsimilarity index 85%rename from db/migrate/tables/project_associations.rbrename to db/migrate/tables/custom_field_sections.rbindex 3630cf53ba3..12ff6acdd0b 100644--- a/db/migrate/tables/project_associations.rb+++ b/db/migrate/tables/custom_field_sections.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,19 +26,18 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++require_relative "base"-class Tables::ProjectAssociations < Tables::Base+class Tables::CustomFieldSections < Tables::Basedef self.table(migration)create_table migration do |t|- t.belongs_to :project_a, type: :int- t.belongs_to :project_b, type: :int-- t.column :description, :text+ t.integer :position+ t.string :name+ t.string :type # project or nil (-> work_package)- t.timestamps null: true+ t.timestampsendendenddiff --git a/db/migrate/tables/custom_fields.rb b/db/migrate/tables/custom_fields.rbindex 3277e0421a7..bd5baddccd6 100644--- a/db/migrate/tables/custom_fields.rb+++ b/db/migrate/tables/custom_fields.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -29,8 +31,7 @@require_relative "base"class Tables::CustomFields < Tables::Base- # rubocop:disable Metrics/AbcSize- def self.table(migration)+ def self.table(migration) # rubocop:disable Metrics/AbcSizecreate_table migration do |t|t.string :type, limit: 30, default: "", null: falset.string :field_format, limit: 30, default: "", null: false@@ -39,19 +40,22 @@ class Tables::CustomFields < Tables::Baset.integer :max_length, default: 0, null: falset.boolean :is_required, default: false, null: falset.boolean :is_for_all, default: false, null: false- t.boolean :is_filter, default: false, null: false+ t.boolean :is_filter, default: true, null: falset.integer :position, default: 1- t.boolean :searchable, default: false- t.boolean :editable, default: true- t.boolean :visible, default: true, null: false- t.boolean :multi_value, default: false+ t.boolean :searchable, default: false # rubocop:disable Rails/ThreeStateBooleanColumn+ t.boolean :editable, default: true # rubocop:disable Rails/ThreeStateBooleanColumn+ t.boolean :admin_only, default: false, null: false+ t.boolean :multi_value, default: false # rubocop:disable Rails/ThreeStateBooleanColumnt.text :default_value- t.string :name, limit: 255, default: nil- t.datetime :created_at- t.datetime :updated_at+ t.string :name, limit: nil, default: nil+ t.datetime :created_at, precision: nil+ t.datetime :updated_at, precision: nil+ t.boolean :content_right_to_left, default: false # rubocop:disable Rails/ThreeStateBooleanColumn+ t.boolean :allow_non_open_versions, default: false # rubocop:disable Rails/ThreeStateBooleanColumn+ t.references :custom_field_section+ t.integer :position_in_custom_field_section, null: truet.index %i[id type], name: "index_custom_fields_on_id_and_type"endend- # rubocop:enable Metrics/AbcSizeenddiff --git a/db/migrate/tables/custom_fields_projects.rb b/db/migrate/tables/custom_fields_projects.rbindex 9c6c2cdc76a..51cf42397ce 100644--- a/db/migrate/tables/custom_fields_projects.rb+++ b/db/migrate/tables/custom_fields_projects.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -29,17 +31,13 @@require_relative "base"class Tables::CustomFieldsProjects < Tables::Base- def self.id_options- { id: false }- end-def self.table(migration)- create_table migration do |t|- t.integer :custom_field_id, default: 0, null: false- t.integer :project_id, default: 0, null: false+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestamps+ t.references :custom_field, null: false, index: false, foreign_key: { on_delete: :cascade, on_update: :cascade }+ t.references :project, null: false, index: false, foreign_key: { on_delete: :cascade, on_update: :cascade }t.index %i[custom_field_id project_id],- name: "index_custom_fields_projects_on_custom_field_id_and_project_id"+ unique: trueendendenddiff --git a/db/migrate/tables/custom_fields_types.rb b/db/migrate/tables/custom_fields_types.rbindex f0384377ccc..41e7d04417a 100644--- a/db/migrate/tables/custom_fields_types.rb+++ b/db/migrate/tables/custom_fields_types.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -29,14 +31,10 @@require_relative "base"class Tables::CustomFieldsTypes < Tables::Base- def self.id_options- { id: false }- end-def self.table(migration)- create_table migration do |t|- t.integer :custom_field_id, default: 0, null: false- t.integer :type_id, default: 0, null: false+ create_table migration, id: false do |t|+ t.bigint :custom_field_id, null: false+ t.bigint :type_id, null: falset.index %i[custom_field_id type_id],name: :custom_fields_types_unique,diff --git a/db/migrate/tables/custom_options.rb b/db/migrate/tables/custom_options.rbindex ae56573c0af..c46e659beda 100644--- a/db/migrate/tables/custom_options.rb+++ b/db/migrate/tables/custom_options.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -31,12 +33,17 @@ require_relative "base"class Tables::CustomOptions < Tables::Basedef self.table(migration)create_table migration do |t|- t.integer :custom_field_id+ t.bigint :custom_field_idt.integer :positiont.boolean :default_valuet.text :value- t.datetime :created_at- t.datetime :updated_at+ t.timestamps precision: nil, null: true++ t.index :custom_field_id++ t.index :value,+ using: "gin",+ opclass: :gin_trgm_opsendendenddiff --git a/db/migrate/tables/custom_styles.rb b/db/migrate/tables/custom_styles.rbindex d70992c3f38..3fccbc8c5b2 100644--- a/db/migrate/tables/custom_styles.rb+++ b/db/migrate/tables/custom_styles.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -32,9 +34,14 @@ class Tables::CustomStyles < Tables::Basedef self.table(migration)create_table migration do |t|t.string :logo- t.timestamps+ t.timestamps precision: nilt.string :favicont.string :touch_icon+ t.string :theme, default: OpenProject::CustomStyles::ColorThemes::DEFAULT_THEME_NAME+ t.string :theme_logo, default: nil+ t.string :export_logo, default: nil+ t.string :export_cover, default: nil+ t.string :export_cover_text_color, default: nilendendenddiff --git a/db/migrate/tables/custom_values.rb b/db/migrate/tables/custom_values.rbindex 4c90950f8f7..d872e6f924a 100644--- a/db/migrate/tables/custom_values.rb+++ b/db/migrate/tables/custom_values.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -30,14 +32,17 @@ require_relative "base"class Tables::CustomValues < Tables::Basedef self.table(migration)- create_table migration do |t|+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestampst.string :customized_type, limit: 30, default: "", null: false- t.integer :customized_id, default: 0, null: false- t.integer :custom_field_id, default: 0, null: false+ t.bigint :customized_id, null: false+ t.bigint :custom_field_id, null: falset.text :valuet.index :custom_field_id, name: "index_custom_values_on_custom_field_id"t.index %i[customized_type customized_id], name: "custom_values_customized"+ t.index :value,+ using: "gin",+ opclass: :gin_trgm_opsendendenddiff --git a/db/migrate/tables/customizable_journals_table.rb b/db/migrate/tables/customizable_journals.rbsimilarity index 87%rename from db/migrate/tables/customizable_journals_table.rbrename to db/migrate/tables/customizable_journals.rbindex 8bc30f49db4..005dbca0c45 100644--- a/db/migrate/tables/customizable_journals_table.rb+++ b/db/migrate/tables/customizable_journals.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -30,9 +32,9 @@ require_relative "base"class Tables::CustomizableJournals < Tables::Basedef self.table(migration)- create_table migration do |t|- t.integer :journal_id, null: false- t.integer :custom_field_id, null: false+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestamps+ t.bigint :journal_id, null: false+ t.bigint :custom_field_id, null: falset.text :valuet.index :journal_iddiff --git a/db/migrate/tables/design_colors.rb b/db/migrate/tables/design_colors.rbindex 594f64e0e40..e454788e657 100644--- a/db/migrate/tables/design_colors.rb+++ b/db/migrate/tables/design_colors.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -34,7 +36,7 @@ class Tables::DesignColors < Tables::Baset.string :variablet.string :hexcode- t.timestamps+ t.timestamps precision: nilt.index :variable, unique: trueenddiff --git a/db/migrate/tables/emoji_reactions.rb b/db/migrate/tables/emoji_reactions.rbnew file mode 100644index 00000000000..404e0fa9d36--- /dev/null+++ b/db/migrate/tables/emoji_reactions.rb@@ -0,0 +1,47 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require_relative "base"++class Tables::EmojiReactions < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.references :user, null: false, foreign_key: true+ t.references :reactable, polymorphic: true, null: false+ t.string :reaction, null: false+ t.timestamps++ t.index :reaction+ t.index %i[user_id reactable_type reactable_id reaction],+ unique: true,+ name: "index_emoji_reactions_uniqueness"+ end+ end+enddiff --git a/db/migrate/tables/enabled_modules.rb b/db/migrate/tables/enabled_modules.rbindex 6809f1ee340..859e773dff9 100644--- a/db/migrate/tables/enabled_modules.rb+++ b/db/migrate/tables/enabled_modules.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -30,8 +32,8 @@ require_relative "base"class Tables::EnabledModules < Tables::Basedef self.table(migration)- create_table migration do |t|- t.integer :project_id+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestamps+ t.bigint :project_idt.string :name, null: falset.index :project_id, name: "enabled_modules_project_id"diff --git a/db/migrate/tables/enterprise_tokens.rb b/db/migrate/tables/enterprise_tokens.rbindex c2765061826..3669a647522 100644--- a/db/migrate/tables/enterprise_tokens.rb+++ b/db/migrate/tables/enterprise_tokens.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -33,7 +35,7 @@ class Tables::EnterpriseTokens < Tables::Basecreate_table migration do |t|t.text :encoded_token- t.timestamps+ t.timestamps precision: nilendendenddiff --git a/db/migrate/tables/enumerations.rb b/db/migrate/tables/enumerations.rbindex aafc948c3b1..ae4a096d5fe 100644--- a/db/migrate/tables/enumerations.rb+++ b/db/migrate/tables/enumerations.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -31,13 +33,15 @@ require_relative "base"class Tables::Enumerations < Tables::Basedef self.table(migration)create_table migration do |t|- t.string :name, limit: 30, default: "", null: false+ t.string :name, default: "", null: falset.integer :position, default: 1t.boolean :is_default, default: false, null: falset.string :typet.boolean :active, default: true, null: false- t.integer :project_id- t.integer :parent_id+ t.bigint :project_id+ t.bigint :parent_id+ t.timestamps precision: nil+ t.belongs_to :colort.index %i[id type], name: "index_enumerations_on_id_and_type"t.index :project_id, name: "index_enumerations_on_project_id"diff --git a/modules/storages/db/migrate/20230420063148_add_provider_fields_to_storages.rb b/db/migrate/tables/exports.rbsimilarity index 85%rename from modules/storages/db/migrate/20230420063148_add_provider_fields_to_storages.rbrename to db/migrate/tables/exports.rbindex c526b8cb7e1..587c83f7be5 100644--- a/modules/storages/db/migrate/20230420063148_add_provider_fields_to_storages.rb+++ b/db/migrate/tables/exports.rb@@ -1,5 +1,6 @@# frozen_string_literal: true+# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -25,10 +26,15 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++-class AddProviderFieldsToStorages < ActiveRecord::Migration[7.0]- def change- add_column :storages, :provider_fields, :jsonb, null: false, default: "{}"+require_relative "base"++class Tables::Exports < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.timestamps precision: nil+ t.string :type+ endendenddiff --git a/db/migrate/tables/favorites.rb b/db/migrate/tables/favorites.rbnew file mode 100644index 00000000000..6a5090f5f0d--- /dev/null+++ b/db/migrate/tables/favorites.rb@@ -0,0 +1,46 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require_relative "base"++class Tables::Favorites < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.references :user, null: false, foreign_key: true, index: true+ t.references :favored, null: false, polymorphic: true++ t.timestamps++ t.index %i[favored_type favored_id]+ t.index %i[user_id favored_type favored_id],+ unique: true+ end+ end+enddiff --git a/db/migrate/tables/forums.rb b/db/migrate/tables/forums.rbindex d7a72ba6112..a505a90e7f5 100644--- a/db/migrate/tables/forums.rb+++ b/db/migrate/tables/forums.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -27,7 +29,20 @@#++require_relative "base"-require_relative "boards"-class Tables::Forums < Tables::Boards+class Tables::Forums < Tables::Base+ def self.table(migration)+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestamps+ t.bigint :project_id, null: false+ t.string :name, default: "", null: false+ t.string :description+ t.integer :position, default: 1+ t.integer :topics_count, default: 0, null: false+ t.integer :messages_count, default: 0, null: false+ t.bigint :last_message_id++ t.index :last_message_id, name: "index_#{table_name}_on_last_message_id"+ t.index :project_id, name: "#{table_name}_project_id"+ end+ endenddiff --git a/db/migrate/tables/good_job_batches.rb b/db/migrate/tables/good_job_batches.rbnew file mode 100644index 00000000000..7fa899fe6d0--- /dev/null+++ b/db/migrate/tables/good_job_batches.rb@@ -0,0 +1,49 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require_relative "base"++class Tables::GoodJobBatches < Tables::Base+ def self.table(migration)+ create_table migration, id: :uuid do |t|+ t.timestamps+ t.text :description+ t.jsonb :serialized_properties+ t.text :on_finish+ t.text :on_success+ t.text :on_discard+ t.text :callback_queue_name+ t.integer :callback_priority+ t.datetime :enqueued_at+ t.datetime :discarded_at+ t.datetime :finished_at+ end+ end+enddiff --git a/db/migrate/tables/good_job_executions.rb b/db/migrate/tables/good_job_executions.rbnew file mode 100644index 00000000000..2c58b65b4b2--- /dev/null+++ b/db/migrate/tables/good_job_executions.rb@@ -0,0 +1,50 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require_relative "base"++class Tables::GoodJobExecutions < Tables::Base+ def self.table(migration)+ create_table migration, id: :uuid do |t|+ t.timestamps+ t.uuid :active_job_id, null: false+ t.text :job_class+ t.text :queue_name+ t.jsonb :serialized_params+ t.datetime :scheduled_at+ t.datetime :finished_at+ t.text :error+ t.integer :error_event, limit: 2++ t.index %i[active_job_id created_at],+ name: :index_good_job_executions_on_active_job_id_and_created_at+ end+ end+enddiff --git a/modules/storages/db/migrate/20230517075214_add_automatic_to_project_folder_modes.rb b/db/migrate/tables/good_job_processes.rbsimilarity index 85%rename from modules/storages/db/migrate/20230517075214_add_automatic_to_project_folder_modes.rbrename to db/migrate/tables/good_job_processes.rbindex 74c02c8a541..2fcb8c9e87e 100644--- a/modules/storages/db/migrate/20230517075214_add_automatic_to_project_folder_modes.rb+++ b/db/migrate/tables/good_job_processes.rb@@ -1,5 +1,6 @@# frozen_string_literal: true+# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -25,14 +26,15 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++-class AddAutomaticToProjectFolderModes < ActiveRecord::Migration[7.0]- disable_ddl_transaction!+require_relative "base"- def up- execute <<-SQL.squish- ALTER TYPE project_folder_modes ADD VALUE 'automatic';- SQL+class Tables::GoodJobProcesses < Tables::Base+ def self.table(migration)+ create_table migration, id: :uuid do |t|+ t.timestamps+ t.jsonb :state+ endendenddiff --git a/db/migrate/tables/good_job_settings.rb b/db/migrate/tables/good_job_settings.rbnew file mode 100644index 00000000000..e4c7c673ea9--- /dev/null+++ b/db/migrate/tables/good_job_settings.rb@@ -0,0 +1,42 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require_relative "base"++class Tables::GoodJobSettings < Tables::Base+ def self.table(migration)+ create_table migration, id: :uuid do |t|+ t.timestamps+ t.text :key+ t.jsonb :value+ t.index :key, unique: true+ end+ end+enddiff --git a/db/migrate/tables/good_jobs.rb b/db/migrate/tables/good_jobs.rbnew file mode 100644index 00000000000..9174e7fb51d--- /dev/null+++ b/db/migrate/tables/good_jobs.rb@@ -0,0 +1,94 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require_relative "base"++class Tables::GoodJobs < Tables::Base+ def self.table(migration) # rubocop:disable Metrics/AbcSize+ create_table migration, id: :uuid do |t|+ t.text :queue_name+ t.integer :priority+ t.jsonb :serialized_params+ t.datetime :scheduled_at+ t.datetime :performed_at+ t.datetime :finished_at+ t.text :error+ t.timestamps+ t.uuid :active_job_id+ t.text :concurrency_key+ t.text :cron_key+ t.uuid :retried_good_job_id+ t.datetime :cron_at+ t.uuid :batch_id+ t.uuid :batch_callback_id+ t.boolean :is_discrete # rubocop:disable Rails/ThreeStateBooleanColumn+ t.integer :executions_count+ t.text :job_class+ t.integer :error_event, limit: 2+ t.text :labels, array: true++ t.index :scheduled_at,+ where: "(finished_at IS NULL)",+ name: :index_good_jobs_on_scheduled_at+ t.index %i[queue_name scheduled_at],+ where: "(finished_at IS NULL)",+ name: :index_good_jobs_on_queue_name_and_scheduled_at+ t.index %i[active_job_id created_at],+ name: :index_good_jobs_on_active_job_id_and_created_at+ t.index :concurrency_key,+ where: "(finished_at IS NULL)",+ name: :index_good_jobs_on_concurrency_key_when_unfinished+ t.index [:finished_at],+ where: "retried_good_job_id IS NULL AND finished_at IS NOT NULL",+ name: :index_good_jobs_jobs_on_finished_at+ t.index %i[priority created_at],+ order: { priority: "DESC NULLS LAST", created_at: :asc },+ where: "finished_at IS NULL",+ name: :index_good_jobs_jobs_on_priority_created_at_when_unfinished+ t.index :batch_id, where: "batch_id IS NOT NULL"+ t.index :batch_callback_id, where: "batch_callback_id IS NOT NULL"+ t.index %i[cron_key created_at],+ where: "(cron_key IS NOT NULL)",+ name: :index_good_jobs_on_cron_key_and_created_at_cond+ t.index %i[cron_key cron_at],+ where: "(cron_key IS NOT NULL)",+ unique: true,+ name: :index_good_jobs_on_cron_key_and_cron_at_cond+ t.index :labels,+ using: :gin,+ where: "(labels IS NOT NULL)",+ name: :index_good_jobs_on_labels+ t.index %i[priority created_at],+ order: { priority: "ASC NULLS LAST", created_at: :asc },+ where: "finished_at IS NULL",+ name: :index_good_job_jobs_for_candidate_lookup+ end+ end+enddiff --git a/db/migrate/tables/group_users.rb b/db/migrate/tables/group_users.rbindex 0e828c9b040..10ed3c17ce1 100644--- a/db/migrate/tables/group_users.rb+++ b/db/migrate/tables/group_users.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -29,16 +31,14 @@require_relative "base"class Tables::GroupUsers < Tables::Base- def self.id_options- { id: false }- end-def self.table(migration)- create_table migration do |t|- t.integer :group_id, null: false- t.integer :user_id, null: false+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestamps+ t.bigint :group_id, null: false+ t.bigint :user_id, null: falset.index %i(group_id user_id), name: :group_user_ids, unique: true++ t.index %i[user_id group_id], unique: trueendendenddiff --git a/db/migrate/tables/hierarchical_item_hierarchies.rb b/db/migrate/tables/hierarchical_item_hierarchies.rbnew file mode 100644index 00000000000..05453ae4935--- /dev/null+++ b/db/migrate/tables/hierarchical_item_hierarchies.rb@@ -0,0 +1,48 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require_relative "base"++class Tables::HierarchicalItemHierarchies < Tables::Base+ def self.table(migration)+ create_table migration, id: false do |t|+ t.integer :ancestor_id, null: false # TODO: turn into bigint+ t.integer :descendant_id, null: false # TODO: turn into bigint+ t.integer :generations, null: false++ t.index %i[ancestor_id descendant_id generations],+ unique: true,+ name: "item_anc_desc_idx"++ t.index [:descendant_id],+ name: "item_desc_idx"+ end+ end+enddiff --git a/db/migrate/tables/available_project_statuses.rb b/db/migrate/tables/hierarchical_items.rbsimilarity index 78%rename from db/migrate/tables/available_project_statuses.rbrename to db/migrate/tables/hierarchical_items.rbindex 89a0a0da98e..4a173f03932 100644--- a/db/migrate/tables/available_project_statuses.rb+++ b/db/migrate/tables/hierarchical_items.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,17 +26,20 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++require_relative "base"-class Tables::AvailableProjectStatuses < Tables::Base+class Tables::HierarchicalItems < Tables::Basedef self.table(migration)create_table migration do |t|- t.belongs_to :project_type, type: :int- t.belongs_to :reported_project_status, type: :int, index: { name: "index_avail_project_statuses_on_rep_project_status_id" }-- t.timestamps null: true # compatibility to pre 5.1 migrations+ t.integer :parent_id # TODO: turn into bigint+ t.integer :sort_order+ t.string :label+ t.string :short+ t.boolean :is_deleted, default: false, null: false+ t.timestamps+ t.references :custom_field, foreign_key: trueendendenddiff --git a/db/migrate/tables/journals.rb b/db/migrate/tables/journals.rbindex 230d3658120..c81cb188fc9 100644--- a/db/migrate/tables/journals.rb+++ b/db/migrate/tables/journals.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -29,22 +31,35 @@require_relative "base"class Tables::Journals < Tables::Base- def self.table(migration)+ def self.table(migration) # rubocop:disable Metrics/AbcSizecreate_table migration do |t|- t.references :journable, polymorphic: true, index: false, type: :int- t.integer :user_id, default: 0, null: false- t.text :notes- t.datetime :created_at, null: false+ t.references :journable, polymorphic: true, index: false+ t.bigint :user_id, null: false, index: true+ t.text :notes, null: true+ t.datetime :created_at, precision: nil, null: false, index: truet.integer :version, default: 0, null: false- t.string :activity_type+ t.datetime :updated_at, precision: nil, default: -> { "CURRENT_TIMESTAMP" }+ t.references :data, polymorphic: true, index: false, null: false+ t.jsonb :cause, default: {}+ t.tstzrange :validity_periodt.index :journable_id- t.index :created_att.index :journable_type- t.index :user_id- t.index :activity_typet.index %i[journable_type journable_id version],unique: true+ t.index %i[data_id data_type],+ unique: true+ t.index :notes,+ using: "gin",+ opclass: :gin_trgm_ops++ t.check_constraint "NOT isempty(validity_period) AND validity_period IS NOT NULL",+ name: "journals_validity_period_not_empty"++ t.exclusion_constraint "journable_id WITH =, journable_type WITH =, validity_period WITH &&",+ name: "non_overlapping_journals_validity_periods",+ using: :gist,+ deferrable: :immediateendendenddiff --git a/db/migrate/tables/auth_sources.rb b/db/migrate/tables/ldap_auth_sources.rbsimilarity index 82%rename from db/migrate/tables/auth_sources.rbrename to db/migrate/tables/ldap_auth_sources.rbindex 3c02b25b9c5..14921b7085c 100644--- a/db/migrate/tables/auth_sources.rb+++ b/db/migrate/tables/ldap_auth_sources.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -28,10 +30,9 @@require_relative "base"-class Tables::AuthSources < Tables::Base- def self.table(migration)+class Tables::LdapAuthSources < Tables::Base+ def self.table(migration) # rubocop:disable Metrics/AbcSizecreate_table migration do |t|- t.string :type, limit: 30, default: "", null: falset.string :name, limit: 60, default: "", null: falset.string :host, limit: 60t.integer :port@@ -43,10 +44,12 @@ class Tables::AuthSources < Tables::Baset.string :attr_lastname, limit: 30t.string :attr_mail, limit: 30t.boolean :onthefly_register, default: false, null: false- t.boolean :tls, default: false, null: falset.string :attr_admin-- t.index %i[id type], name: "index_auth_sources_on_id_and_type"+ t.timestamps precision: nil+ t.integer :tls_mode, default: 0, null: false+ t.text :filter_string, null: true+ t.boolean :verify_peer, default: true, null: false+ t.text :tls_certificate_stringendendenddiff --git a/db/migrate/tables/member_roles.rb b/db/migrate/tables/member_roles.rbindex 569343a2b27..c290c357de8 100644--- a/db/migrate/tables/member_roles.rb+++ b/db/migrate/tables/member_roles.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -30,14 +32,17 @@ require_relative "base"class Tables::MemberRoles < Tables::Basedef self.table(migration)- create_table migration do |t|- t.integer :member_id, null: false- t.integer :role_id, null: false- t.integer :inherited_from+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestamps+ t.bigint :member_id, null: false+ t.bigint :role_id, null: false+ t.bigint :inherited_fromt.index :member_id, name: "index_member_roles_on_member_id"t.index :role_id, name: "index_member_roles_on_role_id"t.index :inherited_from+ t.index %i[member_id role_id inherited_from],+ name: "unique_inherited_role",+ unique: trueendendenddiff --git a/db/migrate/tables/members.rb b/db/migrate/tables/members.rbindex 47da6e10381..678a49839a3 100644--- a/db/migrate/tables/members.rb+++ b/db/migrate/tables/members.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -31,14 +33,21 @@ require_relative "base"class Tables::Members < Tables::Basedef self.table(migration)create_table migration do |t|- t.integer :user_id, default: 0, null: false- t.integer :project_id, default: 0, null: false- t.datetime :created_on- t.boolean :mail_notification, default: false, null: false+ t.references :user, null: false, index: { name: "index_members_on_user_id" }+ t.references :project, default: nil, null: true, index: { name: "index_members_on_project_id" }+ t.datetime :created_at, precision: nil, default: -> { "CURRENT_TIMESTAMP" }, null: true+ t.datetime :updated_at, precision: nil, default: -> { "CURRENT_TIMESTAMP" }, null: false+ t.references :entity, foreign_key: false, polymorphic: true, index: true++ t.index %i[user_id project_id],+ unique: true,+ where: "entity_type IS NULL AND entity_id IS NULL",+ name: "index_members_on_user_id_and_project_without_entity"- t.index :project_id, name: "index_members_on_project_id"- t.index %i[user_id project_id], name: "index_members_on_user_id_and_project_id", unique: true- t.index :user_id, name: "index_members_on_user_id"+ t.index %i[user_id project_id entity_type entity_id],+ unique: true,+ where: "entity_type IS NOT NULL AND entity_id IS NOT NULL",+ name: "index_members_on_user_id_and_project_with_entity"endendenddiff --git a/db/migrate/tables/menu_items.rb b/db/migrate/tables/menu_items.rbindex 79b19042a84..ad326d28029 100644--- a/db/migrate/tables/menu_items.rb+++ b/db/migrate/tables/menu_items.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -30,12 +32,12 @@ require_relative "base"class Tables::MenuItems < Tables::Basedef self.table(migration)- create_table migration do |t|- t.column :name, :string- t.column :title, :string- t.column :parent_id, :integer- t.column :options, :text- t.belongs_to :navigatable, type: :int, index: false+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestamps+ t.string :name+ t.string :title+ t.bigint :parent_id+ t.text :options+ t.belongs_to :navigatable, index: falset.string :typet.index %i(navigatable_id title)diff --git a/db/migrate/tables/message_journals.rb b/db/migrate/tables/message_journals.rbindex 5e0664f4610..72b2ad155cf 100644--- a/db/migrate/tables/message_journals.rb+++ b/db/migrate/tables/message_journals.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -30,19 +32,14 @@ require_relative "base"class Tables::MessageJournals < Tables::Basedef self.table(migration)- create_table migration do |t|- t.integer :journal_id, null: false- t.integer :board_id, null: false- t.integer :parent_id- t.string :subject, default: "", null: false+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestamps+ t.bigint :forum_id, null: false+ t.bigint :parent_id+ t.string :subject, default: nil, null: falset.text :content- t.integer :author_id- t.integer :replies_count, default: 0, null: false- t.integer :last_reply_id- t.boolean :locked, default: false- t.integer :sticky, default: 0-- t.index [:journal_id]+ t.bigint :author_id+ t.boolean :locked, default: nil # rubocop:disable Rails/ThreeStateBooleanColumn+ t.integer :sticky, default: nilendendenddiff --git a/db/migrate/tables/messages.rb b/db/migrate/tables/messages.rbindex aeb5572db23..cd13720e121 100644--- a/db/migrate/tables/messages.rb+++ b/db/migrate/tables/messages.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -32,25 +34,24 @@ class Tables::Messages < Tables::Base# rubocop:disable Metrics/AbcSizedef self.table(migration)create_table migration do |t|- t.integer :board_id, null: false- t.integer :parent_id+ t.bigint :forum_id, null: false+ t.bigint :parent_idt.string :subject, default: "", null: falset.text :content- t.integer :author_id+ t.bigint :author_idt.integer :replies_count, default: 0, null: false- t.integer :last_reply_id- t.datetime :created_on, null: false- t.datetime :updated_on, null: false+ t.bigint :last_reply_id+ t.timestamps precision: nil, default: -> { "CURRENT_TIMESTAMP" }t.boolean :locked, default: falset.integer :sticky, default: 0- t.datetime :sticked_on, default: nil, null: true+ t.datetime :sticked_on, precision: false, default: nil, null: truet.index :author_id, name: "index_messages_on_author_id"- t.index :board_id, name: "messages_board_id"- t.index :created_on, name: "index_messages_on_created_on"+ t.index :forum_id, name: "messages_board_id" # Name kept for compatibility+ t.index :created_at, name: "index_messages_on_created_at"t.index :last_reply_id, name: "index_messages_on_last_reply_id"t.index :parent_id, name: "messages_parent_id"- t.index %i[board_id updated_on]+ t.index %i[forum_id updated_at]endend# rubocop:enable Metrics/AbcSizediff --git a/db/migrate/tables/news.rb b/db/migrate/tables/news.rbindex 19a4e439cd6..02afff17b5c 100644--- a/db/migrate/tables/news.rb+++ b/db/migrate/tables/news.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -31,18 +33,19 @@ require_relative "base"class Tables::News < Tables::Basedef self.table(migration)create_table migration do |t|- t.integer :project_id- t.string :title, limit: 60, default: "", null: false+ t.bigint :project_id+ t.string :title, default: "", null: falset.string :summary, default: ""t.text :description- t.integer :author_id, default: 0, null: false- t.datetime :created_on+ t.bigint :author_id, null: false+ t.datetime :created_at, precision: nilt.integer :comments_count, default: 0, null: false+ t.datetime :updated_at, precision: nilt.index :author_id, name: "index_news_on_author_id"- t.index :created_on, name: "index_news_on_created_on"+ t.index :created_at, name: "index_news_on_created_at"t.index :project_id, name: "news_project_id"- t.index %i[project_id created_on]+ t.index %i[project_id created_at]endendenddiff --git a/db/migrate/tables/news_journals.rb b/db/migrate/tables/news_journals.rbindex 742ca9f26cd..4199579e9d2 100644--- a/db/migrate/tables/news_journals.rb+++ b/db/migrate/tables/news_journals.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -30,16 +32,13 @@ require_relative "base"class Tables::NewsJournals < Tables::Basedef self.table(migration)- create_table migration do |t|- t.integer :journal_id, null: false- t.integer :project_id- t.string :title, limit: 60, default: "", null: false- t.string :summary, default: ""+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestamps+ t.references :project, index: true+ t.string :title, limit: nil, default: nil, null: false+ t.string :summary, default: nilt.text :description- t.integer :author_id, default: 0, null: false- t.integer :comments_count, default: 0, null: false-- t.index [:journal_id]+ t.references :author, null: false, index: false+ t.integer :comments_count, default: nil, null: falseendendenddiff --git a/db/migrate/tables/non_working_days.rb b/db/migrate/tables/non_working_days.rbnew file mode 100644index 00000000000..6395f56d5bc--- /dev/null+++ b/db/migrate/tables/non_working_days.rb@@ -0,0 +1,44 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require_relative "base"++class Tables::NonWorkingDays < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.string :name, null: false+ t.date :date, null: false++ t.timestamps precision: nil+ t.index :date,+ unique: true+ end+ end+enddiff --git a/db/migrate/tables/notification_settings.rb b/db/migrate/tables/notification_settings.rbnew file mode 100644index 00000000000..3200e09efa9--- /dev/null+++ b/db/migrate/tables/notification_settings.rb@@ -0,0 +1,78 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require_relative "base"++class Tables::NotificationSettings < Tables::Base+ def self.table(migration) # rubocop:disable Metrics/AbcSize+ create_table migration do |t|+ t.belongs_to :project, null: true, index: true, foreign_key: true+ t.belongs_to :user, null: false, index: true, foreign_key: true+ t.boolean :watched, default: true # rubocop:disable Rails/ThreeStateBooleanColumn+ t.boolean :mentioned, default: true # rubocop:disable Rails/ThreeStateBooleanColumn++ t.timestamps precision: nil, default: -> { "CURRENT_TIMESTAMP" }++ # Adding indices here is probably useful as most of those are expected to be false+ # and we are searching for those that are true.+ # The columns watched, involved and mentioned will probably be true most of the time+ # so having an index there should not improve speed.+ t.boolean :work_package_commented, default: false, index: true # rubocop:disable Rails/ThreeStateBooleanColumn+ t.boolean :work_package_created, default: false, index: true # rubocop:disable Rails/ThreeStateBooleanColumn+ t.boolean :work_package_processed, default: false, index: true # rubocop:disable Rails/ThreeStateBooleanColumn+ t.boolean :work_package_prioritized, default: false, index: true # rubocop:disable Rails/ThreeStateBooleanColumn+ t.boolean :work_package_scheduled, default: false, index: true # rubocop:disable Rails/ThreeStateBooleanColumn+ t.boolean :news_added, default: false, index: true # rubocop:disable Rails/ThreeStateBooleanColumn+ t.boolean :news_commented, default: false, index: true # rubocop:disable Rails/ThreeStateBooleanColumn+ t.boolean :document_added, default: false, index: true # rubocop:disable Rails/ThreeStateBooleanColumn+ t.boolean :forum_messages, default: false, index: true # rubocop:disable Rails/ThreeStateBooleanColumn+ t.boolean :wiki_page_added, default: false, index: true # rubocop:disable Rails/ThreeStateBooleanColumn+ t.boolean :wiki_page_updated, default: false, index: true # rubocop:disable Rails/ThreeStateBooleanColumn+ t.boolean :membership_added, default: false, index: true # rubocop:disable Rails/ThreeStateBooleanColumn+ t.boolean :membership_updated, default: false, index: true # rubocop:disable Rails/ThreeStateBooleanColumn+ t.integer :start_date, default: 1+ t.integer :due_date, default: 1+ t.integer :overdue, default: nil+ t.boolean :assignee, default: true, null: false+ t.boolean :responsible, default: true, null: false+ t.boolean :shared, default: true, null: false++ t.index %i[user_id],+ unique: true,+ where: "project_id IS NULL",+ name: "index_notification_settings_unique_project_null"++ t.index %i[user_id project_id],+ unique: true,+ where: "project_id IS NOT NULL",+ name: "index_notification_settings_unique_project"+ end+ end+enddiff --git a/db/migrate/20210616191052_create_notifications.rb b/db/migrate/tables/notifications.rbsimilarity index 71%rename from db/migrate/20210616191052_create_notifications.rbrename to db/migrate/tables/notifications.rbindex fe3e018f686..29970f458b1 100644--- a/db/migrate/20210616191052_create_notifications.rb+++ b/db/migrate/tables/notifications.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,24 +26,27 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++++require_relative "base"-class CreateNotifications < ActiveRecord::Migration[6.1]- def change- create_table :notifications do |t|+class Tables::Notifications < Tables::Base+ def self.table(migration)+ create_table migration do |t|t.text :subject- t.boolean :read_ian, default: false, index: true- t.boolean :read_email, default: false, index: true+ t.boolean :read_ian, default: false, index: true # rubocop:disable Rails/ThreeStateBooleanColumnt.integer :reason, limit: 1t.references :recipient, null: false, index: true, foreign_key: { to_table: :users }t.references :actor, null: true, foreign_key: { to_table: :users }t.references :resource, polymorphic: true, null: false- t.references :project- t.references :journal, index: false+ t.references :journal, foreign_key: { on_delete: :cascade }++ t.timestamps precision: nil- t.timestamps+ t.boolean :mail_reminder_sent, default: false, index: true # rubocop:disable Rails/ThreeStateBooleanColumn+ t.boolean :mail_alert_sent, default: nil, index: true # rubocop:disable Rails/ThreeStateBooleanColumnendendenddiff --git a/db/migrate/tables/oauth_access_grants.rb b/db/migrate/tables/oauth_access_grants.rbnew file mode 100644index 00000000000..0be7f0d33e3--- /dev/null+++ b/db/migrate/tables/oauth_access_grants.rb@@ -0,0 +1,52 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require_relative "base"++class Tables::OAuthAccessGrants < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.references :resource_owner, null: false+ t.references :application, null: false+ t.string :token, null: false+ t.integer :expires_in, null: false+ t.text :redirect_uri, null: false+ t.datetime :created_at, precision: nil, null: false+ t.datetime :revoked_at, precision: nil+ t.string :scopes+ t.foreign_key :oauth_applications, column: :application_id+ # Add PKCE challenges column+ t.string :code_challenge, null: true+ t.string :code_challenge_method, null: true++ t.index :token, unique: true+ end+ end+enddiff --git a/db/migrate/20181112125034_create_doorkeeper_tables.rb b/db/migrate/tables/oauth_access_tokens.rbsimilarity index 51%rename from db/migrate/20181112125034_create_doorkeeper_tables.rbrename to db/migrate/tables/oauth_access_tokens.rbindex 18fc7d1e7ca..e1e63dc365a 100644--- a/db/migrate/20181112125034_create_doorkeeper_tables.rb+++ b/db/migrate/tables/oauth_access_tokens.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,51 +26,13 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#++--class CreateDoorkeeperTables < ActiveRecord::Migration[5.1]- def change- create_table :oauth_applications do |t|- t.string :name, null: false- t.string :uid, null: false- t.string :secret, null: false- t.string :owner_type- t.integer :owner_id- t.integer :client_credentials_user_id- t.text :redirect_uri, null: false- t.string :scopes, null: false, default: ""- t.boolean :confidential, null: false, default: true- t.timestamps null: false- end+# ++- # Add owner of an application- add_foreign_key :oauth_applications, :users, column: :owner_id, on_delete: :nullify+require_relative "base"- # Allow to map a user to use for client credentials auth flow- add_foreign_key :oauth_applications, :users, column: :client_credentials_user_id, on_delete: :nullify-- add_index :oauth_applications, :uid, unique: true- add_index :oauth_applications, %i[owner_id owner_type]-- create_table :oauth_access_grants do |t|- t.references :resource_owner, null: false- t.references :application, null: false- t.string :token, null: false- t.integer :expires_in, null: false- t.text :redirect_uri, null: false- t.datetime :created_at, null: false- t.datetime :revoked_at- t.string :scopes- end-- add_index :oauth_access_grants, :token, unique: true- add_foreign_key(- :oauth_access_grants,- :oauth_applications,- column: :application_id- )-- create_table :oauth_access_tokens do |t|+class Tables::OAuthAccessTokens < Tables::Base+ def self.table(migration)+ create_table migration do |t|t.references :resource_owner, index: truet.references :application@@ -82,8 +46,8 @@ class CreateDoorkeeperTables < ActiveRecord::Migration[5.1]t.string :refresh_tokent.integer :expires_in- t.datetime :revoked_at- t.datetime :created_at, null: false+ t.datetime :revoked_at, precision: nil+ t.datetime :created_at, precision: nil, null: falset.string :scopes# If there is a previous_refresh_token column,@@ -93,18 +57,11 @@ class CreateDoorkeeperTables < ActiveRecord::Migration[5.1]# Comment out this line if you'd rather have refresh tokens# instantly revoked.t.string :previous_refresh_token, null: false, default: ""- end- add_index :oauth_access_tokens, :token, unique: true- add_index :oauth_access_tokens, :refresh_token, unique: true- add_foreign_key(- :oauth_access_tokens,- :oauth_applications,- column: :application_id- )+ t.foreign_key :oauth_applications, column: :application_id- # Add PKCE challenges column- add_column :oauth_access_grants, :code_challenge, :string, null: true- add_column :oauth_access_grants, :code_challenge_method, :string, null: true+ t.index :token, unique: true+ t.index :refresh_token, unique: true+ endendenddiff --git a/db/migrate/tables/oauth_applications.rb b/db/migrate/tables/oauth_applications.rbnew file mode 100644index 00000000000..c91f86d9f5e--- /dev/null+++ b/db/migrate/tables/oauth_applications.rb@@ -0,0 +1,58 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require_relative "base"++class Tables::OAuthApplications < Tables::Base+ def self.table(migration) # rubocop:disable Metrics/AbcSize+ create_table migration do |t|+ t.string :name, null: false+ t.string :uid, null: false+ t.string :secret, null: false+ t.string :owner_type+ t.bigint :owner_id+ t.bigint :client_credentials_user_id+ t.text :redirect_uri, null: false+ t.string :scopes, null: false, default: ""+ t.boolean :confidential, null: false, default: true+ t.timestamps precision: nil, null: false+ # Add owner of an application+ t.foreign_key :users, column: :owner_id, on_delete: :nullify+ # Allow to map a user to use for client credentials auth flow+ t.foreign_key :users, column: :client_credentials_user_id, on_delete: :nullify+ t.references :integration, polymorphic: true+ t.column :enabled, :boolean, default: true, null: false+ t.column :builtin, :boolean, default: false, null: false++ t.index :uid, unique: true+ t.index %i[owner_id owner_type]+ end+ end+enddiff --git a/db/migrate/20220518154147_create_oauth_client_tokens.rb b/db/migrate/tables/oauth_client_tokens.rbsimilarity index 85%rename from db/migrate/20220518154147_create_oauth_client_tokens.rbrename to db/migrate/tables/oauth_client_tokens.rbindex 54dcbcf678c..b6b4b323312 100644--- a/db/migrate/20220518154147_create_oauth_client_tokens.rb+++ b/db/migrate/tables/oauth_client_tokens.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,22 +26,23 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++++require_relative "base"-class CreateOAuthClientTokens < ActiveRecord::Migration[6.1]- def change- create_table :oauth_client_tokens do |t|+class Tables::OAuthClientTokens < Tables::Base+ def self.table(migration)+ create_table migration do |t|t.references :oauth_client, null: false, foreign_key: { to_table: :oauth_clients, on_delete: :cascade }t.references :user, null: false, index: true, foreign_key: { to_table: :users, on_delete: :cascade }-t.string :access_tokent.string :refresh_tokent.string :token_typet.integer :expires_int.string :scope- t.string :origin_user_id # ID of the current user on the _OAuth2_provider_side_+ t.timestamps precision: nil+ t.integer :lock_version, default: 0, null: false- t.timestampst.index %i[user_id oauth_client_id], unique: trueendenddiff --git a/db/migrate/tables/project_types.rb b/db/migrate/tables/oauth_clients.rbsimilarity index 81%rename from db/migrate/tables/project_types.rbrename to db/migrate/tables/oauth_clients.rbindex aaea45f4cad..b29c190e699 100644--- a/db/migrate/tables/project_types.rb+++ b/db/migrate/tables/oauth_clients.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,18 +26,17 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++require_relative "base"-class Tables::ProjectTypes < Tables::Base+class Tables::OAuthClients < Tables::Basedef self.table(migration)create_table migration do |t|- t.column :name, :string, default: "", null: false- t.column :allows_association, :boolean, default: true, null: false- t.column :position, :integer, default: 1, null: true-- t.timestamps null: true+ t.string :client_id, null: false+ t.string :client_secret, null: true+ t.references :integration, polymorphic: true, index: { unique: true }, null: false+ t.timestamps precision: nilendendenddiff --git a/db/migrate/tables/ordered_work_packages.rb b/db/migrate/tables/ordered_work_packages.rbnew file mode 100644index 00000000000..52c6bcfcc38--- /dev/null+++ b/db/migrate/tables/ordered_work_packages.rb@@ -0,0 +1,42 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require_relative "base"++class Tables::OrderedWorkPackages < Tables::Base+ def self.table(migration)+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestamps+ t.integer :position, index: true, null: false++ t.references :query, foreign_key: { index: true, on_delete: :cascade }+ t.references :work_package, foreign_key: { index: true, on_delete: :cascade }+ end+ end+enddiff --git a/db/migrate/20220629061540_add_paper_trail.rb b/db/migrate/tables/paper_trail_audits.rbsimilarity index 86%rename from db/migrate/20220629061540_add_paper_trail.rbrename to db/migrate/tables/paper_trail_audits.rbindex 2ecdd6e9a92..9f5e9296d32 100644--- a/db/migrate/20220629061540_add_paper_trail.rb+++ b/db/migrate/tables/paper_trail_audits.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,11 +26,13 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++++require_relative "base"-class AddPaperTrail < ActiveRecord::Migration[7.0]- def change- create_table :paper_trail_audits do |t|+class Tables::PaperTrailAudits < Tables::Base+ def self.table(migration)+ create_table migration do |t|t.string :item_type, null: falset.bigint :item_id, null: falset.string :event, null: false@@ -36,9 +40,9 @@ class AddPaperTrail < ActiveRecord::Migration[7.0]t.text :stackt.jsonb :objectt.jsonb :object_changes-t.datetime :created_at++ t.index %i(item_type item_id)end- add_index :paper_trail_audits, %i(item_type item_id)endenddiff --git a/db/migrate/tables/project_custom_field_project_mappings.rb b/db/migrate/tables/project_custom_field_project_mappings.rbnew file mode 100644index 00000000000..322c90048a9--- /dev/null+++ b/db/migrate/tables/project_custom_field_project_mappings.rb@@ -0,0 +1,48 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require_relative "base"++class Tables::ProjectCustomFieldProjectMappings < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.references :custom_field, foreign_key: true, index: {+ name: "index_project_cf_project_mappings_on_custom_field_id"+ }+ t.references :project, foreign_key: true++ t.timestamps++ t.index %i[project_id custom_field_id],+ unique: true,+ name: "index_project_custom_field_project_mappings_unique"+ end+ end+enddiff --git a/db/migrate/20221130150352_create_project_journals.rb b/db/migrate/tables/project_journals.rbsimilarity index 83%rename from db/migrate/20221130150352_create_project_journals.rbrename to db/migrate/tables/project_journals.rbindex da63a158ce4..ad3c8fc9d9c 100644--- a/db/migrate/20221130150352_create_project_journals.rb+++ b/db/migrate/tables/project_journals.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,12 +26,13 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++++require_relative "base"-class CreateProjectJournals < ActiveRecord::Migration[7.0]- # rubocop:disable Rails/CreateTableWithTimestamps(RuboCop)- def change- create_table :project_journals do |t|+class Tables::ProjectJournals < Tables::Base+ def self.table(migration)+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestampst.string :name, null: falset.text :descriptiont.boolean :public, null: false@@ -37,7 +40,8 @@ class CreateProjectJournals < ActiveRecord::Migration[7.0]t.string :identifier, null: falset.boolean :active, null: falset.boolean :templated, null: false+ t.integer :status_code+ t.text :status_explanationendend- # rubocop:enable Rails/CreateTableWithTimestamps(RuboCop)enddiff --git a/db/migrate/tables/project_queries.rb b/db/migrate/tables/project_queries.rbnew file mode 100644index 00000000000..85f6f241be8--- /dev/null+++ b/db/migrate/tables/project_queries.rb@@ -0,0 +1,45 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require_relative "base"++class Tables::ProjectQueries < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.string :name, null: false+ t.references :user, null: false+ t.json :filters, default: []+ t.json :selects, default: []+ t.json :orders, default: []+ t.timestamps+ t.boolean :public, default: false, null: false, index: true+ end+ end+enddiff --git a/db/migrate/tables/projects.rb b/db/migrate/tables/projects.rbindex cd2da0bfe79..2b95ea20d0b 100644--- a/db/migrate/tables/projects.rb+++ b/db/migrate/tables/projects.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -29,27 +31,26 @@require_relative "base"class Tables::Projects < Tables::Base- # rubocop:disable Metrics/AbcSize- def self.table(migration)+ def self.table(migration) # rubocop:disable Metrics/AbcSizecreate_table migration do |t|t.string :name, default: "", null: falset.text :description- t.boolean :is_public, default: true, null: false- t.integer :parent_id- t.datetime :created_on- t.datetime :updated_on- t.string :identifier- t.integer :status, default: 1, null: false+ t.boolean :public, default: true, null: false+ t.bigint :parent_id+ t.timestamps precision: nil, null: true+ t.string :identifier, null: falset.integer :lftt.integer :rgt- t.belongs_to :project_type, type: :int- t.belongs_to :responsible, type: :int- t.belongs_to :work_packages_responsible, type: :int+ t.boolean :active, default: true, null: false, index: true+ t.boolean :templated, default: false, null: false+ t.integer :status_code+ t.text :status_explanation+ t.jsonb :settings, null: false, default: {}t.index :lft, name: "index_projects_on_lft"t.index :rgt, name: "index_projects_on_rgt"- t.index :identifier+ t.index :identifier, unique: true+ t.index %i[lft rgt]endend- # rubocop:enable Metrics/AbcSizeenddiff --git a/db/migrate/tables/projects_types.rb b/db/migrate/tables/projects_types.rbindex d2fde3c72de..dfa327f97b8 100644--- a/db/migrate/tables/projects_types.rb+++ b/db/migrate/tables/projects_types.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -29,17 +31,14 @@require_relative "base"class Tables::ProjectsTypes < Tables::Base- def self.id_options- { id: false }- end-def self.table(migration)- create_table migration do |t|- t.integer :project_id, default: 0, null: false- t.integer :type_id, default: 0, null: false+ create_table migration, id: false do |t|+ t.references :project,+ null: false,+ index: { name: "projects_types_project_id" },+ foreign_key: { on_delete: :cascade, on_update: :cascade }+ t.references :type, null: false, index: false, foreign_key: { on_delete: :cascade, on_update: :cascade }- t.index :project_id,- name: :projects_types_project_idt.index %i[project_id type_id],name: :projects_types_unique, unique: trueenddiff --git a/db/migrate/tables/queries.rb b/db/migrate/tables/queries.rbindex 2fe691685d2..f7e91e250ed 100644--- a/db/migrate/tables/queries.rb+++ b/db/migrate/tables/queries.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -29,23 +31,32 @@require_relative "base"class Tables::Queries < Tables::Base- def self.table(migration)+ def self.table(migration) # rubocop:disable Metrics/AbcSizecreate_table migration do |t|- t.integer :project_id- t.string :name, default: "", null: false+ t.bigint :project_id+ t.string :name, null: falset.text :filters- t.integer :user_id, default: 0, null: false- t.boolean :is_public, default: false, null: false+ t.bigint :user_id, null: false+ t.boolean :public, default: false, null: falset.text :column_namest.text :sort_criteriat.string :group_byt.boolean :display_sums, default: false, null: false- t.boolean :timeline_visible, default: false- t.boolean :show_hierarchies, default: false- t.integer :timeline_zoom_level, default: 0+ t.boolean :timeline_visible, default: false # rubocop:disable Rails/ThreeStateBooleanColumn+ t.boolean :show_hierarchies, default: false # rubocop:disable Rails/ThreeStateBooleanColumn+ t.integer :timeline_zoom_level, default: 5+ t.text :timeline_labels+ t.text :highlighting_mode+ t.text :highlighted_attributes+ t.timestamps precision: nil, null: true+ t.text :display_representation+ t.boolean :starred, default: false # rubocop:disable Rails/ThreeStateBooleanColumn+ t.boolean :include_subprojects, null: false, default: nil+ t.string :timestampst.index :project_id, name: "index_queries_on_project_id"t.index :user_id, name: "index_queries_on_user_id"+ t.index :updated_atendendenddiff --git a/db/migrate/tables/relations.rb b/db/migrate/tables/relations.rbindex d129d8d9f1b..d3f5d1334bb 100644--- a/db/migrate/tables/relations.rb+++ b/db/migrate/tables/relations.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -30,15 +32,19 @@ require_relative "base"class Tables::Relations < Tables::Basedef self.table(migration)- create_table migration do |t|- t.integer :from_id, null: false- t.integer :to_id, null: false- t.string :relation_type, default: "", null: false- t.integer :delay+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestamps+ t.integer :from_id, null: false # TODO: turn into bigint, foreign key+ t.integer :to_id, null: false # TODO: turn into bigint, foreign key+ t.integer :lagt.text :description+ t.string :relation_typet.index :from_id, name: "index_relations_on_from_id"t.index :to_id, name: "index_relations_on_to_id"+ t.index %i[from_id to_id relation_type],+ unique: true+ t.index %i[to_id from_id relation_type],+ unique: trueendendenddiff --git a/db/migrate/20240806144333_create_remote_identities.rb b/db/migrate/tables/remote_identities.rbsimilarity index 91%rename from db/migrate/20240806144333_create_remote_identities.rbrename to db/migrate/tables/remote_identities.rbindex c6829fdad92..2bc6d271139 100644--- a/db/migrate/20240806144333_create_remote_identities.rb+++ b/db/migrate/tables/remote_identities.rb@@ -1,6 +1,6 @@# frozen_string_literal: true-#-- copyright+# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -26,11 +26,13 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++-class CreateRemoteIdentities < ActiveRecord::Migration[7.1]- def change- create_table :remote_identities do |t|+require_relative "base"++class Tables::RemoteIdentities < Tables::Base+ def self.table(migration)+ create_table migration do |t|t.references :user, index: true, null: false, foreign_key: { to_table: :users, on_delete: :cascade }t.references :oauth_client, index: true, null: false, foreign_key: { to_table: :oauth_clients, on_delete: :cascade }diff --git a/db/migrate/tables/repositories.rb b/db/migrate/tables/repositories.rbindex aec51647879..8c9d78f0e08 100644--- a/db/migrate/tables/repositories.rb+++ b/db/migrate/tables/repositories.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -30,8 +32,8 @@ require_relative "base"class Tables::Repositories < Tables::Basedef self.table(migration)- create_table migration do |t|- t.integer :project_id, default: 0, null: false+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestamps+ t.bigint :project_id, null: falset.string :url, default: "", null: falset.string :login, limit: 60, default: ""t.string :password, default: ""@@ -41,7 +43,7 @@ class Tables::Repositories < Tables::Baset.string :log_encoding, limit: 64t.string :scm_type, null: falset.integer :required_storage_bytes, limit: 8, null: false, default: 0- t.datetime :storage_updated_at+ t.datetime :storage_updated_at, precision: nilt.index :project_id, name: "index_repositories_on_project_id"enddiff --git a/db/migrate/tables/role_permissions.rb b/db/migrate/tables/role_permissions.rbindex 9bafd8838f2..106db919576 100644--- a/db/migrate/tables/role_permissions.rb+++ b/db/migrate/tables/role_permissions.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -32,11 +34,11 @@ class Tables::RolePermissions < Tables::Basedef self.table(migration)create_table migration do |t|t.string :permission- t.integer :role_id+ t.bigint :role_idt.index :role_id- t.timestamps+ t.timestamps precision: nilendendenddiff --git a/db/migrate/tables/roles.rb b/db/migrate/tables/roles.rbindex e651997fc48..253671565c9 100644--- a/db/migrate/tables/roles.rb+++ b/db/migrate/tables/roles.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -31,10 +33,12 @@ require_relative "base"class Tables::Roles < Tables::Basedef self.table(migration)create_table migration do |t|- t.string :name, limit: 30, default: "", null: false+ t.string :name, default: "", null: falset.integer :position, default: 1- t.boolean :assignable, default: truet.integer :builtin, default: 0, null: false+ t.string :type, limit: 30, default: "Role"++ t.timestamps precision: nil, default: -> { "CURRENT_TIMESTAMP" }, null: trueendendenddiff --git a/db/migrate/tables/sessions.rb b/db/migrate/tables/sessions.rbindex f44163ac184..db9bf35792d 100644--- a/db/migrate/tables/sessions.rb+++ b/db/migrate/tables/sessions.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -30,11 +32,11 @@ require_relative "base"class Tables::Sessions < Tables::Basedef self.table(migration)- create_table migration do |t|+ create_unlogged_table migration do |t|t.string :session_id, null: falset.text :data- t.timestamps null: true- t.belongs_to :user, type: :int, index: false+ t.datetime :updated_at, precision: nil, null: true+ t.belongs_to :user, index: falset.index :session_idt.index :updated_atdiff --git a/db/migrate/tables/settings.rb b/db/migrate/tables/settings.rbindex 7aed2446e76..6bf4a0053b7 100644--- a/db/migrate/tables/settings.rb+++ b/db/migrate/tables/settings.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -33,7 +35,7 @@ class Tables::Settings < Tables::Basecreate_table migration do |t|t.string :name, default: "", null: falset.text :value- t.datetime :updated_on+ t.datetime :updated_at, precision: nil, default: -> { "CURRENT_TIMESTAMP" }t.index :name, name: "index_settings_on_name"enddiff --git a/db/migrate/tables/statuses.rb b/db/migrate/tables/statuses.rbindex 9ef01e72639..de0848098f5 100644--- a/db/migrate/tables/statuses.rb+++ b/db/migrate/tables/statuses.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -31,11 +33,15 @@ require_relative "base"class Tables::Statuses < Tables::Basedef self.table(migration)create_table migration do |t|- t.string :name, limit: 30, default: "", null: false+ t.string :name, default: "", null: falset.boolean :is_closed, default: false, null: falset.boolean :is_default, default: false, null: falset.integer :position, default: 1- t.integer :default_done_ratio+ t.integer :default_done_ratio, default: 0, null: false+ t.timestamps precision: nil+ t.belongs_to :color+ t.boolean :is_readonly, default: false # rubocop:disable Rails/ThreeStateBooleanColumn+ t.boolean :excluded_from_totals, default: false, null: falset.index :is_closed, name: "index_statuses_on_is_closed"t.index :is_default, name: "index_statuses_on_is_default"diff --git a/db/migrate/tables/tokens.rb b/db/migrate/tables/tokens.rbindex 92f2a683069..aa721235af5 100644--- a/db/migrate/tables/tokens.rb+++ b/db/migrate/tables/tokens.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -31,12 +33,12 @@ require_relative "base"class Tables::Tokens < Tables::Basedef self.table(migration)create_table migration do |t|- t.integer :user_id, default: 0, null: false- t.string :action, limit: 30, default: "", null: false- t.string :value, limit: 40, default: "", null: false- t.datetime :created_on, null: false-- t.index :user_id, name: "index_tokens_on_user_id"+ t.references :user, index: true, foreign_key: true+ t.string :type+ t.string :value, default: "", null: false, limit: 128+ t.datetime :created_at, precision: nil, null: false, default: -> { "CURRENT_TIMESTAMP" }+ t.datetime :expires_on, precision: nil, null: true+ t.json :data, null: trueendendenddiff --git a/db/migrate/tables/types.rb b/db/migrate/tables/types.rbindex b881297bd2d..c0d1625b913 100644--- a/db/migrate/tables/types.rb+++ b/db/migrate/tables/types.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -34,15 +36,13 @@ class Tables::Types < Tables::Baset.string :name, default: "", null: falset.integer :position, default: 1t.boolean :is_in_roadmap, default: true, null: false- t.boolean :in_aggregation, default: true, null: falset.boolean :is_milestone, default: false, null: falset.boolean :is_default, default: false, null: false- t.belongs_to :color, type: :int, index: { name: :index_types_on_color_id }- t.datetime :created_at, null: false- t.datetime :updated_at, null: false+ t.belongs_to :color, index: { name: :index_types_on_color_id }, foreign_key: { on_delete: :nullify }+ t.timestamps precision: nil, null: falset.boolean :is_standard, default: false, null: false- t.text :attribute_visibility, hash: truet.text :attribute_groups+ t.text :descriptionendendenddiff --git a/db/migrate/tables/user_passwords.rb b/db/migrate/tables/user_passwords.rbindex 59b8a1bbcec..b94f2c409cf 100644--- a/db/migrate/tables/user_passwords.rb+++ b/db/migrate/tables/user_passwords.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -31,10 +33,10 @@ require_relative "base"class Tables::UserPasswords < Tables::Basedef self.table(migration)create_table migration do |t|- t.integer :user_id, null: false+ t.bigint :user_id, null: falset.string :hashed_password, limit: 128, null: falset.string :salt, limit: 64, null: true- t.timestamps null: true+ t.timestamps precision: nil, null: truet.string :type, null: falset.index :user_iddiff --git a/db/migrate/tables/user_preferences.rb b/db/migrate/tables/user_preferences.rbindex 85352fbff22..1b9b7880a05 100644--- a/db/migrate/tables/user_preferences.rb+++ b/db/migrate/tables/user_preferences.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -31,13 +33,26 @@ require_relative "base"class Tables::UserPreferences < Tables::Basedef self.table(migration)create_table migration do |t|- t.integer :user_id, default: 0, null: false- t.text :others- t.boolean :hide_mail, default: true- t.string :time_zone- t.boolean :impaired, default: false+ t.bigint :user_id, null: false+ t.jsonb :settings, default: {}+ t.timestamps default: DateTime.now- t.index :user_id, name: "index_user_preferences_on_user_id"+ t.index :user_id,+ name: "index_user_preferences_on_user_id"+ t.index "(settings->'daily_reminders'->'enabled')",+ using: :gin,+ name: "index_user_prefs_settings_daily_reminders_enabled"+ t.index "(settings->'daily_reminders'->'times')",+ using: :gin,+ name: "index_user_prefs_settings_daily_reminders_times"+ t.index "(settings->'time_zone')",+ using: :gin,+ name: "index_user_prefs_settings_time_zone"+ t.index "(settings->'workdays')",+ using: :gin,+ name: "index_user_prefs_settings_workdays"+ t.index "((user_preferences.settings->'pause_reminders'->>'enabled')::boolean)",+ name: "index_user_prefs_settings_pause_reminders_enabled"endendenddiff --git a/db/migrate/tables/users.rb b/db/migrate/tables/users.rbindex a6812e3aa14..87f4cdb4825 100644--- a/db/migrate/tables/users.rb+++ b/db/migrate/tables/users.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -33,29 +35,31 @@ class Tables::Users < Tables::Basedef self.table(migration)create_table migration do |t|t.string :login, limit: 256, default: "", null: false- t.string :firstname, limit: 30, default: "", null: false- t.string :lastname, limit: 30, default: "", null: false- t.string :mail, limit: 60, default: "", null: false+ t.string :firstname, default: "", null: false+ t.string :lastname, default: "", null: false+ t.string :mail, default: "", null: falset.boolean :admin, default: false, null: falset.integer :status, default: 1, null: false- t.datetime :last_login_on+ t.datetime :last_login_on, precision: nilt.string :language, limit: 5, default: ""- t.integer :auth_source_id- t.datetime :created_on- t.datetime :updated_on+ t.references :ldap_auth_source, index: true+ t.timestamps precision: nil, default: -> { "CURRENT_TIMESTAMP" }, null: truet.string :typet.string :identity_url- t.string :mail_notification, default: "", null: falset.boolean :first_login, null: false, default: truet.boolean :force_password_change, default: falset.integer :failed_login_count, default: 0- t.datetime :last_failed_login_on, null: true+ t.datetime :last_failed_login_on, precision: nil, null: true+ t.datetime :consented_at, precision: nil- t.index %i[auth_source_id], name: "index_users_on_auth_source_id"t.index %i[id type], name: "index_users_on_id_and_type"t.index %i[type], name: "index_users_on_type"t.index %i[type login], length: { type: 255, login: 255 }t.index %i[type status]+ t.index %i[lastname type],+ name: "unique_lastname_for_groups_and_placeholder_users",+ unique: true,+ where: "(type = 'Group' OR type = 'PlaceholderUser')"endend# rubocop:enable Metrics/AbcSizediff --git a/db/migrate/tables/versions.rb b/db/migrate/tables/versions.rbindex 1bc27770fe5..63459c27bb0 100644--- a/db/migrate/tables/versions.rb+++ b/db/migrate/tables/versions.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -31,12 +33,11 @@ require_relative "base"class Tables::Versions < Tables::Basedef self.table(migration)create_table migration do |t|- t.integer :project_id, default: 0, null: false- t.string :name, default: "", null: false+ t.bigint :project_id, null: false+ t.string :name, default: "", null: false, collation: "versions_name"t.string :description, default: ""t.date :effective_date- t.datetime :created_on- t.datetime :updated_on+ t.timestamps precision: nil, default: -> { "CURRENT_TIMESTAMP" }, null: truet.string :wiki_page_titlet.string :status, default: :opent.string :sharing, default: :none, null: falsediff --git a/db/migrate/20211130161501_add_views.rb b/db/migrate/tables/views.rbsimilarity index 86%rename from db/migrate/20211130161501_add_views.rbrename to db/migrate/tables/views.rbindex 20fbac7a356..565283ab605 100644--- a/db/migrate/20211130161501_add_views.rb+++ b/db/migrate/tables/views.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,16 +26,18 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++++require_relative "base"-class AddViews < ActiveRecord::Migration[6.1]- def change- create_table :views do |t|+class Tables::Views < Tables::Base+ def self.table(migration)+ create_table migration do |t|t.references :query, null: false, foreign_key: true, index: { unique: true }t.jsonb :options, default: {}, null: falset.string :type, null: false- t.timestamps+ t.timestamps precision: nilendendenddiff --git a/db/migrate/tables/watchers.rb b/db/migrate/tables/watchers.rbindex beae5c02a35..e3c58587aa5 100644--- a/db/migrate/tables/watchers.rb+++ b/db/migrate/tables/watchers.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -30,10 +32,10 @@ require_relative "base"class Tables::Watchers < Tables::Basedef self.table(migration)- create_table migration do |t|+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestampst.string :watchable_type, default: "", null: false- t.integer :watchable_id, default: 0, null: false- t.integer :user_id+ t.bigint :watchable_id, null: false+ t.bigint :user_idt.index %i(user_id watchable_type), name: "watchers_user_id_type"t.index :user_id, name: "index_watchers_on_user_id"diff --git a/db/migrate/tables/wiki_content_journals.rb b/db/migrate/tables/wiki_page_journals.rbsimilarity index 85%rename from db/migrate/tables/wiki_content_journals.rbrename to db/migrate/tables/wiki_page_journals.rbindex 94fb7a8fdcb..9a310be8d8f 100644--- a/db/migrate/tables/wiki_content_journals.rb+++ b/db/migrate/tables/wiki_page_journals.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -28,15 +30,11 @@require_relative "base"-class Tables::WikiContentJournals < Tables::Base+class Tables::WikiPageJournals < Tables::Basedef self.table(migration)- create_table migration do |t|- t.integer :journal_id, null: false- t.integer :page_id, null: false- t.integer :author_id+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestamps+ t.bigint :author_idt.text :text, limit: (1.gigabyte - 1)-- t.index [:journal_id]endendenddiff --git a/db/migrate/tables/wiki_pages.rb b/db/migrate/tables/wiki_pages.rbindex b52fd8eecce..271258d9c22 100644--- a/db/migrate/tables/wiki_pages.rb+++ b/db/migrate/tables/wiki_pages.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -29,14 +31,18 @@require_relative "base"class Tables::WikiPages < Tables::Base- def self.table(migration)+ def self.table(migration) # rubocop:disable Metrics/AbcSizecreate_table migration do |t|- t.integer :wiki_id, null: false+ t.bigint :wiki_id, null: falset.string :title, null: false- t.datetime :created_on, null: false+ t.datetime :created_at, precision: nil, null: false, default: -> { "CURRENT_TIMESTAMP" }t.boolean :protected, default: false, null: false- t.integer :parent_id+ t.bigint :parent_idt.string :slug, null: false+ t.datetime :updated_at, precision: nil, null: false, index: true+ t.references :author, index: true, null: false, foreign_key: { to_table: :users }+ t.text :text, limit: 16.megabytes+ t.integer :lock_version, null: falset.index %i[wiki_id slug], name: "wiki_pages_wiki_id_slug", unique: truet.index :parent_id, name: "index_wiki_pages_on_parent_id"diff --git a/db/migrate/tables/wiki_redirects.rb b/db/migrate/tables/wiki_redirects.rbindex 8f92ccadfaa..cbe8d826471 100644--- a/db/migrate/tables/wiki_redirects.rb+++ b/db/migrate/tables/wiki_redirects.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -31,10 +33,10 @@ require_relative "base"class Tables::WikiRedirects < Tables::Basedef self.table(migration)create_table migration do |t|- t.integer "wiki_id", null: false- t.string "title"- t.string "redirects_to"- t.datetime "created_on", null: false+ t.bigint :wiki_id, null: false+ t.string :title+ t.string :redirects_to+ t.datetime :created_at, precision: nil, null: false, default: -> { "CURRENT_TIMESTAMP" }t.index %i[wiki_id title], name: "wiki_redirects_wiki_id_title"t.index :wiki_id, name: "index_wiki_redirects_on_wiki_id"diff --git a/db/migrate/tables/wikis.rb b/db/migrate/tables/wikis.rbindex 9f55b77d6a7..4912fe6b8aa 100644--- a/db/migrate/tables/wikis.rb+++ b/db/migrate/tables/wikis.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -31,9 +33,10 @@ require_relative "base"class Tables::Wikis < Tables::Basedef self.table(migration)create_table migration do |t|- t.integer :project_id, null: false+ t.bigint :project_id, null: falset.string :start_page, null: falset.integer :status, default: 1, null: false+ t.timestamps precision: nilt.index :project_id, name: "wikis_project_id"enddiff --git a/db/migrate/tables/work_package_hierarchies.rb b/db/migrate/tables/work_package_hierarchies.rbnew file mode 100644index 00000000000..4de1f4f597a--- /dev/null+++ b/db/migrate/tables/work_package_hierarchies.rb@@ -0,0 +1,48 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require_relative "base"++class Tables::WorkPackageHierarchies < Tables::Base+ def self.table(migration)+ create_table migration, id: false do |t|+ t.integer :ancestor_id, null: false+ t.integer :descendant_id, null: false+ t.integer :generations, null: false++ t.index %i[ancestor_id descendant_id generations],+ unique: true,+ name: "work_package_anc_desc_idx"++ t.index [:descendant_id],+ name: "work_package_desc_idx"+ end+ end+enddiff --git a/db/migrate/tables/work_package_journals.rb b/db/migrate/tables/work_package_journals.rbindex dc0470099d2..e8aea647b92 100644--- a/db/migrate/tables/work_package_journals.rb+++ b/db/migrate/tables/work_package_journals.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -31,26 +33,29 @@ require_relative "base"class Tables::WorkPackageJournals < Tables::Base# rubocop:disable Metrics/AbcSizedef self.table(migration)- create_table migration do |t|- t.integer :journal_id, null: false- t.integer :type_id, default: 0, null: false- t.integer :project_id, default: 0, null: false- t.string :subject, default: "", null: false+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestamps+ t.bigint :type_id, null: false, index: true+ t.bigint :project_id, null: false, index: true+ t.string :subject, default: nil, null: falset.text :description- t.date :due_date- t.integer :category_id- t.integer :status_id, default: 0, null: false- t.integer :assigned_to_id- t.integer :priority_id, default: 0, null: false- t.integer :fixed_version_id- t.integer :author_id, default: 0, null: false- t.integer :done_ratio, default: 0, null: false+ t.date :due_date, index: true+ t.bigint :category_id, index: true+ t.bigint :status_id, null: false, index: true+ t.bigint :assigned_to_id, index: true+ t.bigint :priority_id, null: false+ t.bigint :version_id, index: true+ t.bigint :author_id, null: false, index: true+ t.integer :done_ratio, default: nil, null: truet.float :estimated_hours- t.date :start_date- t.integer :parent_id- t.integer :responsible_id-- t.index [:journal_id]+ t.date :start_date, index: true+ t.bigint :parent_id, index: true+ t.bigint :responsible_id, index: true+ t.float :derived_estimated_hours+ t.boolean :schedule_manually, default: nil, index: true # rubocop:disable Rails/ThreeStateBooleanColumn+ t.integer :duration+ t.boolean :ignore_non_working_days, null: false # rubocop:disable Rails/ThreeStateBooleanColumn+ t.float :derived_remaining_hours+ t.integer :derived_done_ratio, default: nil, null: trueend# rubocop:enable Metrics/AbcSizeenddiff --git a/db/migrate/tables/work_packages.rb b/db/migrate/tables/work_packages.rbindex b123c37f906..d903410329b 100644--- a/db/migrate/tables/work_packages.rb+++ b/db/migrate/tables/work_packages.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -29,46 +31,37 @@require_relative "base"class Tables::WorkPackages < Tables::Base- # rubocop:disable Metrics/AbcSize- def self.table(migration)+ def self.table(migration) # rubocop:disable Metrics/AbcSizecreate_table migration do |t|- t.integer :type_id, default: 0, null: false- t.belongs_to :project, default: 0, null: false, type: :int+ t.references :type, null: false, index: true, foreign_key: { on_delete: :cascade, on_update: :cascade }+ t.references :project, null: false, foreign_key: { on_delete: :cascade, on_update: :cascade }t.string :subject, default: "", null: falset.text :description- t.date :due_date- t.integer :category_id- t.integer :status_id, default: 0, null: false- t.integer :assigned_to_id- t.integer :priority_id, null: true, default: 0- t.integer :fixed_version_id- t.integer :author_id, default: 0, null: false+ t.date :due_date, index: true+ t.bigint :category_id, index: true+ t.references :status, null: false, index: true, foreign_key: { on_delete: :cascade, on_update: :cascade }+ t.bigint :assigned_to_id, index: true+ t.bigint :priority_id, null: true+ t.bigint :version_id, index: true+ t.bigint :author_id, null: false, index: truet.integer :lock_version, default: 0, null: false- t.integer :done_ratio, default: 0, null: false+ t.integer :done_ratio, default: nil, null: truet.float :estimated_hours- t.timestamps null: true- t.date :start_date- t.belongs_to :parent, default: nil, type: :int- t.belongs_to :responsible, type: :int-- # Nested Set- t.integer :root_id, default: nil- t.integer :lft, default: nil- t.integer :rgt, default: nil+ t.timestamps precision: nil, null: true, index: true+ t.date :start_date, index: true+ t.belongs_to :responsible+ t.float :derived_estimated_hours+ t.boolean :schedule_manually, default: false # rubocop:disable Rails/ThreeStateBooleanColumn+ t.bigint :parent_id, null: true, index: true+ t.integer :duration+ t.boolean :ignore_non_working_days, default: false, null: false+ t.float :derived_remaining_hours+ t.integer :derived_done_ratio, default: nil, null: true- # Nested Set- t.index %i[root_id lft rgt]-- t.index :type_id- t.index :status_id- t.index :category_id- t.index :author_id- t.index :assigned_to_id- t.index :created_at- t.index :fixed_version_id- t.index :updated_att.index %i[project_id updated_at]+ t.index :schedule_manually, where: :schedule_manually++ t.check_constraint "due_date >= start_date", name: "work_packages_due_larger_start_date"endend- # rubocop:enable Metrics/AbcSizeenddiff --git a/db/migrate/tables/workflows.rb b/db/migrate/tables/workflows.rbindex 7c7a738cd2b..52534bfad53 100644--- a/db/migrate/tables/workflows.rb+++ b/db/migrate/tables/workflows.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -30,17 +32,14 @@ require_relative "base"class Tables::Workflows < Tables::Basedef self.table(migration)- create_table migration do |t|- t.integer :type_id, default: 0, null: false- t.integer :old_status_id, default: 0, null: false- t.integer :new_status_id, default: 0, null: false- t.integer :role_id, default: 0, null: false+ create_table migration do |t| # rubocop:disable Rails/CreateTableWithTimestamps+ t.references :type, null: false, index: false, foreign_key: { on_delete: :cascade, on_update: :cascade }+ t.references :old_status, null: false, foreign_key: { to_table: :statuses, on_delete: :cascade, on_update: :cascade }+ t.references :new_status, null: false, foreign_key: { to_table: :statuses, on_delete: :cascade, on_update: :cascade }+ t.references :role, null: false, foreign_key: { on_delete: :cascade, on_update: :cascade }t.boolean :assignee, default: false, null: falset.boolean :author, default: false, null: false- t.index :new_status_id, name: "index_workflows_on_new_status_id"- t.index :old_status_id, name: "index_workflows_on_old_status_id"- t.index :role_id, name: "index_workflows_on_role_id"t.index %i[role_id type_id old_status_id], name: "wkfs_role_type_old_status"endenddiff --git a/modules/storages/db/migrate/20230123092649_make_containter_id_and_containter_type_optional_for_file_links.rb b/modules/auth_saml/db/migrate/1011015_aggregated_auth_saml_migrations.rbsimilarity index 80%rename from modules/storages/db/migrate/20230123092649_make_containter_id_and_containter_type_optional_for_file_links.rbrename to modules/auth_saml/db/migrate/1011015_aggregated_auth_saml_migrations.rbindex 4f372ed6942..a8e21a4f52c 100644--- a/modules/storages/db/migrate/20230123092649_make_containter_id_and_containter_type_optional_for_file_links.rb+++ b/modules/auth_saml/db/migrate/1011015_aggregated_auth_saml_migrations.rb@@ -28,9 +28,11 @@# See COPYRIGHT and LICENSE files for more details.#++-class MakeContainterIdAndContainterTypeOptionalForFileLinks < ActiveRecord::Migration[7.0]- def change- change_column_null :file_links, :container_id, true- change_column_null :file_links, :container_type, true- end+require Rails.root.join("db/migrate/migration_utils/squashed_migration").to_s+Dir[File.join(__dir__, "tables/*.rb")].each { |file| require file }++class AggregatedAuthSamlMigrations < SquashedMigration+ squashed_migrations *%w[+ 20240821121856_migrate_saml_settings_to_providers+ ].freezeenddiff --git a/modules/auth_saml/db/migrate/20240821121856_migrate_saml_settings_to_providers.rb b/modules/auth_saml/db/migrate/20240821121856_migrate_saml_settings_to_providers.rbdeleted file mode 100644index 260c6c18b35..00000000000--- a/modules/auth_saml/db/migrate/20240821121856_migrate_saml_settings_to_providers.rb+++ /dev/null@@ -1,48 +0,0 @@-# frozen_string_literal: true--class MigrateSamlSettingsToProviders < ActiveRecord::Migration[7.1]- def up- settings = Setting.plugin_openproject_auth_saml- return if settings.blank?-- providers = Hash(settings).with_indifferent_access[:providers]- return if providers.blank?-- providers.each do |name, options|- migrate_provider!(name, options)- end- end-- def down- # This migration does not yet remove Setting.plugin_openproject_auth_saml- # so it can be retried.- end-- private-- def migrate_provider!(name, options)- puts "Trying to migrate SAML provider #{name} from previous settings format..."- call = ::Saml::SyncService.new(name, options, contract_class: EmptyContract).call-- if call.success- puts <<~SUCCESS- Successfully migrated SAML provider #{name} from previous settings format.- You can now manage this provider in the new administrative UI within OpenProject under- the "Administration -> Authentication -> SAML providers" section.- SUCCESS- else- raise <<~ERROR- Failed to create or update SAML provider #{name} from previous settings format.- The error message was: #{call.message}-- Please check the logs for more information and open a bug report in our community:- https://www.openproject.org/docs/development/report-a-bug/-- If you would like to skip migrating the SAML setting and discard them instead, you can use our documentation- to unset any previous SAML settings:-- https://www.openproject.org/docs/system-admin-guide/authentication/saml/- ERROR- end- end-enddiff --git a/db/migrate/20200924085508_cleanup_orphaned_journal_data.rb b/modules/backlogs/db/migrate/1002015_aggregated_backlogs_migrations.rbsimilarity index 57%rename from db/migrate/20200924085508_cleanup_orphaned_journal_data.rbrename to modules/backlogs/db/migrate/1002015_aggregated_backlogs_migrations.rbindex bf1a731456e..b7ccf843639 100644--- a/db/migrate/20200924085508_cleanup_orphaned_journal_data.rb+++ b/modules/backlogs/db/migrate/1002015_aggregated_backlogs_migrations.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -26,40 +28,31 @@# See COPYRIGHT and LICENSE files for more details.#++-class CleanupOrphanedJournalData < ActiveRecord::Migration[6.0]- def up- cleanup_orphaned_journals("attachable_journals")- cleanup_orphaned_journals("customizable_journals")- cleanup_orphaned_journals("attachment_journals")- cleanup_orphaned_journals("changeset_journals")- cleanup_orphaned_journals("message_journals")- cleanup_orphaned_journals("news_journals")- cleanup_orphaned_journals("wiki_content_journals")- cleanup_orphaned_journals("work_package_journals")- end+require Rails.root.join("db/migrate/migration_utils/squashed_migration").to_s+Dir[File.join(__dir__, "tables/*.rb")].each { |file| require file }++class AggregatedBacklogsMigrations < SquashedMigration+ squashed_migrations *%w[+ 20180323151208_to_v710_aggregated_backlogs_migrations+ 20230717104700_drop_export_card_configurations+ ].freeze++ tables Tables::DoneStatusesForProject,+ Tables::VersionSettings- # No down needed as this only cleans up data that should have been deleted anyway.+ modifications do+ add_column :work_packages, :position, :integer+ add_column :work_packages, :story_points, :integer+ add_column :work_packages, :remaining_hours, :float- private+ add_column :work_package_journals, :story_points, :integer+ add_column :work_package_journals, :remaining_hours, :float- def cleanup_orphaned_journals(table)- execute <<~SQL.squish- DELETE- FROM- #{table}- WHERE- #{table}.id IN (- SELECT- #{table}.id- FROM- #{table}- LEFT OUTER JOIN- journals- ON- journals.id = #{table}.journal_id- WHERE- journals.id IS NULL- )- SQL+ add_index :work_package_journals,+ %i[version_id+ status_id+ project_id+ type_id],+ name: "work_package_journal_on_burndown_attributes"endenddiff --git a/modules/backlogs/db/migrate/20180323151208_to_v710_aggregated_backlogs_migrations.rb b/modules/backlogs/db/migrate/20180323151208_to_v710_aggregated_backlogs_migrations.rbdeleted file mode 100644index a704b20dd37..00000000000--- a/modules/backlogs/db/migrate/20180323151208_to_v710_aggregated_backlogs_migrations.rb+++ /dev/null@@ -1,94 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require Rails.root.join("db/migrate/migration_utils/migration_squasher").to_s-# This migration aggregates the migrations detailed in MIGRATION_FILES-class ToV710AggregatedBacklogsMigrations < ActiveRecord::Migration[5.1]- MIGRATION_FILES = <<-MIGRATIONS- 20111014073606_aggregated_backlogs_migrations.rb- 20130625094113_add_backlogs_column_to_work_package.rb- 20130916094370_legacy_issues_backlogs_data_to_work_packages.rb- 20130919092624_add_backlog_columns_to_work_package_journal.rb- 20131001132542_rename_issue_status_to_status.rb- MIGRATIONS-- def up- Migration::MigrationSquasher.squash(migrations) do- create_table "version_settings", id: :integer do |t|- t.integer "project_id"- t.integer "version_id"- t.integer "display"- t.datetime "created_at", null: false- t.datetime "updated_at", null: false- end- add_index "version_settings", ["project_id", "version_id"], name: "index_version_settings_on_project_id_and_version_id"-- create_table "done_statuses_for_project", id: false do |t|- t.integer "project_id"- t.integer "status_id"- end-- add_column :work_packages, :position, :integer- add_column :work_packages, :story_points, :integer- add_column :work_packages, :remaining_hours, :float-- add_column :work_package_journals, :story_points, :integer- add_column :work_package_journals, :remaining_hours, :float-- add_index :work_package_journals,- %i[fixed_version_id- status_id- project_id- type_id],- name: "work_package_journal_on_burndown_attributes"- end- end-- def down- drop_table "version_settings"- drop_table "done_statuses_for_project"-- remove_column :work_packages, :position- remove_column :work_packages, :story_points- remove_column :work_packages, :remaining_hours-- remove_column :work_package_journals, :story_points- remove_column :work_package_journals, :remaining_hours-- remove_index :work_package_journals,- name: "work_package_journal_on_burndown_attributes"- end-- private-- def migrations- MIGRATION_FILES.split.map do |m|- m.gsub(/_.*\z/, "")- end- end-enddiff --git a/modules/storages/db/migrate/20230802085026_rename_projects_storages_table.rb b/modules/backlogs/db/migrate/tables/done_statuses_for_project.rbsimilarity index 82%rename from modules/storages/db/migrate/20230802085026_rename_projects_storages_table.rbrename to modules/backlogs/db/migrate/tables/done_statuses_for_project.rbindex 05d192b04f6..c882e3533de 100644--- a/modules/storages/db/migrate/20230802085026_rename_projects_storages_table.rb+++ b/modules/backlogs/db/migrate/tables/done_statuses_for_project.rb@@ -1,6 +1,6 @@# frozen_string_literal: true-#-- copyright+# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -26,11 +26,15 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++-class RenameProjectsStoragesTable < ActiveRecord::Migration[7.0]- def change- rename_table :projects_storages, :project_storages- rename_column :last_project_folders, :projects_storage_id, :project_storage_id+require Rails.root.join("db/migrate/tables/base").to_s++class Tables::DoneStatusesForProject < Tables::Base+ def self.table(migration)+ create_table migration, id: false do |t|+ t.bigint :project_id+ t.bigint :status_id+ endendenddiff --git a/modules/backlogs/db/migrate/tables/version_settings.rb b/modules/backlogs/db/migrate/tables/version_settings.rbnew file mode 100644index 00000000000..c79f115ca17--- /dev/null+++ b/modules/backlogs/db/migrate/tables/version_settings.rb@@ -0,0 +1,45 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::VersionSettings < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.bigint :project_id+ t.bigint :version_id+ t.integer :display+ t.timestamps precision: nil, null: false++ t.index %i[project_id version_id],+ name: "index_version_settings_on_project_id_and_version_id"+ end+ end+enddiff --git a/app/workers/work_packages/progress/migrate_remove_totals_from_childless_work_packages_job.rb b/modules/bim/db/migrate/1001015_aggregated_bim_migrations.rbsimilarity index 51%rename from app/workers/work_packages/progress/migrate_remove_totals_from_childless_work_packages_job.rbrename to modules/bim/db/migrate/1001015_aggregated_bim_migrations.rbindex d991e49b019..bd275587ad6 100644--- a/app/workers/work_packages/progress/migrate_remove_totals_from_childless_work_packages_job.rb+++ b/modules/bim/db/migrate/1001015_aggregated_bim_migrations.rb@@ -28,39 +28,31 @@# See COPYRIGHT and LICENSE files for more details.#++-class WorkPackages::Progress::MigrateRemoveTotalsFromChildlessWorkPackagesJob < WorkPackages::Progress::Job- include WorkPackages::Progress::SqlCommandsForMigration+require Rails.root.join("db/migrate/migration_utils/squashed_migration").to_s+Dir[File.join(__dir__, "tables/*.rb")].each { |file| require file }- def perform- updated_work_package_ids = remove_totals_from_childless_work_packages- create_journals_for_updated_work_packages(updated_work_package_ids, cause: journal_cause)- end+class AggregatedBimMigrations < SquashedMigration+ squashed_migrations *%w[+ 20181214103300_add_bcf_plugin+ 20190719123448_add_viewpoint_to_bcf_comment+ 20190823090211_remove_project_id_from_bcf_issue+ 20191029155327_add_ifc_models_plugin+ 20191114090353_add_is_default_to_ifc_models+ 20191119144123_add_issue_columns+ 20191121140202_migrate_xml_viewpoint_to_json+ 20200123163818_add_on_delete_nullify_to_bcf_comment_foreign_key_to_viewpoint+ 20200310092237_add_timestamps_to_bcf+ 20200610083854_add_uniqueness_contrain_to_bcf_topic_on_uuid+ 20201105154216_seed_custom_style_with_bim_theme+ 20210521080035_update_xkt_to_version8+ 20210713081724_flip_bcf_viewpoint_clipping_direction_selectively+ 20210910092414_add_bcf_comment_hierarchy+ 20211011204301_add_column_conversion_status_to_ifc_model+ 20211022143726_remove_snapshot_data+ ].freeze- private-- def journal_cause- { type: "system_update", feature: "totals_removed_from_childless_work_packages" }- end-- def remove_totals_from_childless_work_packages- results = execute(<<~SQL.squish)- UPDATE work_packages- SET derived_estimated_hours = NULL,- derived_remaining_hours = NULL,- derived_done_ratio = NULL- WHERE work_packages.id IN (- SELECT ancestor_id AS id- FROM work_package_hierarchies- GROUP BY id- HAVING MAX(generations) = 0- )- AND (- work_packages.derived_estimated_hours IS NOT NULL- OR work_packages.derived_remaining_hours IS NOT NULL- OR work_packages.derived_done_ratio IS NOT NULL- )- RETURNING work_packages.id- SQL- results.column_values(0)- end+ tables Tables::BcfIssues,+ Tables::BcfViewpoints,+ Tables::BcfComments,+ Tables::IfcModelsenddiff --git a/modules/bim/db/migrate/20190719123448_add_viewpoint_to_bcf_comment.rb b/modules/bim/db/migrate/20190719123448_add_viewpoint_to_bcf_comment.rbdeleted file mode 100644index 91d02ba0c97..00000000000--- a/modules/bim/db/migrate/20190719123448_add_viewpoint_to_bcf_comment.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddViewpointToBcfComment < ActiveRecord::Migration[5.1]- def change- add_reference :bcf_comments, :viewpoint, foreign_key: { to_table: :bcf_viewpoints }, index: true- end-enddiff --git a/modules/bim/db/migrate/20190823090211_remove_project_id_from_bcf_issue.rb b/modules/bim/db/migrate/20190823090211_remove_project_id_from_bcf_issue.rbdeleted file mode 100644index 9e52ea3db5b..00000000000--- a/modules/bim/db/migrate/20190823090211_remove_project_id_from_bcf_issue.rb+++ /dev/null@@ -1,44 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RemoveProjectIdFromBcfIssue < ActiveRecord::Migration[5.1]- def up- remove_column :bcf_issues, :project_id- end-- def down- add_reference :bcf_issues, :project, foreign_key: { on_delete: :cascade }, index: true-- Bim::Bcf::Issue.includes(:work_package).find_each do |bcf_issue|- if bcf_issue.work_package- bcf_issue.project_id = bcf_issue.work_package.project_id- bcf_issue.save- end- end- end-enddiff --git a/modules/bim/db/migrate/20191114090353_add_is_default_to_ifc_models.rb b/modules/bim/db/migrate/20191114090353_add_is_default_to_ifc_models.rbdeleted file mode 100644index d704fab0eb6..00000000000--- a/modules/bim/db/migrate/20191114090353_add_is_default_to_ifc_models.rb+++ /dev/null@@ -1,35 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddIsDefaultToIfcModels < ActiveRecord::Migration[5.1]- def change- add_column :ifc_models, :is_default, :boolean, default: false, null: false-- add_index :ifc_models, :is_default- end-enddiff --git a/modules/bim/db/migrate/20191119144123_add_issue_columns.rb b/modules/bim/db/migrate/20191119144123_add_issue_columns.rbdeleted file mode 100644index 8489fcc3702..00000000000--- a/modules/bim/db/migrate/20191119144123_add_issue_columns.rb+++ /dev/null@@ -1,37 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddIssueColumns < ActiveRecord::Migration[6.0]- def change- change_table :bcf_issues do |i|- i.string :stage- i.integer :index- i.text :labels, array: true, default: []- end- end-enddiff --git a/modules/bim/db/migrate/20191121140202_migrate_xml_viewpoint_to_json.rb b/modules/bim/db/migrate/20191121140202_migrate_xml_viewpoint_to_json.rbdeleted file mode 100644index 3b491117bed..00000000000--- a/modules/bim/db/migrate/20191121140202_migrate_xml_viewpoint_to_json.rb+++ /dev/null@@ -1,58 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class MigrateXmlViewpointToJson < ActiveRecord::Migration[6.0]- def up- # Add JSON viewpoint- change_table :bcf_viewpoints do |t|- t.jsonb :json_viewpoint- end-- # Convert viewpoints- ::Bim::Bcf::Viewpoint.reset_column_information- ::Bim::Bcf::Viewpoint.find_each do |resource|- mapper = ::OpenProject::Bim::BcfJson::ViewpointReader- .new(resource.uuid, resource.viewpoint)-- resource.update_column(:json_viewpoint, mapper.result)-- Rails.logger.debug { "Converted viewpoint (##{resource.id}) #{resource.uuid} to JSON." }- rescue StandardError => e- warn "Failed to convert viewpoint #{viewpoint.uuid}: #{e} #{e.message}"- end-- # Remove the old XML viewpoint- change_table :bcf_viewpoints do |t|- t.remove :viewpoint- end- end-- def down- raise "Cannot be reverted yet!"- end-enddiff --git a/modules/bim/db/migrate/20200123163818_add_on_delete_nullify_to_bcf_comment_foreign_key_to_viewpoint.rb b/modules/bim/db/migrate/20200123163818_add_on_delete_nullify_to_bcf_comment_foreign_key_to_viewpoint.rbdeleted file mode 100644index 3df0e5aee10..00000000000--- a/modules/bim/db/migrate/20200123163818_add_on_delete_nullify_to_bcf_comment_foreign_key_to_viewpoint.rb+++ /dev/null@@ -1,34 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddOnDeleteNullifyToBcfCommentForeignKeyToViewpoint < ActiveRecord::Migration[6.0]- def change- remove_reference :bcf_comments, :viewpoint- add_reference :bcf_comments, :viewpoint, foreign_key: { to_table: :bcf_viewpoints, on_delete: :nullify }, index: true- end-enddiff --git a/modules/bim/db/migrate/20200610083854_add_uniqueness_contrain_to_bcf_topic_on_uuid.rb b/modules/bim/db/migrate/20200610083854_add_uniqueness_contrain_to_bcf_topic_on_uuid.rbdeleted file mode 100644index 8c18e137067..00000000000--- a/modules/bim/db/migrate/20200610083854_add_uniqueness_contrain_to_bcf_topic_on_uuid.rb+++ /dev/null@@ -1,41 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddUniquenessContrainToBcfTopicOnUuid < ActiveRecord::Migration[6.0]- def up- # Create unique index on an issue's uuid. A BCF issue should only exist once on an instance. If you need a copy,- # then it is not the same anymore and thus should have a different uuid.- remove_index :bcf_issues, :uuid- add_index :bcf_issues, %i[uuid], unique: true- end-- def down- remove_index :bcf_issues, :uuid- add_index :bcf_issues, %i[uuid]- end-enddiff --git a/modules/bim/db/migrate/20201105154216_seed_custom_style_with_bim_theme.rb b/modules/bim/db/migrate/20201105154216_seed_custom_style_with_bim_theme.rbdeleted file mode 100644index f7c4e51d8b4..00000000000--- a/modules/bim/db/migrate/20201105154216_seed_custom_style_with_bim_theme.rb+++ /dev/null@@ -1,98 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--# This migration cleans up messed up themes. Sometimes in the past-# the BIM theme was not set where it should have been set.-class SeedCustomStyleWithBimTheme < ActiveRecord::Migration[6.0]- def up- # When- # migrating BIM instances- # that did not have any custom styles OR- # that do not have any design colors set and no custom logo/touch-icon/favicon- # (this basically means that no theme actually got applied)- # then- # add a custom style with the BIM theme set. This will write the theme's colors- # as DesignColor entries to the DB which is necessary for the theme to actually- # have an effect.- if OpenProject::Configuration.bim? &&- (CustomStyle.current.nil? ||- (DesignColor.count == 0 &&- CustomStyle.current.favicon.nil? &&- CustomStyle.current.logo.nil? &&- CustomStyle.current.touch_icon.nil?))- seed_bim_theme- end- end-- def down- # nop- end-- private-- def seed_bim_theme- CustomStyle.transaction do- set_custom_style- set_design_colors- end- end-- def set_design_colors- # There should not be any DesignColors present. However, we want to make sure.- DesignColor.delete_all-- theme[:colors].each do |param_variable, param_hexcode|- DesignColor.create variable: param_variable, hexcode: param_hexcode- end- end-- def set_custom_style- custom_style = CustomStyle.current || CustomStyle.create!- custom_style.attributes = { theme: theme[:theme], theme_logo: theme[:logo] }- custom_style.save!- custom_style- end-- def theme- {- theme: "OpenProject BIM",- colors: {- "primary-color" => "#3270DB",- "primary-color-dark" => "#163473",- "alternative-color" => "#349939",- "header-bg-color" => "#05002C",- "header-item-bg-hover-color" => "#163473",- "content-link-color" => "#275BB5",- "main-menu-bg-color" => "#0E2045",- "main-menu-bg-selected-background" => "#3270DB",- "main-menu-bg-hover-background" => "#163473"- },- logo: "bim/logo_openproject_bim_big.png"- }- end-enddiff --git a/modules/bim/db/migrate/20210521080035_update_xkt_to_version8.rb b/modules/bim/db/migrate/20210521080035_update_xkt_to_version8.rbdeleted file mode 100644index d07238f5414..00000000000--- a/modules/bim/db/migrate/20210521080035_update_xkt_to_version8.rb+++ /dev/null@@ -1,116 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class UpdateXktToVersion8 < ActiveRecord::Migration[6.1]- SEEDED_MODEL_DATA = { "Hospital - Architecture (cc-by-sa-3.0 Autodesk Inc.)" => "hospital_architecture",- "Hospital - Structural (cc-by-sa-3.0 Autodesk Inc.)" => "hospital_structural",- "Hospital - Mechanical (cc-by-sa-3.0 Autodesk Inc.)" => "hospital_mechanical" }.freeze-- # Note: rails 7.1 breaks the class' ancestor chain, and raises an error, when a class- # with an enum definition without a database field is being referenced.- # Re-defining the IfcModel class without the enum to avoid the issue.- class IfcModel < ApplicationRecord- has_many :attachments, -> { where(container_type: "Bim::IfcModels::IfcModel") },- foreign_key: :container_id,- class_name: "Attachment"- end-- def up- # Queue every IFC model for a new transformation.- Rails.logger.info "Migrate all IFC models to the latest XKT version"-- if IfcModel.count.zero?- Rails.logger.info("No IFC models to migrate")- return- end-- # Only report an error if you really need the IFC models to be converted. If the BIM edition is not active then- # you don't need the IFC models to get converted and even more important, you don't need the full conversion- # pipeline to be installed.- unless ::OpenProject::Configuration.bim? && ::Bim::IfcModels::ViewConverterService.available?- Rails.logger.error("Cannot convert IFC models. Some or all IFC conversion tools are not installed on your server.")- return- end-- migrate_all_ifc_models- update_demo_xkt_models- end-- def down- # This migration is irreversible- end-- private-- def migrate_all_ifc_models- IfcModel.find_each do |ifc_model|- cleanup_metadata_attachment(ifc_model)- # We have seeded models that do not have an IFC attachment. They cannot get converted as an IFC file is- # necessary.- next if ifc_model.attachments.find_by(description: "ifc").nil?-- ::Bim::IfcModels::IfcConversionJob.perform_later(ifc_model)- end- end-- def cleanup_metadata_attachment(ifc_model)- ifc_model.attachments.find_by(description: "metadata")&.destroy- end-- def update_demo_xkt_models- project = Project.find_by(identifier: "demo-bcf-management-project")- return unless project-- ifc_models = project.ifc_models.joins(:attachments)- .where("attachments.description LIKE 'xkt' AND ifc_models.title IN (?)",- SEEDED_MODEL_DATA.keys)-- ifc_models.each do |ifc_model|- old_attachment = ifc_model.xkt_attachment- next unless old_attachment-- attachment = Attachment.new(- container: ifc_model,- author: old_attachment.author,- file: get_file(SEEDED_MODEL_DATA[ifc_model.title]),- description: old_attachment.description- )-- old_attachment.destroy- attachment.save! validate: false- end- end-- def get_file(name)- path = "modules/bim/files/ifc_models/#{name}/"- file_name = "#{name}.xkt"- return unless File.exist?(path + file_name)-- File.new(Rails.root.join(path, file_name))- end-enddiff --git a/modules/bim/db/migrate/20211011204301_add_column_conversion_status_to_ifc_model.rb b/modules/bim/db/migrate/20211011204301_add_column_conversion_status_to_ifc_model.rbdeleted file mode 100644index ad9966d59a5..00000000000--- a/modules/bim/db/migrate/20211011204301_add_column_conversion_status_to_ifc_model.rb+++ /dev/null@@ -1,63 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddColumnConversionStatusToIfcModel < ActiveRecord::Migration[6.1]- class MigrationAttachment < ApplicationRecord- self.table_name = "attachments"- end-- # Note: rails 7.1 breaks the class' ancestor chain, and raises an error, when a class- # with an enum definition without a database field is being referenced.- # Re-defining the IfcModel class without the enum to avoid the issue.- class IfcModel < ApplicationRecord- has_many :attachments, -> { where(container_type: "Bim::IfcModels::IfcModel") },- foreign_key: :container_id,- class_name: "MigrationAttachment"- end-- def up- add_column(:ifc_models, :conversion_status, :integer, default: 0) # default "pending"- add_column(:ifc_models, :conversion_error_message, :text)-- converted_models = IfcModel- .joins(:attachments)- .where("attachments.description = 'xkt'")-- not_converted_models = IfcModel- .where- .not(id: converted_models)-- converted_models.update_all(conversion_status: 2) # 2 == processed- not_converted_models.update_all(conversion_status: 3) # 3 == error- end-- def down- remove_column(:ifc_models, :conversion_status)- remove_column(:ifc_models, :conversion_error_message)- end-enddiff --git a/modules/bim/db/migrate/20181214103300_add_bcf_plugin.rb b/modules/bim/db/migrate/tables/bcf_comments.rbsimilarity index 65%rename from modules/bim/db/migrate/20181214103300_add_bcf_plugin.rbrename to modules/bim/db/migrate/tables/bcf_comments.rbindex d1aef4eea7f..0e65df97d44 100644--- a/modules/bim/db/migrate/20181214103300_add_bcf_plugin.rb+++ b/modules/bim/db/migrate/tables/bcf_comments.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,40 +26,26 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#++--class AddBcfPlugin < ActiveRecord::Migration[5.1]- def change- create_table :bcf_issues do |t|- t.text :uuid, index: true- t.column :markup, :xml-- t.references :project, foreign_key: { on_delete: :cascade }, index: true- t.references :work_package, foreign_key: { on_delete: :cascade }, index: { unique: true }- end-- create_table :bcf_viewpoints do |t|- t.text :uuid, index: true- t.column :viewpoint, :xml- t.text :viewpoint_name-- t.references :issue,- foreign_key: { to_table: :bcf_issues, on_delete: :cascade }+# ++- # Create unique index on issue and uuid to avoid duplicates on resynchronization- t.index %i[uuid issue_id], unique: true- end+require Rails.root.join("db/migrate/tables/base").to_s- create_table :bcf_comments do |t|- t.text :uuid, index: true+class Tables::BcfComments < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.text :uuidt.references :journal, index: true-t.references :issue,foreign_key: { to_table: :bcf_issues, on_delete: :cascade },index: true+ t.references :viewpoint, foreign_key: { to_table: :bcf_viewpoints, on_delete: :nullify }, index: true# Create unique index on issue and uuid to avoid duplicates on resynchronizationt.index %i[uuid issue_id], unique: true+ t.index :uuid++ t.bigint :reply_to, default: nil, null: true+ t.foreign_key :bcf_comments, column: :reply_to, on_delete: :nullifyendendenddiff --git a/modules/bim/db/migrate/tables/bcf_issues.rb b/modules/bim/db/migrate/tables/bcf_issues.rbnew file mode 100644index 00000000000..7bf2fe52d9d--- /dev/null+++ b/modules/bim/db/migrate/tables/bcf_issues.rb@@ -0,0 +1,50 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::BcfIssues < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.text :uuid+ t.column :markup, :xml++ t.references :work_package, foreign_key: { on_delete: :cascade }, index: { unique: true }++ t.string :stage+ t.integer :index+ t.text :labels, array: true, default: []++ t.timestamps default: -> { "CURRENT_TIMESTAMP" }++ t.index :uuid, unique: true+ end+ end+enddiff --git a/db/migrate/tables/boards.rb b/modules/bim/db/migrate/tables/bcf_viewpoints.rbsimilarity index 70%rename from db/migrate/tables/boards.rbrename to modules/bim/db/migrate/tables/bcf_viewpoints.rbindex b8d585317ad..1a7173a0039 100644--- a/db/migrate/tables/boards.rb+++ b/modules/bim/db/migrate/tables/bcf_viewpoints.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,23 +26,24 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++-require_relative "base"+require Rails.root.join("db/migrate/tables/base").to_s-class Tables::Boards < Tables::Base+class Tables::BcfViewpoints < Tables::Basedef self.table(migration)create_table migration do |t|- t.integer :project_id, null: false- t.string :name, default: "", null: false- t.string :description- t.integer :position, default: 1- t.integer :topics_count, default: 0, null: false- t.integer :messages_count, default: 0, null: false- t.integer :last_message_id+ t.text :uuid+ t.text :viewpoint_name+ t.references :issue,+ foreign_key: { to_table: :bcf_issues, on_delete: :cascade }+ t.jsonb :json_viewpoint++ # Create unique index on issue and uuid to avoid duplicates on resynchronization+ t.index %i[uuid issue_id], unique: true+ t.index :uuid- t.index :last_message_id, name: "index_#{table_name}_on_last_message_id"- t.index :project_id, name: "#{table_name}_project_id"+ t.timestamps default: -> { "CURRENT_TIMESTAMP" }endendenddiff --git a/modules/bim/db/migrate/20191029155327_add_ifc_models_plugin.rb b/modules/bim/db/migrate/tables/ifc_models.rbsimilarity index 76%rename from modules/bim/db/migrate/20191029155327_add_ifc_models_plugin.rbrename to modules/bim/db/migrate/tables/ifc_models.rbindex c171f968482..e3b881b68d6 100644--- a/modules/bim/db/migrate/20191029155327_add_ifc_models_plugin.rb+++ b/modules/bim/db/migrate/tables/ifc_models.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,16 +26,20 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++-class AddIfcModelsPlugin < ActiveRecord::Migration[5.1]- def change- create_table :ifc_models do |t|- t.string :title- t.timestamps+require Rails.root.join("db/migrate/tables/base").to_s+class Tables::IfcModels < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.string :title+ t.timestamps precision: nilt.references :project, foreign_key: { on_delete: :cascade }, index: truet.references :uploader, index: true+ t.boolean :is_default, default: false, null: false, index: true+ t.integer :conversion_status, default: 0 # default "pending"+ t.text :conversion_error_messageendendenddiff --git a/db/migrate/20230829151629_add_copy_work_packages_permission_to_roles.rb b/modules/budgets/db/migrate/1004015_aggregated_budget_migrations.rbsimilarity index 61%rename from db/migrate/20230829151629_add_copy_work_packages_permission_to_roles.rbrename to modules/budgets/db/migrate/1004015_aggregated_budget_migrations.rbindex 6bcb92a8a9f..fb106821dfd 100644--- a/db/migrate/20230829151629_add_copy_work_packages_permission_to_roles.rb+++ b/modules/budgets/db/migrate/1004015_aggregated_budget_migrations.rb@@ -1,6 +1,6 @@# frozen_string_literal: true-#-- copyright+# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -26,23 +26,28 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++-require_relative "migration_utils/permission_adder"+require Rails.root.join("db/migrate/migration_utils/squashed_migration").to_s+require_relative "tables/budgets"+require_relative "tables/budget_journals"+require_relative "tables/labor_budget_items"+require_relative "tables/material_budget_items"-class AddCopyWorkPackagesPermissionToRoles < ActiveRecord::Migration[7.0]- # Decouple ActiveRecord model from Migration- class MigrationRolePermission < ApplicationRecord- self.table_name = "role_permissions"- end+# This migration aggregates the migrations detailed in MIGRATION_FILES+class AggregatedBudgetMigrations < SquashedMigration+ squashed_migrations *%w[+ 20200807083950_keep_enabled_module+ 20200810152654_rename_cost_object_to_budget+ ]- def up- ::Migration::MigrationUtils::PermissionAdder- .add(:move_work_packages,- :copy_work_packages)- end+ tables Tables::Budgets,+ Tables::BudgetJournals,+ Tables::LaborBudgetItems,+ Tables::MaterialBudgetItems- def down- MigrationRolePermission.where(permission: "copy_work_packages").delete_all+ modifications do+ add_column :work_packages, :budget_id, :integer+ add_column :work_package_journals, :budget_id, :integer, null: trueendenddiff --git a/modules/budgets/db/migrate/20200807083950_keep_enabled_module.rb b/modules/budgets/db/migrate/20200807083950_keep_enabled_module.rbdeleted file mode 100644index 54f4b410fca..00000000000--- a/modules/budgets/db/migrate/20200807083950_keep_enabled_module.rb+++ /dev/null@@ -1,47 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require Rails.root.to_s + "/db/migrate/migration_utils/module_renamer"--class KeepEnabledModule < ActiveRecord::Migration[6.0]- def up- module_renamer.add_to_enabled("budgets", %w[costs_module])- module_renamer.add_to_default("budgets", %w[costs_module])- end-- def down- module_renamer.remove_from_enabled("budgets")- module_renamer.remove_from_default("budgets")- end-- private-- def module_renamer- Migration::MigrationUtils::ModuleRenamer- end-enddiff --git a/modules/budgets/db/migrate/20200810152654_rename_cost_object_to_budget.rb b/modules/budgets/db/migrate/20200810152654_rename_cost_object_to_budget.rbdeleted file mode 100644index 042ecc06245..00000000000--- a/modules/budgets/db/migrate/20200810152654_rename_cost_object_to_budget.rb+++ /dev/null@@ -1,194 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RenameCostObjectToBudget < ActiveRecord::Migration[6.0]- def up- if primary_key_index_name(:cost_objects) != "cost_objects_pkey"- warn "Found unexpected primary key name. Fixing primary key names..."-- require "./db/migrate/20190502102512_ensure_postgres_index_names"-- EnsurePostgresIndexNames.new.up- end-- remove_column :cost_objects, :type- rename_table :cost_objects, :budgets-- execute <<~SQL.squish- UPDATE types- SET attribute_groups = REGEXP_REPLACE(attribute_groups, ' cost_object', ' budget')- WHERE attribute_groups LIKE '%cost_object%'- SQL-- execute <<~SQL.squish- UPDATE role_permissions- SET permission = 'view_budgets'- WHERE permission = 'view_cost_objects'- SQL-- execute <<~SQL.squish- UPDATE role_permissions- SET permission = 'edit_budgets'- WHERE permission = 'edit_cost_objects'- SQL-- execute <<~SQL.squish- UPDATE journals- SET activity_type = 'budgets'- WHERE activity_type = 'cost_objects'- SQL-- execute <<~SQL.squish- UPDATE attachments- SET container_type = 'Budget'- WHERE container_type = 'CostObject'- SQL-- rename_in_queries("cost_object", "budget")- rename_in_cost_queries("CostObject", "Budget")-- rename_column :budgets, :created_on, :created_at- rename_column :budgets, :updated_on, :updated_at-- rename_table :cost_object_journals, :budget_journals- remove_column :budget_journals, :created_on-- rename_column :work_packages, :cost_object_id, :budget_id- rename_column :work_package_journals, :cost_object_id, :budget_id- rename_column :labor_budget_items, :cost_object_id, :budget_id- rename_column :labor_budget_items, :budget, :amount- rename_column :material_budget_items, :cost_object_id, :budget_id- rename_column :material_budget_items, :budget, :amount- end-- def down- rename_column :material_budget_items, :amount, :budget- rename_column :material_budget_items, :budget_id, :cost_object_id- rename_column :labor_budget_items, :amount, :budget- rename_column :labor_budget_items, :budget_id, :cost_object_id- rename_column :work_packages, :budget_id, :cost_object_id- rename_column :work_package_journals, :budget_id, :cost_object_id-- add_column :budget_journals, :created_on, :timestamp- rename_table :budget_journals, :cost_object_journals-- rename_column :budgets, :created_at, :created_on- rename_column :budgets, :updated_at, :updated_on-- rename_in_queries("budget", "cost_object")- rename_in_cost_queries("Budget", "CostObject")-- execute <<~SQL.squish- UPDATE attachments- SET container_type = 'CostObject'- WHERE container_type = 'Budget'- SQL-- execute <<~SQL.squish- UPDATE journals- SET activity_type = 'cost_objects'- WHERE activity_type = 'budgets'- SQL-- execute <<~SQL.squish- UPDATE role_permissions- SET permission = 'view_cost_objects'- WHERE permission = 'view_budgets'- SQL-- execute <<~SQL.squish- UPDATE role_permissions- SET permission = 'edit_cost_objects'- WHERE permission = 'edit_budgets'- SQL-- execute <<~SQL.squish- UPDATE types- SET attribute_groups = REGEXP_REPLACE(attribute_groups, ' budget', ' cost_object')- WHERE attribute_groups LIKE '%budget%'- SQL-- add_column :budgets, :type, :string-- execute <<~SQL.squish- UPDATE budgets SET type = 'VariableCostObject'- SQL-- change_column :budgets, :type, :string, null: false-- rename_table :budgets, :cost_objects- end-- def rename_in_queries(old, new)- execute <<~SQL.squish- UPDATE queries- SET filters = REGEXP_REPLACE(filters, '#{old}_id:', '#{new}_id:')- WHERE filters LIKE '%#{old}_id%'- SQL-- execute <<~SQL.squish- UPDATE queries- SET sort_criteria = REGEXP_REPLACE(sort_criteria, '#{old}', '#{new}')- WHERE sort_criteria LIKE '%#{old}%'- SQL-- execute <<~SQL.squish- UPDATE queries- SET column_names = REGEXP_REPLACE(column_names, '#{old}', '#{new}')- WHERE column_names LIKE '%#{old}%'- SQL-- execute <<~SQL.squish- UPDATE queries- SET group_by = REGEXP_REPLACE(group_by, '#{old}', '#{new}')- WHERE group_by LIKE '%#{old}%'- SQL-- execute <<~SQL.squish- UPDATE queries- SET timeline_labels = REGEXP_REPLACE(timeline_labels, '#{old.camelize(:lower)}', '#{new.camelize(:lower)}')- WHERE timeline_labels LIKE '%#{old.camelize(:lower)}%'- SQL- end-- def rename_in_cost_queries(old, new)- execute <<~SQL.squish- UPDATE cost_queries- SET serialized = REGEXP_REPLACE(serialized, '#{old}', '#{new}')- WHERE serialized LIKE '%#{old}%'- SQL- end-- def primary_key_index_name(table_name)- connection = ActiveRecord::Base.connection- table = connection.quote table_name- sql = "SELECT indexname FROM pg_indexes WHERE tablename = #{table} AND indexdef LIKE '%(id)';"-- connection.execute(sql).pluck("indexname").compact.first- end-enddiff --git a/modules/budgets/db/migrate/tables/budget_journals.rb b/modules/budgets/db/migrate/tables/budget_journals.rbnew file mode 100644index 00000000000..f0399fc74d5--- /dev/null+++ b/modules/budgets/db/migrate/tables/budget_journals.rb@@ -0,0 +1,43 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::BudgetJournals < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.bigint :project_id, null: false+ t.bigint :author_id, null: false+ t.string :subject, null: false+ t.text :description+ t.date :fixed_date, null: false+ end+ end+enddiff --git a/modules/budgets/db/migrate/tables/budgets.rb b/modules/budgets/db/migrate/tables/budgets.rbnew file mode 100644index 00000000000..63431f0e6c8--- /dev/null+++ b/modules/budgets/db/migrate/tables/budgets.rb@@ -0,0 +1,46 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::Budgets < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.bigint :project_id, null: false+ t.bigint :author_id, null: false+ t.string :subject, null: false+ t.text :description, null: false+ t.date :fixed_date, null: false+ t.timestamps precision: nil, null: true++ t.index %i[project_id updated_at]+ end+ end+enddiff --git a/modules/budgets/db/migrate/tables/labor_budget_items.rb b/modules/budgets/db/migrate/tables/labor_budget_items.rbnew file mode 100644index 00000000000..fc51dc24e8d--- /dev/null+++ b/modules/budgets/db/migrate/tables/labor_budget_items.rb@@ -0,0 +1,43 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::LaborBudgetItems < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.bigint :budget_id, null: false+ t.float :hours, null: false+ t.bigint :user_id+ t.string :comments, default: "", null: false+ t.decimal :amount, precision: 15, scale: 4+ end+ end+enddiff --git a/modules/budgets/db/migrate/tables/material_budget_items.rb b/modules/budgets/db/migrate/tables/material_budget_items.rbnew file mode 100644index 00000000000..a2911e9227e--- /dev/null+++ b/modules/budgets/db/migrate/tables/material_budget_items.rb@@ -0,0 +1,43 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::MaterialBudgetItems < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.bigint :budget_id, null: false+ t.float :units, null: false+ t.bigint :cost_type_id+ t.string :comments, default: "", null: false+ t.decimal :amount, precision: 15, scale: 4+ end+ end+enddiff --git a/modules/storages/db/migrate/20220113144323_create_storage.rb b/modules/calendar/db/migrate/1007015_aggregated_calendar_migrations.rbsimilarity index 75%rename from modules/storages/db/migrate/20220113144323_create_storage.rbrename to modules/calendar/db/migrate/1007015_aggregated_calendar_migrations.rbindex 7a700f33bc7..0247ae7d7b7 100644--- a/modules/storages/db/migrate/20220113144323_create_storage.rb+++ b/modules/calendar/db/migrate/1007015_aggregated_calendar_migrations.rb@@ -28,15 +28,15 @@# See COPYRIGHT and LICENSE files for more details.#++-class CreateStorage < ActiveRecord::Migration[6.1]- def change- create_table :storages do |t|- t.string :provider_type, null: false- t.string :name, null: false, index: { unique: true }- t.string :host, null: false, index: { unique: true }- t.references :creator, null: false, index: true, foreign_key: { to_table: :users }+require Rails.root.join("db/migrate/migration_utils/squashed_migration").to_s+require_relative "tables/ical_token_query_assignments"- t.timestamps- end- end+class AggregatedCalendarMigrations < SquashedMigration+ squashed_migrations *%w[+ 20230421154500_ical_token_query_assignment+ 20230502094813_add_name_to_ical_tokens+ 20230607101213_populate_share_calendar_role_permission+ ]++ tables Tables::IcalTokenQueryAssignmentsenddiff --git a/modules/calendar/db/migrate/20230421154500_ical_token_query_assignment.rb b/modules/calendar/db/migrate/20230421154500_ical_token_query_assignment.rbdeleted file mode 100644index a5c15c75d16..00000000000--- a/modules/calendar/db/migrate/20230421154500_ical_token_query_assignment.rb+++ /dev/null@@ -1,10 +0,0 @@-class ICalTokenQueryAssignment < ActiveRecord::Migration[7.0]- def change- create_table :ical_token_query_assignments do |t|- t.references :ical_token, foreign_key: { to_table: :tokens, on_delete: :cascade }- t.references :query, foreign_key: { on_delete: :cascade }-- t.timestamps- end- end-enddiff --git a/modules/calendar/db/migrate/20230502094813_add_name_to_ical_tokens.rb b/modules/calendar/db/migrate/20230502094813_add_name_to_ical_tokens.rbdeleted file mode 100644index 132191cac71..00000000000--- a/modules/calendar/db/migrate/20230502094813_add_name_to_ical_tokens.rb+++ /dev/null@@ -1,15 +0,0 @@-class AddNameToICalTokens < ActiveRecord::Migration[7.0]- def up- # Add column with default value to avoid null values for existing records in preview environment- add_column :ical_token_query_assignments, :name, :string, null: false, default: "Not provided in earlier version"- # Remove default value after migration and applying it to existing records- change_column_default :ical_token_query_assignments, :name, nil- end-- def down- remove_column :ical_token_query_assignments, :name- # Remove all ical tokens as they have been created with a name before and- # are not intended to be used without a name- Token::ICal.delete_all- end-enddiff --git a/modules/calendar/db/migrate/20230607101213_populate_share_calendar_role_permission.rb b/modules/calendar/db/migrate/20230607101213_populate_share_calendar_role_permission.rbdeleted file mode 100644index 2ddd257c7c2..00000000000--- a/modules/calendar/db/migrate/20230607101213_populate_share_calendar_role_permission.rb+++ /dev/null@@ -1,16 +0,0 @@-require Rails.root.join("db/migrate/migration_utils/permission_adder")--class PopulateShareCalendarRolePermission < ActiveRecord::Migration[7.0]- def up- # From https://community.openproject.org/projects/openproject/work_packages/15339/activity- # -> For the migration path, all the roles that has the setting "View calendars" active will- # also by default have "Subscribe to iCalendars" active- ::Migration::MigrationUtils::PermissionAdder- .add(:view_calendar,- :share_calendars)- end-- def down- # nothing to do- end-enddiff --git a/modules/calendar/db/migrate/tables/ical_token_query_assignments.rb b/modules/calendar/db/migrate/tables/ical_token_query_assignments.rbnew file mode 100644index 00000000000..aa0ad829d2b--- /dev/null+++ b/modules/calendar/db/migrate/tables/ical_token_query_assignments.rb@@ -0,0 +1,42 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::IcalTokenQueryAssignments < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.references :ical_token, foreign_key: { to_table: :tokens, on_delete: :cascade }+ t.references :query, foreign_key: { on_delete: :cascade }+ t.timestamps+ t.string :name, null: false, default: nil+ end+ end+enddiff --git a/db/migrate/20230808140921_add_derived_remaining_hours_to_work_packages.rb b/modules/costs/db/migrate/1009015_aggregated_costs_migrations.rbsimilarity index 52%rename from db/migrate/20230808140921_add_derived_remaining_hours_to_work_packages.rbrename to modules/costs/db/migrate/1009015_aggregated_costs_migrations.rbindex a3b434ebf06..921b5e0fd92 100644--- a/db/migrate/20230808140921_add_derived_remaining_hours_to_work_packages.rb+++ b/modules/costs/db/migrate/1009015_aggregated_costs_migrations.rb@@ -28,37 +28,32 @@# See COPYRIGHT and LICENSE files for more details.#++-class AddDerivedRemainingHoursToWorkPackages < ActiveRecord::Migration[7.0]- def change- add_column :work_packages, :derived_remaining_hours, :float- add_column :work_package_journals, :derived_remaining_hours, :float-- reversible do |change|- change.up do- migrate_to_derived_remaining_hours!- end-- change.down do- rollback_from_derived_remaining_hours!- end- end- end-- def work_packages_to_update- WorkPackage.where.not(id: WorkPackage.leaves)- end-- def migrate_to_derived_remaining_hours!- scope = work_packages_to_update- .where.not(remaining_hours: nil)- scope.update_all("derived_remaining_hours = remaining_hours, remaining_hours = NULL")- end-- def journal_user = SystemUser.first-- def rollback_from_derived_remaining_hours!- scope = work_packages_to_update- .where.not(derived_remaining_hours: nil)- scope.update_all("remaining_hours = derived_remaining_hours")- end+require Rails.root.join("db/migrate/migration_utils/squashed_migration").to_s+require_relative "tables/cost_entries"+require_relative "tables/cost_types"+require_relative "tables/rates"+require_relative "tables/time_entries"+require_relative "tables/time_entry_activities_projects"+require_relative "tables/time_entry_journals"++class AggregatedCostsMigrations < SquashedMigration+ squashed_migrations *%w[+ 20180323133404_to_v710_aggregated_costs_migrations+ 20200327074416_rename_fixed_version_in_cost_query+ 20200807083952_rename_time_and_cost_module+ 20210726065912_rename_cost_object_type+ 20201001184404_rename_timestamp_on_time_and_cost_entry+ 20220608213712_add_logged_by_id_to_time_entries+ 20220707192304_backfill_time_entries_with_logged_by_id+ 20220815072420_add_logged_by_to_time_entries_journals+ 20221018160449_add_logged_by_to_cost_entries+ 20230622074222_add_ongoing_to_time_entry+ ].freeze++ tables Tables::CostEntries,+ Tables::CostTypes,+ Tables::Rates,+ Tables::TimeEntries,+ Tables::TimeEntryActivitiesProjects,+ Tables::TimeEntryJournalsenddiff --git a/modules/costs/db/migrate/20180323133404_to_v710_aggregated_costs_migrations.rb b/modules/costs/db/migrate/20180323133404_to_v710_aggregated_costs_migrations.rbdeleted file mode 100644index 72426426ac6..00000000000--- a/modules/costs/db/migrate/20180323133404_to_v710_aggregated_costs_migrations.rb+++ /dev/null@@ -1,170 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require Rails.root.join("db/migrate/migration_utils/migration_squasher").to_s-# This migration aggregates the migrations detailed in MIGRATION_FILES-class ToV710AggregatedCostsMigrations < ActiveRecord::Migration[5.1]- MIGRATION_FILES = <<-MIGRATIONS- 20121022124254_aggregated_costs_migrations.rb- 20130529145329_remove_signoff_from_cost_objects.rb- 20130625094710_add_costs_column_to_work_package.rb- 20130916094369_legacy_issues_costs_data_to_work_packages.rb- 20130918084158_add_cost_object_journals.rb- 20130918084919_add_cost_object_id_to_work_package_journals.rb- 20130918160542_add_journal_columns_to_time_entry_journals.rb- 20130918180542_legacy_variable_cost_object_journal_data.rb- 20160504070128_add_index_for_latest_cost_activity.rb- MIGRATIONS-- def up- Migration::MigrationSquasher.squash(migrations) do- create_table "cost_entries", id: :integer do |t|- t.integer "user_id", null: false- t.integer "project_id", null: false- t.integer "work_package_id", null: false- t.integer "cost_type_id", null: false- t.float "units", null: false- t.date "spent_on", null: false- t.datetime "created_on", null: false- t.datetime "updated_on", null: false- t.string "comments", null: false- t.boolean "blocked", default: false, null: false- t.decimal "overridden_costs", precision: 15, scale: 4- t.decimal "costs", precision: 15, scale: 4- t.integer "rate_id"- t.integer "tyear", null: false- t.integer "tmonth", null: false- t.integer "tweek", null: false- end-- create_table "cost_objects", id: :integer do |t|- t.integer "project_id", null: false- t.integer "author_id", null: false- t.string "subject", null: false- t.text "description", null: false- t.string "type", null: false- t.date "fixed_date", null: false- t.datetime "created_on"- t.datetime "updated_on"- end-- add_index :cost_objects, %i[project_id updated_on]-- create_table "cost_types", id: :integer do |t|- t.string "name", null: false- t.string "unit", null: false- t.string "unit_plural", null: false- t.boolean "default", default: false, null: false- t.datetime "deleted_at"- end-- create_table "labor_budget_items", id: :integer do |t|- t.integer "cost_object_id", null: false- t.float "hours", null: false- t.integer "user_id"- t.string "comments", default: "", null: false- t.decimal "budget", precision: 15, scale: 4- end-- create_table "material_budget_items", id: :integer do |t|- t.integer "cost_object_id", null: false- t.float "units", null: false- t.integer "cost_type_id"- t.string "comments", default: "", null: false- t.decimal "budget", precision: 15, scale: 4- end-- create_table "rates", id: :integer do |t|- t.date "valid_from", null: false- t.decimal "rate", precision: 15, scale: 4, null: false- t.string "type", null: false- t.integer "project_id"- t.integer "user_id"- t.integer "cost_type_id"- end-- change_table "time_entries", id: :integer do |t|- t.decimal "overridden_costs", precision: 15, scale: 4- t.decimal "costs", precision: 15, scale: 4- t.integer "rate_id"- end-- create_table :cost_object_journals, id: :integer do |t|- t.integer :journal_id, null: false- t.integer :project_id, null: false- t.integer :author_id, null: false- t.string :subject, null: false- t.text :description- t.date :fixed_date, null: false- t.datetime :created_on- end-- add_column :work_packages, :cost_object_id, :integer- add_column :work_package_journals, :cost_object_id, :integer, null: true-- add_column :time_entry_journals, :overridden_costs, :decimal, precision: 15, scale: 2, null: true- add_column :time_entry_journals, :costs, :decimal, precision: 15, scale: 2, null: true- add_column :time_entry_journals, :rate_id, :integer-- TimeEntry.reset_column_information- end- end-- def down- drop_table "cost_entries"- drop_table "cost_objects"- drop_table "cost_types"- drop_table "labor_budget_items"- drop_table "material_budget_items"- drop_table "rates"- drop_table "cost_object_journals"-- change_table "time_entries" do |t|- t.remove_column "overridden_costs"- t.remove_column "costs"- t.remove_column "rate_id"- end-- remove_column :work_packages, :cost_object_id- remove_column :work_package_journals, :cost_object_id-- remove_column :time_entry_journals, :overridden_costs- remove_column :time_entry_journals, :costs- remove_column :time_entry_journals, :rate_id-- TimeEntry.reset_column_information- end-- def migrations- MIGRATION_FILES.split.map do |m|- m.gsub(/_.*\z/, "")- end- end-enddiff --git a/modules/costs/db/migrate/20200327074416_rename_fixed_version_in_cost_query.rb b/modules/costs/db/migrate/20200327074416_rename_fixed_version_in_cost_query.rbdeleted file mode 100644index 5005f7a2874..00000000000--- a/modules/costs/db/migrate/20200327074416_rename_fixed_version_in_cost_query.rb+++ /dev/null@@ -1,55 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RenameFixedVersionInCostQuery < ActiveRecord::Migration[6.0]- def up- rename_query_attributes("FixedVersion", "Version")- end-- def down- rename_query_attributes("Version", "FixedVersion")- end-- def rename_query_attributes(from, to)- ActiveRecord::Base.connection.exec_query(- <<-SQL.squish- UPDATE- cost_queries q_sink- SET- serialized = regexp_replace(q_source.serialized, '(\n- - )#{from}Id(\n)', '\\1#{to}Id\\2')- FROM- cost_queries q_source- WHERE- q_source.serialized LIKE '%#{from}%'- AND q_sink.id = q_source.id- SQL- )- end-enddiff --git a/modules/costs/db/migrate/20200807083952_rename_time_and_cost_module.rb b/modules/costs/db/migrate/20200807083952_rename_time_and_cost_module.rbdeleted file mode 100644index cfcef7ffdc9..00000000000--- a/modules/costs/db/migrate/20200807083952_rename_time_and_cost_module.rb+++ /dev/null@@ -1,60 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require Rails.root.join("db/migrate/migration_utils/module_renamer").to_s-require Rails.root.join("db/migrate/migration_utils/setting_renamer").to_s--class RenameTimeAndCostModule < ActiveRecord::Migration[6.0]- def up- module_renamer.add_to_enabled("costs", %w[time_tracking costs_module reporting_module])- module_renamer.remove_from_enabled(%w[time_tracking costs_module reporting_module])- module_renamer.add_to_default("costs", %w[time_tracking costs_module reporting_module])- setting_renamer.rename("plugin_costs", "plugin_costs")- end-- def down- # We do not know if all three where actually enabled but having them enabled will keep the functionality- module_renamer.add_to_enabled("time_tracking", "costs")- module_renamer.add_to_enabled("costs_module", "costs")- module_renamer.add_to_enabled("reporting_module", "costs")-- module_renamer.remove_from_enabled("costs")- module_renamer.add_to_default(%w[costs_module time_tracking reporting_module], "costs")- setting_renamer.rename("plugin_costs", "plugin_costs")- end-- def module_renamer- Migration::MigrationUtils::ModuleRenamer- end-- def setting_renamer- Migration::MigrationUtils::SettingRenamer- end-enddiff --git a/modules/costs/db/migrate/20210726065912_rename_cost_object_type.rb b/modules/costs/db/migrate/20210726065912_rename_cost_object_type.rbdeleted file mode 100644index 39fe0b604c9..00000000000--- a/modules/costs/db/migrate/20210726065912_rename_cost_object_type.rb+++ /dev/null@@ -1,66 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RenameCostObjectType < ActiveRecord::Migration[6.1]- def up- # Remove the index to allow duplicates for the time of the reordering.- # It is recreated right afterwards.- remove_index :journals, %i[journable_type journable_id version]-- execute <<~SQL.squish- UPDATE- journals- SET- version = version + max_journal.max_version- FROM- (SELECT- journable_id, MAX(version) max_version- FROM- journals- WHERE- journable_type = 'CostObject'- GROUP BY journable_id) max_journal- WHERE- max_journal.journable_id = journals.journable_id- AND- journals.journable_type = 'Budget'- SQL-- add_index :journals, %i[journable_type journable_id version], unique: true-- Journal- .where(journable_type: "CostObject")- .update_all(journable_type: "Budget")- end-- def down- # Doesn't need to be reverted- end-enddiff --git a/modules/costs/db/migrate/20230622074222_add_ongoing_to_time_entry.rb b/modules/costs/db/migrate/20230622074222_add_ongoing_to_time_entry.rbdeleted file mode 100644index 6744a477336..00000000000--- a/modules/costs/db/migrate/20230622074222_add_ongoing_to_time_entry.rb+++ /dev/null@@ -1,45 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddOngoingToTimeEntry < ActiveRecord::Migration[7.0]- def change- change_table :time_entries do |t|- t.boolean :ongoing, null: false, default: false, index: true- end-- add_index :time_entries, %i[user_id ongoing], unique: true, where: "ongoing = true"-- change_column_null :time_entries, :activity_id, true- change_column_null :time_entries, :hours, true-- change_column_null :time_entry_journals, :activity_id, true- change_column_null :time_entry_journals, :hours, true- end-enddiff --git a/spec/migrations/remove_hide_mail_from_user_preferences_spec.rb b/modules/costs/db/migrate/tables/cost_entries.rbsimilarity index 57%rename from spec/migrations/remove_hide_mail_from_user_preferences_spec.rbrename to modules/costs/db/migrate/tables/cost_entries.rbindex 0f5e07732d7..a1a942764be 100644--- a/spec/migrations/remove_hide_mail_from_user_preferences_spec.rb+++ b/modules/costs/db/migrate/tables/cost_entries.rb@@ -28,36 +28,27 @@# See COPYRIGHT and LICENSE files for more details.# ++-require "spec_helper"-require Rails.root.join("db/migrate/20241002151949_remove_hide_mail_from_user_preferences.rb")+require Rails.root.join("db/migrate/tables/base").to_s-RSpec.describe RemoveHideMailFromUserPreferences, type: :model do- # Silencing migration logs, since we are not interested in that during testing- subject(:run_migration) do- perform_enqueued_jobs do- ActiveRecord::Migration.suppress_messages { described_class.new.up }- end- end-- context "when hide_mail user preference exists" do- before do- create(:user_preference, settings: { hide_mail: true, other: "setting" })- end-- it "removes the flag" do- run_migration- expect(UserPreference.first.settings).to eq({ "other" => "setting" })- end- end-- context "when hide_mail user preference does not exists" do- before do- create(:user_preference, settings: { other: "setting" })- end-- it "does nothing" do- run_migration- expect(UserPreference.first.settings).to eq({ "other" => "setting" })+class Tables::CostEntries < Tables::Base+ def self.table(migration) # rubocop:disable Metrics/AbcSize+ create_table migration do |t|+ t.bigint :user_id, null: false+ t.bigint :project_id, null: false+ t.bigint :work_package_id, null: false+ t.bigint :cost_type_id, null: false+ t.float :units, null: false+ t.date :spent_on, null: false+ t.timestamps precision: nil, default: -> { "CURRENT_TIMESTAMP" }+ t.string :comments, null: false+ t.boolean :blocked, default: false, null: false+ t.decimal :overridden_costs, precision: 15, scale: 4+ t.decimal :costs, precision: 15, scale: 4+ t.bigint :rate_id+ t.integer :tyear, null: false+ t.integer :tmonth, null: false+ t.integer :tweek, null: false+ t.references :logged_by, foreign_key: { to_table: :users }, index: trueendendenddiff --git a/modules/costs/db/migrate/tables/cost_types.rb b/modules/costs/db/migrate/tables/cost_types.rbnew file mode 100644index 00000000000..55a3dd51bff--- /dev/null+++ b/modules/costs/db/migrate/tables/cost_types.rb@@ -0,0 +1,43 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::CostTypes < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.string :name, null: false+ t.string :unit, null: false+ t.string :unit_plural, null: false+ t.boolean :default, default: false, null: false+ t.datetime :deleted_at, precision: nil+ end+ end+enddiff --git a/modules/costs/db/migrate/tables/rates.rb b/modules/costs/db/migrate/tables/rates.rbnew file mode 100644index 00000000000..d3d6e7475af--- /dev/null+++ b/modules/costs/db/migrate/tables/rates.rb@@ -0,0 +1,44 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::Rates < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.date :valid_from, null: false+ t.decimal :rate, precision: 15, scale: 4, null: false+ t.string :type, null: false+ t.bigint :project_id+ t.bigint :user_id+ t.bigint :cost_type_id+ end+ end+enddiff --git a/db/migrate/tables/time_entries.rb b/modules/costs/db/migrate/tables/time_entries.rbsimilarity index 65%rename from db/migrate/tables/time_entries.rbrename to modules/costs/db/migrate/tables/time_entries.rbindex e06f6070813..e59215a4e39 100644--- a/db/migrate/tables/time_entries.rb+++ b/modules/costs/db/migrate/tables/time_entries.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,34 +26,37 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++-require_relative "base"+require Rails.root.join("db/migrate/tables/base").to_sclass Tables::TimeEntries < Tables::Base- # rubocop:disable Metrics/AbcSize- def self.table(migration)+ def self.table(migration) # rubocop:disable Metrics/AbcSizecreate_table migration do |t|- t.integer :project_id, null: false- t.integer :user_id, null: false- t.belongs_to :work_package, type: :int, index: false- t.float :hours, null: false+ t.bigint :project_id, null: false+ t.bigint :user_id, null: false+ t.belongs_to :work_package, index: false+ t.float :hours, null: truet.string :comments- t.integer :activity_id, null: false+ t.bigint :activity_id, null: truet.date :spent_on, null: falset.integer :tyear, null: falset.integer :tmonth, null: falset.integer :tweek, null: false- t.datetime :created_on, null: false- t.datetime :updated_on, null: false+ t.timestamps precision: nil, default: -> { "CURRENT_TIMESTAMP" }+ t.decimal :overridden_costs, precision: 15, scale: 4+ t.decimal :costs, precision: 15, scale: 4+ t.bigint :rate_id+ t.references :logged_by, foreign_key: { to_table: :users }, index: true, null: false+ t.boolean :ongoing, null: false, default: false, index: truet.index :activity_id, name: "index_time_entries_on_activity_id"- t.index :created_on, name: "index_time_entries_on_created_on"+ t.index :created_at, name: "index_time_entries_on_created_at"t.index :work_package_id, name: "time_entries_issue_id" # issue_id for backwards compatibilityt.index :project_id, name: "time_entries_project_id"t.index :user_id, name: "index_time_entries_on_user_id"- t.index %i[project_id updated_on]+ t.index %i[project_id updated_at]+ t.index %i[user_id ongoing], unique: true, where: "ongoing = true"endend- # rubocop:enable Metrics/AbcSizeenddiff --git a/modules/costs/db/migrate/tables/time_entry_activities_projects.rb b/modules/costs/db/migrate/tables/time_entry_activities_projects.rbnew file mode 100644index 00000000000..0629cfe3136--- /dev/null+++ b/modules/costs/db/migrate/tables/time_entry_activities_projects.rb@@ -0,0 +1,45 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::TimeEntryActivitiesProjects < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.references :activity, null: false, foreign_key: { to_table: :enumerations }, index: true+ t.references :project, null: false, foreign_key: true, index: true+ t.boolean :active, default: true, index: true++ t.index %i[project_id activity_id],+ unique: true,+ name: "index_teap_on_project_id_and_activity_id"+ end+ end+enddiff --git a/db/migrate/tables/time_entry_journals.rb b/modules/costs/db/migrate/tables/time_entry_journals.rbsimilarity index 71%rename from db/migrate/tables/time_entry_journals.rbrename to modules/costs/db/migrate/tables/time_entry_journals.rbindex f9ea48ee4fa..41776843182 100644--- a/db/migrate/tables/time_entry_journals.rb+++ b/modules/costs/db/migrate/tables/time_entry_journals.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,26 +26,27 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++-require_relative "base"+require Rails.root.join("db/migrate/tables/base").to_sclass Tables::TimeEntryJournals < Tables::Basedef self.table(migration)create_table migration do |t|- t.integer :journal_id, null: false- t.integer :project_id, null: false- t.integer :user_id, null: false- t.integer :work_package_id- t.float :hours, null: false- t.string :comments- t.integer :activity_id, null: false+ t.bigint :project_id, null: false, index: true+ t.bigint :user_id, null: false+ t.bigint :work_package_id+ t.float :hours, null: true+ t.text :comments+ t.bigint :activity_id, null: truet.date :spent_on, null: falset.integer :tyear, null: falset.integer :tmonth, null: falset.integer :tweek, null: false-- t.index [:journal_id]+ t.decimal :overridden_costs, precision: 15, scale: 2, null: true+ t.decimal :costs, precision: 15, scale: 2, null: true+ t.bigint :rate_id+ t.references :logged_by, foreign_key: { to_table: :users }, index: true, null: falseendendenddiff --git a/db/migrate/20240306154734_create_good_job_labels.rb b/modules/documents/db/migrate/1012015_aggregated_documents_migrations.rbsimilarity index 75%rename from db/migrate/20240306154734_create_good_job_labels.rbrename to modules/documents/db/migrate/1012015_aggregated_documents_migrations.rbindex 7773d60e535..81343b8d828 100644--- a/db/migrate/20240306154734_create_good_job_labels.rb+++ b/modules/documents/db/migrate/1012015_aggregated_documents_migrations.rb@@ -28,16 +28,16 @@# See COPYRIGHT and LICENSE files for more details.#++-class CreateGoodJobLabels < ActiveRecord::Migration[7.1]- def change- reversible do |dir|- dir.up do- # Ensure this incremental update migration is idempotent- # with monolithic install migration.- return if connection.column_exists?(:good_jobs, :labels)- end- end+require Rails.root.join("db/migrate/migration_utils/squashed_migration").to_s+require_relative "tables/documents"+require_relative "tables/document_journals"- add_column :good_jobs, :labels, :text, array: true- end+class AggregatedDocumentsMigrations < SquashedMigration+ squashed_migrations *%w[+ 20180323140208_to_v710_aggregated_documents_migrations+ 20200217090016_document_timestamps+ ]++ tables Tables::Documents,+ Tables::DocumentJournalsenddiff --git a/modules/documents/db/migrate/20180323140208_to_v710_aggregated_documents_migrations.rb b/modules/documents/db/migrate/20180323140208_to_v710_aggregated_documents_migrations.rbdeleted file mode 100644index b7fbb7e3095..00000000000--- a/modules/documents/db/migrate/20180323140208_to_v710_aggregated_documents_migrations.rb+++ /dev/null@@ -1,76 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require Rails.root.join("db/migrate/migration_utils/migration_squasher").to_s-# This migration aggregates the migrations detailed in MIGRATION_FILES-class ToV710AggregatedDocumentsMigrations < ActiveRecord::Migration[5.1]- MIGRATION_FILES = <<-MIGRATIONS- 20130807085604_create_document_journals.rb- 20130814131242_create_documents_tables.rb- 20140320140001_legacy_document_journal_data.rb- MIGRATIONS-- def up- Migration::MigrationSquasher.squash(migrations) do- create_table "documents", id: :integer do |t|- t.integer "project_id", default: 0, null: false- t.integer "category_id", default: 0, null: false- t.string "title", limit: 60, default: "", null: false- t.text "description"- t.datetime "created_on"- end- add_index "documents", ["category_id"], name: "index_documents_on_category_id"- add_index "documents", ["created_on"], name: "index_documents_on_created_on"- add_index "documents", ["project_id"], name: "documents_project_id"-- create_table :document_journals, id: :integer do |t|- t.integer :journal_id, null: false- t.integer :project_id, default: 0, null: false- t.integer :category_id, default: 0, null: false- t.string :title, limit: 60, default: "", null: false- t.text :description- t.datetime :created_on- end- end- end-- def down- drop_table :documents- drop_table :document_journals- end-- private-- def migrations- MIGRATION_FILES.split.map do |m|- m.gsub(/_.*\z/, "")- end- end-enddiff --git a/modules/documents/db/migrate/tables/document_journals.rb b/modules/documents/db/migrate/tables/document_journals.rbnew file mode 100644index 00000000000..f7e47c0bf1c--- /dev/null+++ b/modules/documents/db/migrate/tables/document_journals.rb@@ -0,0 +1,42 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::DocumentJournals < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.bigint :project_id, null: false+ t.bigint :category_id, null: false+ t.string :title, limit: 60, default: nil, null: false+ t.text :description+ end+ end+enddiff --git a/modules/documents/db/migrate/tables/documents.rb b/modules/documents/db/migrate/tables/documents.rbnew file mode 100644index 00000000000..e54d9a97496--- /dev/null+++ b/modules/documents/db/migrate/tables/documents.rb@@ -0,0 +1,44 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::Documents < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.bigint :project_id, null: false, index: { name: "documents_project_id" }+ t.bigint :category_id, null: false, index: { name: "index_documents_on_category_id" }+ t.string :title, limit: 60, default: "", null: false+ t.text :description+ t.datetime :created_at, precision: nil, index: { name: "index_documents_on_created_at" }+ t.datetime :updated_at, precision: nil+ end+ end+enddiff --git a/modules/gantt/db/migrate/1022015_aggregated_gantt_migrations.rb b/modules/gantt/db/migrate/1022015_aggregated_gantt_migrations.rbnew file mode 100644index 00000000000..dbf9506404f--- /dev/null+++ b/modules/gantt/db/migrate/1022015_aggregated_gantt_migrations.rb@@ -0,0 +1,40 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/migration_utils/squashed_migration").to_s++class AggregatedGanttMigrations < SquashedMigration+ squashed_migrations *%w[+ 20231201085450_change_view_of_queries_with_timeline_to_gantt+ 20240131130149_enable_gantt_module_for_all_projects+ 20240201115019_add_gantt_module_to_default_modules+ 20240930122522_change_view_of_queries_with_timeline_to_gantt_again+ ]+enddiff --git a/modules/gantt/spec/migrations/change_view_of_queries_with_timeline_to_gantt_spec.rb b/modules/gantt/spec/migrations/change_view_of_queries_with_timeline_to_gantt_spec.rbdeleted file mode 100644index 54f065a69f9..00000000000--- a/modules/gantt/spec/migrations/change_view_of_queries_with_timeline_to_gantt_spec.rb+++ /dev/null@@ -1,95 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require "spec_helper"-require Rails.root.join("db/migrate/20231201085450_change_view_of_queries_with_timeline_to_gantt.rb")--RSpec.describe ChangeViewOfQueriesWithTimelineToGantt, type: :model do- let!(:wp_query_with_timeline) do- query = create(:query_with_view_work_packages_table)- query.timeline_visible = true-- query.save!- query- end-- let!(:wp_query_without_timeline) do- query = create(:query_with_view_work_packages_table)- query.timeline_visible = false-- query.save!- query- end-- let!(:calendar_query) do- query = create(:query_with_view_work_packages_calendar)- # Doesn't make sense in the calendar but should not be migrated nevertheless- query.timeline_visible = true-- query.save!- query- end-- context "when migrating up" do- # Silencing migration logs, since we are not interested in that during testing- subject { ActiveRecord::Migration.suppress_messages { described_class.new.up } }-- it "changes the view type for (work package table) queries with enabled timeline" do- expect { subject }- .to change { View.where(query_id: wp_query_with_timeline.id).first.type }.from("work_packages_table").to("gantt")- expect { subject }- .not_to change { View.where(query_id: wp_query_without_timeline.id).first.type }- expect { subject }- .not_to change { View.where(query_id: calendar_query.id).first.type }- end- end-- context "when migrating down" do- let!(:gantt_query) do- query = create(:query_with_view_gantt)- query.timeline_visible = true-- query.save!- query- end-- # Silencing migration logs, since we are not interested in that during testing- subject { ActiveRecord::Migration.suppress_messages { described_class.new.down } }-- it "changes the view type for (gantt table) queries" do- expect { subject }- .to change { View.where(query_id: gantt_query.id).first.type }.from("gantt").to("work_packages_table")- expect { subject }- .not_to change { View.where(query_id: wp_query_with_timeline.id).first.type }- expect { subject }- .not_to change { View.where(query_id: wp_query_without_timeline.id).first.type }- expect { subject }- .not_to change { View.where(query_id: calendar_query.id).first.type }- end- end-enddiff --git a/modules/github_integration/db/migrate/1014015_aggregated_github_migrations.rb b/modules/github_integration/db/migrate/1014015_aggregated_github_migrations.rbnew file mode 100644index 00000000000..9e76404158f--- /dev/null+++ b/modules/github_integration/db/migrate/1014015_aggregated_github_migrations.rb@@ -0,0 +1,86 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/migration_utils/migration_squasher").to_s+# This migration aggregates the migrations detailed in MIGRATION_FILES+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++require Rails.root.join("db/migrate/migration_utils/squashed_migration").to_s+require_relative "tables/github_pull_requests"+require_relative "tables/github_pull_requests_work_packages"+require_relative "tables/github_users"+require_relative "tables/github_check_runs"+require_relative "tables/deploy_targets"+require_relative "tables/deploy_status_checks"++class AggregatedGithubMigrations < SquashedMigration+ squashed_migrations *%w[+ 20210407110000_github_integration_models+ 20230316080525_add_repository_html_url+ 20240501083852_create_deploy_targets+ 20240501093751_create_deploy_status_checks+ 20240502081436_add_merge_commit_sha_to_github_pull_requests+ ]++ tables Tables::GithubPullRequests,+ Tables::GithubPullRequestsWorkPackages,+ Tables::GithubUsers,+ Tables::GithubCheckRuns,+ Tables::DeployTargets,+ Tables::DeployStatusChecks+enddiff --git a/modules/github_integration/db/migrate/20210407110000_github_integration_models.rb b/modules/github_integration/db/migrate/20210407110000_github_integration_models.rbdeleted file mode 100644index eb7caaf2104..00000000000--- a/modules/github_integration/db/migrate/20210407110000_github_integration_models.rb+++ /dev/null@@ -1,95 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class GithubIntegrationModels < ActiveRecord::Migration[6.1]- # rubocop:disable Metrics/AbcSize- def change- # see https://docs.github.com/en/rest/reference/pulls- create_table :github_pull_requests do |t|- t.references :github_user- t.references :merged_by-- t.bigint :github_id, unique: true # may be null if we receive a comment and just know the html_url- t.integer :number, null: false- t.string :github_html_url, null: false, unique: true- t.string :state, null: false- t.string :repository, null: false- t.datetime :github_updated_at- t.string :title- t.text :body- t.boolean :draft- t.boolean :merged- t.datetime :merged_at- t.integer :comments_count- t.integer :review_comments_count- t.integer :additions_count- t.integer :deletions_count- t.integer :changed_files_count- t.json :labels # [{name, color}]- t.timestamps- end-- create_join_table :github_pull_requests, :work_packages do |t|- t.index :github_pull_request_id, name: "github_pr_wp_pr_id"- t.index %i[github_pull_request_id work_package_id],- unique: true,- name: "unique_index_gh_prs_wps_on_gh_pr_id_and_wp_id"- end-- # see: https://docs.github.com/en/rest/reference/users- create_table :github_users do |t|- t.bigint :github_id, null: false, unique: true- t.string :github_login, null: false- t.string :github_html_url, null: false- t.string :github_avatar_url, null: false-- t.timestamps- end-- # see: https://docs.github.com/en/rest/reference/checks- create_table :github_check_runs do |t|- t.references :github_pull_request, null: false-- t.bigint :github_id, null: false, unique: true- t.string :github_html_url, null: false- t.bigint :app_id, null: false- t.string :github_app_owner_avatar_url, null: false- t.string :status, null: false- t.string :name, null: false- t.string :conclusion- t.string :output_title- t.string :output_summary- t.string :details_url- t.datetime :started_at- t.datetime :completed_at-- t.timestamps- end- end- # rubocop:enable Metrics/AbcSize-enddiff --git a/modules/github_integration/db/migrate/20230316080525_add_repository_html_url.rb b/modules/github_integration/db/migrate/20230316080525_add_repository_html_url.rbdeleted file mode 100644index 912ae586822..00000000000--- a/modules/github_integration/db/migrate/20230316080525_add_repository_html_url.rb+++ /dev/null@@ -1,43 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddRepositoryHtmlUrl < ActiveRecord::Migration[7.0]- def change- change_table :github_pull_requests, bulk: true do |t|- t.string :repository_html_url- end-- execute <<~SQL.squish- UPDATE github_pull_requests- SET repository_html_url = CONCAT(- substring(github_html_url from 0 for position(repository IN github_html_url)),- repository- )- SQL- end-enddiff --git a/modules/github_integration/db/migrate/20240501083852_create_deploy_targets.rb b/modules/github_integration/db/migrate/20240501083852_create_deploy_targets.rbdeleted file mode 100644index 782e976724b..00000000000--- a/modules/github_integration/db/migrate/20240501083852_create_deploy_targets.rb+++ /dev/null@@ -1,13 +0,0 @@-class CreateDeployTargets < ActiveRecord::Migration[7.1]- def change- create_table :deploy_targets do |t|- t.text :type, null: false- t.text :host, null: false- t.jsonb :options, null: false, default: {}-- t.timestamps- end-- add_index :deploy_targets, :host, unique: true- end-enddiff --git a/modules/github_integration/db/migrate/20240501093751_create_deploy_status_checks.rb b/modules/github_integration/db/migrate/20240501093751_create_deploy_status_checks.rbdeleted file mode 100644index 2881a758cde..00000000000--- a/modules/github_integration/db/migrate/20240501093751_create_deploy_status_checks.rb+++ /dev/null@@ -1,12 +0,0 @@-class CreateDeployStatusChecks < ActiveRecord::Migration[7.1]- def change- create_table :deploy_status_checks do |t|- t.references :deploy_target- t.references :github_pull_request-- t.text :core_sha, null: false-- t.timestamps- end- end-enddiff --git a/modules/github_integration/db/migrate/20240502081436_add_merge_commit_sha_to_github_pull_requests.rb b/modules/github_integration/db/migrate/20240502081436_add_merge_commit_sha_to_github_pull_requests.rbdeleted file mode 100644index 5ae78152b88..00000000000--- a/modules/github_integration/db/migrate/20240502081436_add_merge_commit_sha_to_github_pull_requests.rb+++ /dev/null@@ -1,5 +0,0 @@-class AddMergeCommitShaToGithubPullRequests < ActiveRecord::Migration[7.1]- def change- add_column :github_pull_requests, :merge_commit_sha, :text- end-enddiff --git a/modules/github_integration/db/migrate/tables/deploy_status_checks.rb b/modules/github_integration/db/migrate/tables/deploy_status_checks.rbnew file mode 100644index 00000000000..b52a043f105--- /dev/null+++ b/modules/github_integration/db/migrate/tables/deploy_status_checks.rb@@ -0,0 +1,44 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::DeployStatusChecks < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.references :deploy_target+ t.references :github_pull_request++ t.text :core_sha, null: false++ t.timestamps+ end+ end+enddiff --git a/modules/github_integration/db/migrate/tables/deploy_targets.rb b/modules/github_integration/db/migrate/tables/deploy_targets.rbnew file mode 100644index 00000000000..947e03ea479--- /dev/null+++ b/modules/github_integration/db/migrate/tables/deploy_targets.rb@@ -0,0 +1,43 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::DeployTargets < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.text :type, null: false+ t.text :host, null: false, index: { unique: true }+ t.jsonb :options, null: false, default: {}++ t.timestamps+ end+ end+enddiff --git a/modules/github_integration/db/migrate/tables/github_check_runs.rb b/modules/github_integration/db/migrate/tables/github_check_runs.rbnew file mode 100644index 00000000000..ca4960c2e76--- /dev/null+++ b/modules/github_integration/db/migrate/tables/github_check_runs.rb@@ -0,0 +1,54 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::GithubCheckRuns < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.references :github_pull_request, null: false++ t.bigint :github_id, null: false+ t.string :github_html_url, null: false+ t.bigint :app_id, null: false+ t.string :github_app_owner_avatar_url, null: false+ t.string :status, null: false+ t.string :name, null: false+ t.string :conclusion+ t.string :output_title+ t.string :output_summary+ t.string :details_url+ t.datetime :started_at, precision: nil+ t.datetime :completed_at, precision: nil++ t.timestamps precision: nil+ end+ end+enddiff --git a/modules/github_integration/db/migrate/tables/github_pull_requests.rb b/modules/github_integration/db/migrate/tables/github_pull_requests.rbnew file mode 100644index 00000000000..7881adbc7c3--- /dev/null+++ b/modules/github_integration/db/migrate/tables/github_pull_requests.rb@@ -0,0 +1,61 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::GithubPullRequests < Tables::Base+ def self.table(migration) # rubocop:disable Metrics/AbcSize+ create_table migration do |t|+ t.references :github_user+ t.references :merged_by++ t.bigint :github_id # may be null if we receive a comment and just know the html_url+ t.integer :number, null: false+ t.string :github_html_url, null: false+ t.string :state, null: false+ t.string :repository, null: false+ t.datetime :github_updated_at, precision: nil+ t.string :title+ t.text :body+ t.boolean :draft+ t.boolean :merged+ t.datetime :merged_at, precision: nil+ t.integer :comments_count+ t.integer :review_comments_count+ t.integer :additions_count+ t.integer :deletions_count+ t.integer :changed_files_count+ t.json :labels # [{name, color}]+ t.timestamps precision: nil+ t.string :repository_html_url+ t.text :merge_commit_sha+ end+ end+enddiff --git a/modules/documents/db/migrate/20200217090016_document_timestamps.rb b/modules/github_integration/db/migrate/tables/github_pull_requests_work_packages.rbsimilarity index 74%rename from modules/documents/db/migrate/20200217090016_document_timestamps.rbrename to modules/github_integration/db/migrate/tables/github_pull_requests_work_packages.rbindex 639d26d9acd..cd274d8e938 100644--- a/modules/documents/db/migrate/20200217090016_document_timestamps.rb+++ b/modules/github_integration/db/migrate/tables/github_pull_requests_work_packages.rb@@ -28,15 +28,15 @@# See COPYRIGHT and LICENSE files for more details.#++-class DocumentTimestamps < ActiveRecord::Migration[6.0]- def change- add_column :documents, :updated_at, :datetime- rename_column :documents, :created_on, :created_at- # We do not need the timestamp on the data table, as we already have it on the journals table.- remove_column :document_journals, :created_on, :datetime+require Rails.root.join("db/migrate/tables/base").to_s- reversible do |change|- change.up { Document.update_all("updated_at = created_at") }+class Tables::GithubPullRequestsWorkPackages < Tables::Base+ def self.table(migration)+ migration.create_join_table :github_pull_requests, :work_packages do |t|+ t.index :github_pull_request_id, name: "github_pr_wp_pr_id"+ t.index %i[github_pull_request_id work_package_id],+ unique: true,+ name: "unique_index_gh_prs_wps_on_gh_pr_id_and_wp_id"endendenddiff --git a/modules/github_integration/db/migrate/tables/github_users.rb b/modules/github_integration/db/migrate/tables/github_users.rbnew file mode 100644index 00000000000..2800126db2a--- /dev/null+++ b/modules/github_integration/db/migrate/tables/github_users.rb@@ -0,0 +1,44 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::GithubUsers < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.bigint :github_id, null: false+ t.string :github_login, null: false+ t.string :github_html_url, null: false+ t.string :github_avatar_url, null: false++ t.timestamps precision: nil+ end+ end+enddiff --git a/db/migrate/20240116165933_add_derived_done_ratio_to_work_packages.rb b/modules/gitlab_integration/db/migrate/1015015_aggregated_gitlab_migrations.rbsimilarity index 60%rename from db/migrate/20240116165933_add_derived_done_ratio_to_work_packages.rbrename to modules/gitlab_integration/db/migrate/1015015_aggregated_gitlab_migrations.rbindex 9179a27176d..ff87ad7f097 100644--- a/db/migrate/20240116165933_add_derived_done_ratio_to_work_packages.rb+++ b/modules/gitlab_integration/db/migrate/1015015_aggregated_gitlab_migrations.rb@@ -28,33 +28,25 @@# See COPYRIGHT and LICENSE files for more details.#++-class AddDerivedDoneRatioToWorkPackages < ActiveRecord::Migration[7.0]- def change- add_column :work_packages, :derived_done_ratio, :integer, default: 0- add_column :work_package_journals, :derived_done_ratio, :integer, default: 0+require Rails.root.join("db/migrate/migration_utils/squashed_migration").to_s+require_relative "tables/gitlab_merge_requests"+require_relative "tables/gitlab_users"+require_relative "tables/gitlab_pipelines"+require_relative "tables/gitlab_issues"+require_relative "tables/gitlab_merge_requests_work_packages"+require_relative "tables/gitlab_issues_work_packages"- reversible do |direction|- direction.up do- migrate_to_derived_done_ratio- end+class AggregatedGitlabMigrations < SquashedMigration+ squashed_migrations *%w[+ 20211015110000_gitlab_integration_models+ 20211015110001_add_username_commit_to_pipelines+ 20211015110002_add_gitlab_issues+ ]- direction.down do- rollback_from_derived_done_ratio- end- end- end-- def migrate_to_derived_done_ratio- non_leaf_work_packages- .update_all("derived_done_ratio = done_ratio, done_ratio = 0")- end-- def rollback_from_derived_done_ratio- non_leaf_work_packages- .update_all("done_ratio = derived_done_ratio")- end-- def non_leaf_work_packages- WorkPackage.where.not(id: WorkPackage.leaves)- end+ tables Tables::GitlabMergeRequests,+ Tables::GitlabUsers,+ Tables::GitlabPipelines,+ Tables::GitlabIssues,+ Tables::GitlabMergeRequestsWorkPackages,+ Tables::GitlabIssuesWorkPackagesenddiff --git a/modules/gitlab_integration/db/migrate/20211015110000_gitlab_integration_models.rb b/modules/gitlab_integration/db/migrate/20211015110000_gitlab_integration_models.rbdeleted file mode 100644index a3f998bb9c9..00000000000--- a/modules/gitlab_integration/db/migrate/20211015110000_gitlab_integration_models.rb+++ /dev/null@@ -1,87 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) 2023 Ben Tey-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See docs/COPYRIGHT.rdoc for more details.-#++-class GitlabIntegrationModels < ActiveRecord::Migration[6.1]- # rubocop:disable Metrics/AbcSize- def change- create_table :gitlab_merge_requests do |t|- t.references :gitlab_user- t.references :merged_by-- t.bigint :gitlab_id, unique: true- t.integer :number, null: false- t.string :gitlab_html_url, null: false, unique: true- t.string :state, null: false- t.string :repository, null: false- t.datetime :gitlab_updated_at- t.string :title- t.text :body- t.boolean :draft- t.boolean :merged- t.datetime :merged_at- t.json :labels # [{name, color}]-- t.timestamps- end-- create_join_table :gitlab_merge_requests, :work_packages do |t|- t.index :gitlab_merge_request_id, name: "gitlab_mr_wp_mr_id"- t.index %i[gitlab_merge_request_id work_package_id],- unique: true,- name: "unique_index_gl_mrs_wps_on_gl_mr_id_and_wp_id"- end-- create_table :gitlab_users do |t|- t.bigint :gitlab_id, null: false, unique: true- t.string :gitlab_name, null: false- t.string :gitlab_username, null: false- t.string :gitlab_email, null: false- t.string :gitlab_avatar_url, null: false-- t.timestamps- end-- create_table :gitlab_pipelines do |t|- t.references :gitlab_merge_request, null: false-- t.bigint :gitlab_id, null: false, unique: true- t.string :gitlab_html_url, null: false- t.bigint :project_id, null: false- t.string :gitlab_user_avatar_url, null: false- t.string :status, null: false- t.string :name, null: false- t.string :details_url- t.json :ci_details- t.datetime :started_at- t.datetime :completed_at-- t.timestamps- end- end- # rubocop:enable Metrics/AbcSize-enddiff --git a/modules/gitlab_integration/db/migrate/20211015110001_add_username_commit_to_pipelines.rb b/modules/gitlab_integration/db/migrate/20211015110001_add_username_commit_to_pipelines.rbdeleted file mode 100644index 45d439b20e8..00000000000--- a/modules/gitlab_integration/db/migrate/20211015110001_add_username_commit_to_pipelines.rb+++ /dev/null@@ -1,36 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) 2023 Ben Tey-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See docs/COPYRIGHT.rdoc for more details.-#++--class AddUsernameCommitToPipelines < ActiveRecord::Migration[7.0]- def change- add_column :gitlab_pipelines, :username, :text-- add_column :gitlab_pipelines, :commit_id, :text- end-enddiff --git a/modules/gitlab_integration/db/migrate/tables/gitlab_issues.rb b/modules/gitlab_integration/db/migrate/tables/gitlab_issues.rbnew file mode 100644index 00000000000..99c76c50ade--- /dev/null+++ b/modules/gitlab_integration/db/migrate/tables/gitlab_issues.rb@@ -0,0 +1,51 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::GitlabIssues < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.references :gitlab_user++ t.bigint :gitlab_id+ t.integer :number, null: false+ t.string :gitlab_html_url, null: false+ t.string :state, null: false+ t.string :repository, null: false+ t.datetime :gitlab_updated_at+ t.string :title+ t.text :body+ t.json :labels # [{name, color}]++ t.timestamps+ end+ end+enddiff --git a/modules/gitlab_integration/db/migrate/tables/gitlab_issues_work_packages.rb b/modules/gitlab_integration/db/migrate/tables/gitlab_issues_work_packages.rbnew file mode 100644index 00000000000..c92af478b51--- /dev/null+++ b/modules/gitlab_integration/db/migrate/tables/gitlab_issues_work_packages.rb@@ -0,0 +1,42 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::GitlabIssuesWorkPackages < Tables::Base+ def self.table(migration)+ migration.create_join_table :gitlab_issues, :work_packages do |t|+ t.index :gitlab_issue_id, name: "gitlab_issues_wp_issue_id"+ t.index %i[gitlab_issue_id work_package_id],+ unique: true,+ name: "unique_index_gl_issues_wps_on_gl_issue_id_and_wp_id"+ end+ end+enddiff --git a/modules/gitlab_integration/db/migrate/20211015110002_add_gitlab_issues.rb b/modules/gitlab_integration/db/migrate/tables/gitlab_merge_requests.rbsimilarity index 68%rename from modules/gitlab_integration/db/migrate/20211015110002_add_gitlab_issues.rbrename to modules/gitlab_integration/db/migrate/tables/gitlab_merge_requests.rbindex 05ffa33cede..7f509eb9f07 100644--- a/modules/gitlab_integration/db/migrate/20211015110002_add_gitlab_issues.rb+++ b/modules/gitlab_integration/db/migrate/tables/gitlab_merge_requests.rb@@ -1,6 +1,8 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.-# Copyright (C) 2023 Ben Tey+# Copyright (C) the OpenProject GmbH## This program is free software; you can redistribute it and/or# modify it under the terms of the GNU General Public License version 3.@@ -8,7 +10,6 @@# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:# Copyright (C) 2006-2013 Jean-Philippe Lang# Copyright (C) 2010-2013 the ChiliProject Team-# Copyright (C) the OpenProject GmbH## This program is free software; you can redistribute it and/or# modify it under the terms of the GNU General Public License@@ -24,31 +25,31 @@# along with this program; if not, write to the Free Software# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.#-# See docs/COPYRIGHT.rdoc for more details.-#++-class AddGitlabIssues < ActiveRecord::Migration[7.0]- def change- create_table :gitlab_issues do |t|+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::GitlabMergeRequests < Tables::Base+ def self.table(migration)+ create_table migration do |t|t.references :gitlab_user+ t.references :merged_by- t.bigint :gitlab_id, unique: true+ t.bigint :gitlab_idt.integer :number, null: false- t.string :gitlab_html_url, null: false, unique: true+ t.string :gitlab_html_url, null: falset.string :state, null: falset.string :repository, null: false- t.datetime :gitlab_updated_at+ t.datetime :gitlab_updated_at, precision: nilt.string :titlet.text :body+ t.boolean :draft+ t.boolean :merged+ t.datetime :merged_at, precision: nilt.json :labels # [{name, color}]- t.timestamps- end-- create_join_table :gitlab_issues, :work_packages do |t|- t.index :gitlab_issue_id, name: "gitlab_issues_wp_issue_id"- t.index %i[gitlab_issue_id work_package_id],- unique: true,- name: "unique_index_gl_issues_wps_on_gl_issue_id_and_wp_id"+ t.timestamps precision: nilendendenddiff --git a/db/migrate/tables/wiki_contents.rb b/modules/gitlab_integration/db/migrate/tables/gitlab_merge_requests_work_packages.rbsimilarity index 72%rename from db/migrate/tables/wiki_contents.rbrename to modules/gitlab_integration/db/migrate/tables/gitlab_merge_requests_work_packages.rbindex ff402138a0e..3322611f008 100644--- a/db/migrate/tables/wiki_contents.rb+++ b/modules/gitlab_integration/db/migrate/tables/gitlab_merge_requests_work_packages.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,22 +26,17 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++-require_relative "base"+require Rails.root.join("db/migrate/tables/base").to_s-class Tables::WikiContents < Tables::Base+class Tables::GitlabMergeRequestsWorkPackages < Tables::Basedef self.table(migration)- create_table migration do |t|- t.integer :page_id, null: false- t.integer :author_id- t.text :text, limit: 16.megabytes- t.datetime :updated_on, null: false- t.integer :lock_version, null: false-- t.index :author_id, name: "index_wiki_contents_on_author_id"- t.index :page_id, name: "wiki_contents_page_id"- t.index %i[page_id updated_on]+ migration.create_join_table :gitlab_merge_requests, :work_packages do |t|+ t.index :gitlab_merge_request_id, name: "gitlab_mr_wp_mr_id"+ t.index %i[gitlab_merge_request_id work_package_id],+ unique: true,+ name: "unique_index_gl_mrs_wps_on_gl_mr_id_and_wp_id"endendenddiff --git a/modules/gitlab_integration/db/migrate/tables/gitlab_pipelines.rb b/modules/gitlab_integration/db/migrate/tables/gitlab_pipelines.rbnew file mode 100644index 00000000000..d76f475f3cb--- /dev/null+++ b/modules/gitlab_integration/db/migrate/tables/gitlab_pipelines.rb@@ -0,0 +1,54 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::GitlabPipelines < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.references :gitlab_merge_request, null: false++ t.bigint :gitlab_id, null: false+ t.string :gitlab_html_url, null: false+ t.bigint :project_id, null: false+ t.string :gitlab_user_avatar_url, null: false+ t.string :status, null: false+ t.string :name, null: false+ t.string :details_url+ t.json :ci_details+ t.datetime :started_at, precision: nil+ t.datetime :completed_at, precision: nil++ t.timestamps precision: nil+ t.text :username+ t.text :commit_id+ end+ end+enddiff --git a/modules/gitlab_integration/db/migrate/tables/gitlab_users.rb b/modules/gitlab_integration/db/migrate/tables/gitlab_users.rbnew file mode 100644index 00000000000..d59153306fe--- /dev/null+++ b/modules/gitlab_integration/db/migrate/tables/gitlab_users.rb@@ -0,0 +1,45 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::GitlabUsers < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.bigint :gitlab_id, null: false+ t.string :gitlab_name, null: false+ t.string :gitlab_username, null: false+ t.string :gitlab_email, null: false+ t.string :gitlab_avatar_url, null: false++ t.timestamps precision: nil+ end+ end+enddiff --git a/modules/grids/db/migrate/1020015_aggregated_grid_migrations.rb b/modules/grids/db/migrate/1020015_aggregated_grid_migrations.rbnew file mode 100644index 00000000000..96668ea29c6--- /dev/null+++ b/modules/grids/db/migrate/1020015_aggregated_grid_migrations.rb@@ -0,0 +1,41 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/migration_utils/squashed_migration").to_s+Dir[File.join(__dir__, "tables/*.rb")].each { |file| require file }++class AggregatedGridMigrations < SquashedMigration+ squashed_migrations "20181118193730_create_grid",+ "20190129083842_add_project_to_grid",+ "20190205090102_add_options_to_grid"++ tables Tables::Grids,+ Tables::GridWidgets+enddiff --git a/db/migrate/20181118193730_create_grid.rb b/modules/grids/db/migrate/tables/grid_widgets.rbsimilarity index 77%rename from db/migrate/20181118193730_create_grid.rbrename to modules/grids/db/migrate/tables/grid_widgets.rbindex 48b832874ae..7d4f978a417 100644--- a/db/migrate/20181118193730_create_grid.rb+++ b/modules/grids/db/migrate/tables/grid_widgets.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,30 +26,13 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#++--class CreateGrid < ActiveRecord::Migration[5.1]- def change- create_grids- create_grid_widgets- end-- private+# ++- def create_grids- create_table :grids do |t|- t.integer :row_count, null: false- t.integer :column_count, null: false- t.string :type-- t.references :user-- t.timestamps- end- end+require Rails.root.join("db/migrate/tables/base").to_s- def create_grid_widgets- create_table :grid_widgets do |t|+class Tables::GridWidgets < Tables::Base+ def self.table(migration)+ create_table migration do |t|t.integer :start_row, null: falset.integer :end_row, null: falset.integer :start_column, null: falsediff --git a/modules/grids/db/migrate/tables/grids.rb b/modules/grids/db/migrate/tables/grids.rbnew file mode 100644index 00000000000..b6667e42c7d--- /dev/null+++ b/modules/grids/db/migrate/tables/grids.rb@@ -0,0 +1,46 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::Grids < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.integer :row_count, null: false+ t.integer :column_count, null: false+ t.string :type+ t.references :user+ t.timestamps precision: nil+ t.references :project+ t.text :name+ t.text :options+ end+ end+enddiff --git a/modules/storages/db/migrate/20231009135807_remove_renamed_cronjobs.rb b/modules/job_status/db/migrate/1013015_aggregated_job_status_migrations.rbsimilarity index 77%rename from modules/storages/db/migrate/20231009135807_remove_renamed_cronjobs.rbrename to modules/job_status/db/migrate/1013015_aggregated_job_status_migrations.rbindex aa7c8dcedcb..68a125dbef9 100644--- a/modules/storages/db/migrate/20231009135807_remove_renamed_cronjobs.rb+++ b/modules/job_status/db/migrate/1013015_aggregated_job_status_migrations.rb@@ -28,11 +28,15 @@# See COPYRIGHT and LICENSE files for more details.#++-class RemoveRenamedCronjobs < ActiveRecord::Migration[7.0]- def up- execute("DELETE FROM delayed_jobs WHERE handler LIKE '%job_class: CleanupUncontaineredFileLinksJob%'")- execute("DELETE FROM delayed_jobs WHERE handler LIKE '%job_class: ManageNextcloudIntegrationJob%'")- end+require Rails.root.join("db/migrate/migration_utils/squashed_migration").to_s+require_relative "tables/job_statuses"- def down; end+class AggregatedJobStatusMigrations < SquashedMigration+ squashed_migrations *%w[+ 20200422105623_add_job_status+ 20200610124259_extend_job_status+ 20240229133250_rename_delayed_job_statuses+ ]++ tables Tables::JobStatusesenddiff --git a/modules/job_status/db/migrate/20200422105623_add_job_status.rb b/modules/job_status/db/migrate/20200422105623_add_job_status.rbdeleted file mode 100644index bbc556408ba..00000000000--- a/modules/job_status/db/migrate/20200422105623_add_job_status.rb+++ /dev/null@@ -1,53 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddJobStatus < ActiveRecord::Migration[6.0]- def up- execute <<-SQL.squish- CREATE TYPE delayed_job_status AS ENUM ('in_queue', 'error', 'in_process', 'success', 'failure');- SQL-- create_table :delayed_job_statuses do |t|- t.references :job- t.references :reference, polymorphic: true, index: { unique: true }- t.string :message-- t.timestamps- end-- add_column :delayed_job_statuses, :status, :delayed_job_status, default: "in_queue"- end-- def down- drop_table :delayed_job_statuses-- execute <<-SQL.squish- DROP TYPE delayed_job_status;- SQL- end-enddiff --git a/modules/job_status/db/migrate/20200610124259_extend_job_status.rb b/modules/job_status/db/migrate/20200610124259_extend_job_status.rbdeleted file mode 100644index d961577f1e2..00000000000--- a/modules/job_status/db/migrate/20200610124259_extend_job_status.rb+++ /dev/null@@ -1,63 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class ExtendJobStatus < ActiveRecord::Migration[6.0]- # ALTER TYPE has to run outside transaction- disable_ddl_transaction!-- def change- reversible do |dir|- dir.up do- execute <<-SQL.squish- ALTER TYPE delayed_job_status ADD VALUE IF NOT EXISTS 'cancelled';- SQL- end- end-- ActiveRecord::Base.transaction do- remove_reference :delayed_job_statuses, :job-- change_table :delayed_job_statuses do |t|- t.references :user, index: true- t.string :job_id, index: { unique: true }- t.jsonb :payload- end-- reversible do |dir|- dir.up do- change_column_default :delayed_job_statuses, :created_at, -> { "CURRENT_TIMESTAMP" }- change_column_default :delayed_job_statuses, :updated_at, -> { "CURRENT_TIMESTAMP" }- end- end-- # Now that we have user reference on job status- # we don't need it on export- remove_reference :work_package_exports, :user- end- end-enddiff --git a/modules/job_status/db/migrate/tables/job_statuses.rb b/modules/job_status/db/migrate/tables/job_statuses.rbnew file mode 100644index 00000000000..4617dd85793--- /dev/null+++ b/modules/job_status/db/migrate/tables/job_statuses.rb@@ -0,0 +1,50 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::JobStatuses < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.references :reference,+ polymorphic: true,+ index: { unique: true, name: "index_job_statuses_on_reference_type_and_reference_id" }+ t.string :message+ t.timestamps precision: nil, default: -> { "CURRENT_TIMESTAMP" }+ t.string :status, default: "in_queue"+ t.references :user, index: true+ t.string :job_id, index: { unique: true }+ t.jsonb :payload++ t.check_constraint("status IS NULL OR status IN ('in_queue', 'error', 'in_process', 'success', 'failure', 'cancelled')",+ name: "delayed_job_statuses_status_check")+ end+ end+enddiff --git a/db/migrate/20230905090205_add_share_workpackages_permission.rb b/modules/ldap_groups/db/migrate/1008015_aggregated_ldap_groups_migrations.rbsimilarity index 64%rename from db/migrate/20230905090205_add_share_workpackages_permission.rbrename to modules/ldap_groups/db/migrate/1008015_aggregated_ldap_groups_migrations.rbindex 1706576059b..818b497620f 100644--- a/db/migrate/20230905090205_add_share_workpackages_permission.rb+++ b/modules/ldap_groups/db/migrate/1008015_aggregated_ldap_groups_migrations.rb@@ -28,20 +28,21 @@# See COPYRIGHT and LICENSE files for more details.#++-require_relative "migration_utils/permission_adder"+require Rails.root.join("db/migrate/migration_utils/squashed_migration").to_s+require_relative "tables/ldap_groups_memberships"+require_relative "tables/ldap_groups_synchronized_filters"+require_relative "tables/ldap_groups_synchronized_groups"-class AddShareWorkpackagesPermission < ActiveRecord::Migration[7.0]- # Decouple ActiveRecord model from Migration- class MigrationRolePermission < ApplicationRecord- self.table_name = "role_permissions"- end+class AggregatedLdapGroupsMigrations < SquashedMigration+ squashed_migrations *%w[+ 20180125082205_add_ldap_synchronized_groups+ 20200420122713_make_synchronized_group_dn+ 20200420133116_add_synchronized_filters+ 20200427082928_ldap_groups_timestamp+ 20210219092709_move_base_dn_into_filters+ ]- def up- ::Migration::MigrationUtils::PermissionAdder.add(:manage_members, :share_work_packages)- ::Migration::MigrationUtils::PermissionAdder.add(:edit_work_packages, :share_work_packages)- end-- def down- MigrationRolePermission.where(permission: "share_work_packages").delete_all- end+ tables Tables::LdapGroupsMemberships,+ Tables::LdapGroupsSynchronizedFilters,+ Tables::LdapGroupsSynchronizedGroupsenddiff --git a/modules/ldap_groups/db/migrate/20180125082205_add_ldap_synchronized_groups.rb b/modules/ldap_groups/db/migrate/20180125082205_add_ldap_synchronized_groups.rbdeleted file mode 100644index 4b7774c1f0f..00000000000--- a/modules/ldap_groups/db/migrate/20180125082205_add_ldap_synchronized_groups.rb+++ /dev/null@@ -1,46 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddLdapSynchronizedGroups < ActiveRecord::Migration[5.0]- def change- create_table :ldap_groups_synchronized_groups do |t|- t.string :entry- t.references :group- t.references :auth_source-- t.timestamps- end-- create_table :ldap_groups_memberships do |t|- t.references :user- t.references :group-- t.timestamps- end- end-enddiff --git a/modules/ldap_groups/db/migrate/20200420122713_make_synchronized_group_dn.rb b/modules/ldap_groups/db/migrate/20200420122713_make_synchronized_group_dn.rbdeleted file mode 100644index b5b4e0e0332..00000000000--- a/modules/ldap_groups/db/migrate/20200420122713_make_synchronized_group_dn.rb+++ /dev/null@@ -1,55 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class MakeSynchronizedGroupDn < ActiveRecord::Migration[6.0]- def up- add_column :ldap_groups_synchronized_groups, :dn, :text, index: true- add_column :ldap_groups_synchronized_groups,- :users_count,- :integer,- default: 0,- null: false-- LdapGroups::SynchronizedGroup.find_each do |group|- dn = ::OpenProject::LdapGroups.group_dn(Net::LDAP::DN.escape(group.entry))- group.update_column(:dn, dn)- end-- remove_column :ldap_groups_synchronized_groups, :entry, :text- end-- def down- add_column :ldap_groups_synchronized_groups, :entry, :text-- warn "Removing synchronized groups"- LdapGroups::SynchronizedGroup.destroy_all-- remove_column :ldap_groups_synchronized_groups, :dn- remove_column :ldap_groups_synchronized_groups, :users_count- end-enddiff --git a/modules/ldap_groups/db/migrate/20200427082928_ldap_groups_timestamps.rb b/modules/ldap_groups/db/migrate/20200427082928_ldap_groups_timestamps.rbdeleted file mode 100644index 792ec381064..00000000000--- a/modules/ldap_groups/db/migrate/20200427082928_ldap_groups_timestamps.rb+++ /dev/null@@ -1,44 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class LdapGroupsTimestamps < ActiveRecord::Migration[6.0]- def up- change_column_default :ldap_groups_synchronized_groups, :created_at, -> { "CURRENT_TIMESTAMP" }- change_column_default :ldap_groups_synchronized_groups, :updated_at, -> { "CURRENT_TIMESTAMP" }-- change_column_default :ldap_groups_synchronized_filters, :created_at, -> { "CURRENT_TIMESTAMP" }- change_column_default :ldap_groups_synchronized_filters, :updated_at, -> { "CURRENT_TIMESTAMP" }-- change_column_default :ldap_groups_memberships, :created_at, -> { "CURRENT_TIMESTAMP" }- change_column_default :ldap_groups_memberships, :updated_at, -> { "CURRENT_TIMESTAMP" }- end-- def down- # Nothing to do- end-enddiff --git a/modules/ldap_groups/db/migrate/20210219092709_move_base_dn_into_filters.rb b/modules/ldap_groups/db/migrate/20210219092709_move_base_dn_into_filters.rbdeleted file mode 100644index 4475d60ecb4..00000000000--- a/modules/ldap_groups/db/migrate/20210219092709_move_base_dn_into_filters.rb+++ /dev/null@@ -1,68 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class MoveBaseDnIntoFilters < ActiveRecord::Migration[6.1]- class MigratingAuthSource < ApplicationRecord- self.table_name = "auth_sources"- end-- def change- add_column :ldap_groups_synchronized_filters, :base_dn, :text, null: true-- # Add sync_users option to filters- add_column :ldap_groups_synchronized_filters,- :sync_users,- :boolean,- null: false,- default: false-- # Add sync_users option to groups- add_column :ldap_groups_synchronized_groups,- :sync_users,- :boolean,- null: false,- default: false-- LdapGroups::SynchronizedFilter.reset_column_information- LdapGroups::SynchronizedGroup.reset_column_information-- # Take over the connection's onthefly setting- # for whether to sync users for filters and groups- MigratingAuthSource- .pluck(:id, :onthefly_register)- .each do |id, onthefly|- LdapGroups::SynchronizedFilter- .where(ldap_auth_source_id: id)- .update_all(sync_users: onthefly)-- LdapGroups::SynchronizedGroup- .where(ldap_auth_source_id: id)- .update_all(sync_users: onthefly)- end- end-enddiff --git a/db/migrate/tables/reportings.rb b/modules/ldap_groups/db/migrate/tables/ldap_groups_memberships.rbsimilarity index 78%rename from db/migrate/tables/reportings.rbrename to modules/ldap_groups/db/migrate/tables/ldap_groups_memberships.rbindex ae5f274a6f0..a320aea8cd7 100644--- a/db/migrate/tables/reportings.rb+++ b/modules/ldap_groups/db/migrate/tables/ldap_groups_memberships.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,20 +26,19 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++-require_relative "base"+require Rails.root.join("db/migrate/tables/base").to_s-class Tables::Reportings < Tables::Base+class Tables::LdapGroupsMemberships < Tables::Basedef self.table(migration)create_table migration do |t|- t.column :reported_project_status_comment, :text-- t.belongs_to :project, type: :int- t.belongs_to :reporting_to_project, type: :int- t.belongs_to :reported_project_status, type: :int+ t.references :user+ t.references :group- t.timestamps null: true+ t.timestamps precision: nil, default: -> { "CURRENT_TIMESTAMP" }+ t.index %i[user_id group_id],+ unique: trueendendenddiff --git a/modules/ldap_groups/db/migrate/20200420133116_add_synchronized_filters.rb b/modules/ldap_groups/db/migrate/tables/ldap_groups_synchronized_filters.rbsimilarity index 75%rename from modules/ldap_groups/db/migrate/20200420133116_add_synchronized_filters.rbrename to modules/ldap_groups/db/migrate/tables/ldap_groups_synchronized_filters.rbindex 9972e3674c7..0cd731ec61f 100644--- a/modules/ldap_groups/db/migrate/20200420133116_add_synchronized_filters.rb+++ b/modules/ldap_groups/db/migrate/tables/ldap_groups_synchronized_filters.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,21 +26,22 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++++require Rails.root.join("db/migrate/tables/base").to_s-class AddSynchronizedFilters < ActiveRecord::Migration[6.0]- def change- create_table :ldap_groups_synchronized_filters do |t|+class Tables::LdapGroupsSynchronizedFilters < Tables::Base+ def self.table(migration)+ create_table migration do |t|t.string :namet.string :group_name_attributet.string :filter_string- t.references :auth_source+ t.references :ldap_auth_source- t.timestamps- end+ t.timestamps precision: nil, default: -> { "CURRENT_TIMESTAMP" }- change_table :ldap_groups_synchronized_groups do |t|- t.belongs_to :filter, foreign_key: { to_table: :ldap_groups_synchronized_filters }+ t.text :base_dn, null: true+ t.boolean :sync_users, null: false, default: falseendendenddiff --git a/modules/ldap_groups/db/migrate/tables/ldap_groups_synchronized_groups.rb b/modules/ldap_groups/db/migrate/tables/ldap_groups_synchronized_groups.rbnew file mode 100644index 00000000000..106b91a7fd5--- /dev/null+++ b/modules/ldap_groups/db/migrate/tables/ldap_groups_synchronized_groups.rb@@ -0,0 +1,47 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::LdapGroupsSynchronizedGroups < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.references :group+ t.references :ldap_auth_source++ t.timestamps precision: nil, default: -> { "CURRENT_TIMESTAMP" }++ t.text :dn+ t.integer :users_count, default: 0, null: false+ t.belongs_to :filter, foreign_key: { to_table: :ldap_groups_synchronized_filters }+ t.boolean :sync_users, null: false, default: false+ end+ end+enddiff --git a/modules/meeting/db/migrate/1003015_aggregated_meeting_migrations.rb b/modules/meeting/db/migrate/1003015_aggregated_meeting_migrations.rbnew file mode 100644index 00000000000..8b584752245--- /dev/null+++ b/modules/meeting/db/migrate/1003015_aggregated_meeting_migrations.rb@@ -0,0 +1,64 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++require Rails.root.join("db/migrate/migration_utils/squashed_migration").to_s+require Rails.root.join("db/migrate/tables/base").to_s+Dir[File.join(__dir__, "tables/*.rb")].each { |file| require file }++class AggregatedMeetingMigrations < SquashedMigration+ squashed_migrations *%w[+ 20180323135408_to_v710_aggregated_meeting_migrations+ 20230816141222_create_meeting_agenda_items+ 20230823113310_add_work_package_to_meeting_agenda_items+ 20230829122717_add_state_to_meetings+ 20230911102918_add_type_to_meeting+ 20230918135247_change_meeting_agenda_item_description_to_notes+ 20231003151656_create_meeting_agenda_item_journals+ 20231012124745_add_item_type_to_meeting_agenda_items+ 20231013114720_add_item_type_to_meeting_agenda_item_journal+ 20231020154219_add_trgm_index_to_meeting_agenda_item_notes+ 20231025144701_migrate_agenda_item_permissions+ 20231119192222_add_locking_to_meeting+ 20240313102951_add_presenter_to_meeting+ 20240405131352_create_meeting_sections+ 20240408161233_add_state_to_meeting_journal+ 20240418110249_set_author_as_presenter+ 20240516102219_fix_untitled_meetings+ ].freeze++ tables Tables::MeetingContents,+ Tables::MeetingParticipants,+ Tables::Meetings,+ Tables::MeetingJournals,+ Tables::MeetingContentJournals,+ Tables::MeetingSections,+ Tables::MeetingAgendaItems,+ Tables::MeetingAgendaItemJournals+enddiff --git a/modules/meeting/db/migrate/20180323135408_to_v710_aggregated_meeting_migrations.rb b/modules/meeting/db/migrate/20180323135408_to_v710_aggregated_meeting_migrations.rbdeleted file mode 100644index 4f1c47f6ad0..00000000000--- a/modules/meeting/db/migrate/20180323135408_to_v710_aggregated_meeting_migrations.rb+++ /dev/null@@ -1,116 +0,0 @@-# frozen_string_literal: true-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require Rails.root.join("db/migrate/migration_utils/migration_squasher").to_s-# This migration aggregates the migrations detailed in MIGRATION_FILES-class ToV710AggregatedMeetingMigrations < ActiveRecord::Migration[5.1]- MIGRATION_FILES = <<-MIGRATIONS- 20111605171865_aggregated_meeting_migrations.rb- 20130924114042_legacy_meeting_minutes_journal_data.rb- 20130731151542_remove_meeting_role_id_from_meeting_participants.rb- 20131127120534_migrate_text_references_to_work_packages.rb- 20130822113942_create_meeting_journals.rb- 20160504064737_add_index_for_latest_meeting_activity.rb- 20130924091342_legacy_meeting_journal_data.rb- 20130924093842_legacy_meeting_agenda_journal_data.rb- MIGRATIONS-- def up- Migration::MigrationSquasher.squash(migrations) do- create_table "meeting_contents", id: :integer do |t|- t.string "type"- t.integer "meeting_id"- t.integer "author_id"- t.text "text"- t.integer "lock_version"- t.datetime "created_at", null: false- t.datetime "updated_at", null: false- t.boolean "locked", default: false- end-- create_table "meeting_participants", id: :integer do |t|- t.integer "user_id"- t.integer "meeting_id"- t.string "email"- t.string "name"- t.boolean "invited"- t.boolean "attended"- t.datetime "created_at", null: false- t.datetime "updated_at", null: false- end-- create_table "meetings", id: :integer do |t|- t.string "title"- t.integer "author_id"- t.integer "project_id"- t.string "location"- t.datetime "start_time"- t.float "duration"- t.datetime "created_at", null: false- t.datetime "updated_at", null: false-- t.index %i[project_id updated_at]- end-- create_table :meeting_journals, id: :integer do |t|- t.integer :journal_id, null: false- t.string :title- t.integer :author_id- t.integer :project_id- t.string :location- t.datetime :start_time- t.float :duration- end-- create_table :meeting_content_journals, id: :integer do |t|- t.integer :journal_id, null: false- t.integer :meeting_id- t.integer :author_id- t.text :text- t.boolean :locked- end- end- end-- def down- drop_table "meeting_contents"- drop_table "meeting_participants"- drop_table "meetings"- drop_table :meeting_journals- drop_table :meeting_content_journals- end-- private-- def migrations- MIGRATION_FILES.split.map do |m|- m.gsub(/_.*\z/, "")- end- end-enddiff --git a/modules/meeting/db/migrate/20230816141222_create_meeting_agenda_items.rb b/modules/meeting/db/migrate/20230816141222_create_meeting_agenda_items.rbdeleted file mode 100644index 4e8993e4056..00000000000--- a/modules/meeting/db/migrate/20230816141222_create_meeting_agenda_items.rb+++ /dev/null@@ -1,17 +0,0 @@-# frozen_string_literal: true-class CreateMeetingAgendaItems < ActiveRecord::Migration[5.1]- def change- create_table :meeting_agenda_items do |t|- t.references :meeting, foreign_key: true- t.references :author, foreign_key: { to_table: :users }- t.string :title- t.text :description- t.integer :position- t.integer :duration_in_minutes- t.datetime :start_time- t.datetime :end_time-- t.timestamps- end- end-enddiff --git a/modules/meeting/db/migrate/20230823113310_add_work_package_to_meeting_agenda_items.rb b/modules/meeting/db/migrate/20230823113310_add_work_package_to_meeting_agenda_items.rbdeleted file mode 100644index c83bafc06d6..00000000000--- a/modules/meeting/db/migrate/20230823113310_add_work_package_to_meeting_agenda_items.rb+++ /dev/null@@ -1,6 +0,0 @@-# frozen_string_literal: true-class AddWorkPackageToMeetingAgendaItems < ActiveRecord::Migration[5.1]- def change- add_reference :meeting_agenda_items, :work_package, index: true- end-enddiff --git a/modules/meeting/db/migrate/20230829122717_add_state_to_meetings.rb b/modules/meeting/db/migrate/20230829122717_add_state_to_meetings.rbdeleted file mode 100644index 72a3efa45ed..00000000000--- a/modules/meeting/db/migrate/20230829122717_add_state_to_meetings.rb+++ /dev/null@@ -1,6 +0,0 @@-# frozen_string_literal: true-class AddStateToMeetings < ActiveRecord::Migration[5.1]- def change- add_column :meetings, :state, :integer, default: 0, null: false- end-enddiff --git a/modules/meeting/db/migrate/20230911102918_add_type_to_meeting.rb b/modules/meeting/db/migrate/20230911102918_add_type_to_meeting.rbdeleted file mode 100644index 72598fa94e6..00000000000--- a/modules/meeting/db/migrate/20230911102918_add_type_to_meeting.rb+++ /dev/null@@ -1,6 +0,0 @@-# frozen_string_literal: true-class AddTypeToMeeting < ActiveRecord::Migration[7.0]- def change- add_column :meetings, :type, :string, default: "Meeting", null: false- end-enddiff --git a/modules/meeting/db/migrate/20230918135247_change_meeting_agenda_item_description_to_notes.rb b/modules/meeting/db/migrate/20230918135247_change_meeting_agenda_item_description_to_notes.rbdeleted file mode 100644index 22c18d0a911..00000000000--- a/modules/meeting/db/migrate/20230918135247_change_meeting_agenda_item_description_to_notes.rb+++ /dev/null@@ -1,6 +0,0 @@-# frozen_string_literal: true-class ChangeMeetingAgendaItemDescriptionToNotes < ActiveRecord::Migration[7.0]- def change- rename_column :meeting_agenda_items, :description, :notes- end-enddiff --git a/modules/meeting/db/migrate/20240313102951_add_presenter_to_meeting.rb b/modules/meeting/db/migrate/20240313102951_add_presenter_to_meeting.rbdeleted file mode 100644index e698406837d..00000000000--- a/modules/meeting/db/migrate/20240313102951_add_presenter_to_meeting.rb+++ /dev/null@@ -1,7 +0,0 @@-# frozen_string_literal: true-class AddPresenterToMeeting < ActiveRecord::Migration[7.1]- def change- add_reference :meeting_agenda_items, :presenter, type: :bigint, foreign_key: { to_table: :users }, index: true- add_reference :meeting_agenda_item_journals, :presenter, type: :bigint, foreign_key: { to_table: :users }, index: true- end-enddiff --git a/modules/meeting/db/migrate/20240405131352_create_meeting_sections.rb b/modules/meeting/db/migrate/20240405131352_create_meeting_sections.rbdeleted file mode 100644index aa1e32cf96d..00000000000--- a/modules/meeting/db/migrate/20240405131352_create_meeting_sections.rb+++ /dev/null@@ -1,40 +0,0 @@-# frozen_string_literal: true--class CreateMeetingSections < ActiveRecord::Migration[7.1]- def up- create_table :meeting_sections do |t|- t.integer :position- t.string :title- t.references :meeting, null: false, foreign_key: true-- t.timestamps- end-- add_reference :meeting_agenda_items, :meeting_section-- create_and_assign_default_section- end-- def down- remove_reference :meeting_agenda_items, :meeting_section- drop_table :meeting_sections- # TODO: positions of agenda items are now not valid anymore as they have been scoped to sections- # Do we need to catch this?- end-- private-- def create_and_assign_default_section- execute <<~SQL.squish- INSERT INTO meeting_sections (meeting_id, title, created_at, updated_at)- SELECT id, 'Untitled', NOW(), NOW()- FROM meetings- WHERE meetings.type = 'StructuredMeeting';-- UPDATE meeting_agenda_items- SET meeting_section_id = meeting_sections.id- FROM meeting_sections- WHERE meeting_agenda_items.meeting_id = meeting_sections.meeting_id;- SQL- end-enddiff --git a/modules/meeting/db/migrate/20240408161233_add_state_to_meeting_journal.rb b/modules/meeting/db/migrate/20240408161233_add_state_to_meeting_journal.rbdeleted file mode 100644index c44e3d5183a..00000000000--- a/modules/meeting/db/migrate/20240408161233_add_state_to_meeting_journal.rb+++ /dev/null@@ -1,6 +0,0 @@-# frozen_string_literal: true-class AddStateToMeetingJournal < ActiveRecord::Migration[7.1]- def change- add_column :meeting_journals, :state, :integer, default: 0, null: false- end-enddiff --git a/modules/meeting/db/migrate/20240418110249_set_author_as_presenter.rb b/modules/meeting/db/migrate/20240418110249_set_author_as_presenter.rbdeleted file mode 100644index 82746aa4b03..00000000000--- a/modules/meeting/db/migrate/20240418110249_set_author_as_presenter.rb+++ /dev/null@@ -1,10 +0,0 @@-# frozen_string_literal: true-class SetAuthorAsPresenter < ActiveRecord::Migration[7.1]- def up- execute "UPDATE meeting_agenda_items SET presenter_id = author_id WHERE presenter_id IS NULL"- end-- def down- # Nothing to do- end-enddiff --git a/modules/meeting/db/migrate/20240426073948_create_recurring_meetings.rb b/modules/meeting/db/migrate/20240426073948_create_recurring_meetings.rbindex 799d8e3d965..32dbd29d02a 100644--- a/modules/meeting/db/migrate/20240426073948_create_recurring_meetings.rb+++ b/modules/meeting/db/migrate/20240426073948_create_recurring_meetings.rb@@ -1,4 +1,5 @@# frozen_string_literal: true+class CreateRecurringMeetings < ActiveRecord::Migration[7.1]def changecreate_table :recurring_meetings do |t|diff --git a/modules/meeting/db/migrate/20240516102219_fix_untitled_meetings.rb b/modules/meeting/db/migrate/20240516102219_fix_untitled_meetings.rbdeleted file mode 100644index 3b8b7e59820..00000000000--- a/modules/meeting/db/migrate/20240516102219_fix_untitled_meetings.rb+++ /dev/null@@ -1,10 +0,0 @@-# frozen_string_literal: true-class FixUntitledMeetings < ActiveRecord::Migration[7.1]- def up- MeetingSection.where(title: "Untitled").update_all(title: "")- end-- def down- MeetingSection.where(title: "").update_all(title: "Untitled")- end-enddiff --git a/db/migrate/tables/wiki_content_versions.rb b/modules/meeting/db/migrate/tables/meeting_agenda_item_journals.rbsimilarity index 70%rename from db/migrate/tables/wiki_content_versions.rbrename to modules/meeting/db/migrate/tables/meeting_agenda_item_journals.rbindex 299cec20239..854fac203a6 100644--- a/db/migrate/tables/wiki_content_versions.rb+++ b/modules/meeting/db/migrate/tables/meeting_agenda_item_journals.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,24 +26,25 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++-require_relative "base"+require Rails.root.join("db/migrate/tables/base").to_s-class Tables::WikiContentVersions < Tables::Base+class Tables::MeetingAgendaItemJournals < Tables::Basedef self.table(migration)create_table migration do |t|- t.integer :wiki_content_id, null: false- t.integer :page_id, null: false+ t.integer :journal_id+ t.integer :agenda_item_idt.integer :author_id- t.binary :data, limit: 16.megabytes- t.string :compression, limit: 6, default: ""- t.string :comments, default: ""- t.datetime :updated_on, null: false- t.integer :version, null: false-- t.index :updated_on, name: "index_wiki_content_versions_on_updated_on"- t.index :wiki_content_id, name: "wiki_content_versions_wcid"+ t.string :title+ t.text :notes+ t.integer :position+ t.integer :duration_in_minutes+ t.datetime :start_time+ t.datetime :end_time+ t.integer :work_package_id+ t.integer :item_type, limit: 1+ t.references :presenter, foreign_key: { to_table: :users }, index: trueendendenddiff --git a/modules/meeting/db/migrate/tables/meeting_agenda_items.rb b/modules/meeting/db/migrate/tables/meeting_agenda_items.rbnew file mode 100644index 00000000000..6f089d1ad4d--- /dev/null+++ b/modules/meeting/db/migrate/tables/meeting_agenda_items.rb@@ -0,0 +1,57 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::MeetingAgendaItems < Tables::Base+ def self.table(migration) # rubocop:disable Metrics/AbcSize+ create_table migration do |t|+ t.references :meeting, foreign_key: true+ t.references :author, foreign_key: { to_table: :users }+ t.string :title+ t.text :notes+ t.integer :position+ t.integer :duration_in_minutes+ t.timestamp :start_time, precision: nil+ t.timestamp :end_time, precision: nil+ t.timestamp :created_at, precision: nil, null: false+ t.timestamp :updated_at, precision: nil, null: false+ t.references :work_package, index: true+ t.integer :item_type, default: 0, limit: 1+ t.integer :lock_version, default: 0, null: false+ t.references :presenter, foreign_key: { to_table: :users }, index: true+ t.references :meeting_section++ t.index :notes,+ using: "gin",+ opclass: :gin_trgm_ops+ end+ end+enddiff --git a/modules/meeting/db/migrate/tables/meeting_content_journals.rb b/modules/meeting/db/migrate/tables/meeting_content_journals.rbnew file mode 100644index 00000000000..243b98378c4--- /dev/null+++ b/modules/meeting/db/migrate/tables/meeting_content_journals.rb@@ -0,0 +1,42 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::MeetingContentJournals < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.bigint :meeting_id+ t.bigint :author_id+ t.text :text+ t.boolean :locked+ end+ end+enddiff --git a/modules/meeting/db/migrate/tables/meeting_contents.rb b/modules/meeting/db/migrate/tables/meeting_contents.rbnew file mode 100644index 00000000000..03577fc2cf6--- /dev/null+++ b/modules/meeting/db/migrate/tables/meeting_contents.rb@@ -0,0 +1,45 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::MeetingContents < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.string :type+ t.bigint :meeting_id+ t.bigint :author_id+ t.text :text+ t.integer :lock_version+ t.timestamps precision: nil, null: false+ t.boolean :locked, default: false+ end+ end+enddiff --git a/modules/meeting/db/migrate/tables/meeting_journals.rb b/modules/meeting/db/migrate/tables/meeting_journals.rbnew file mode 100644index 00000000000..9d91a356c2c--- /dev/null+++ b/modules/meeting/db/migrate/tables/meeting_journals.rb@@ -0,0 +1,45 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::MeetingJournals < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.string :title+ t.bigint :author_id+ t.bigint :project_id+ t.string :location+ t.datetime :start_time, precision: nil+ t.float :duration+ t.integer :state, default: 0, null: false+ end+ end+enddiff --git a/modules/meeting/db/migrate/tables/meeting_participants.rb b/modules/meeting/db/migrate/tables/meeting_participants.rbnew file mode 100644index 00000000000..a9f30a8096d--- /dev/null+++ b/modules/meeting/db/migrate/tables/meeting_participants.rb@@ -0,0 +1,45 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::MeetingParticipants < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.bigint :user_id+ t.bigint :meeting_id+ t.string :email+ t.string :name+ t.boolean :invited+ t.boolean :attended+ t.timestamps precision: nil, null: false+ end+ end+enddiff --git a/db/migrate/tables/planning_element_type_colors.rb b/modules/meeting/db/migrate/tables/meeting_sections.rbsimilarity index 82%rename from db/migrate/tables/planning_element_type_colors.rbrename to modules/meeting/db/migrate/tables/meeting_sections.rbindex 23f17357fbf..905260fc3a3 100644--- a/db/migrate/tables/planning_element_type_colors.rb+++ b/modules/meeting/db/migrate/tables/meeting_sections.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,19 +26,18 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++-require_relative "base"+require Rails.root.join("db/migrate/tables/base").to_s-class Tables::PlanningElementTypeColors < Tables::Base+class Tables::MeetingSections < Tables::Basedef self.table(migration)create_table migration do |t|- t.column :name, :string, null: false- t.column :hexcode, :string, null: false, length: 7-- t.integer :position, default: 1, null: true+ t.integer :position+ t.string :title+ t.references :meeting, null: false, foreign_key: true- t.timestamps null: true+ t.timestampsendendenddiff --git a/modules/meeting/db/migrate/tables/meetings.rb b/modules/meeting/db/migrate/tables/meetings.rbnew file mode 100644index 00000000000..83e4467a4bb--- /dev/null+++ b/modules/meeting/db/migrate/tables/meetings.rb@@ -0,0 +1,50 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::Meetings < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.string :title+ t.bigint :author_id+ t.bigint :project_id+ t.string :location+ t.datetime :start_time, precision: nil+ t.float :duration+ t.timestamps precision: nil, null: false+ t.integer :state, default: 0, null: false+ t.integer :lock_version, default: 0, null: false+ t.string :type, default: "Meeting", null: false++ t.index %i[project_id updated_at]+ end+ end+enddiff --git a/modules/two_factor_authentication/db/migrate/20130214130336_add_default_otp_channel_to_user.rb b/modules/my_page/db/migrate/1021015_aggregated_my_page_migrations.rbsimilarity index 82%rename from modules/two_factor_authentication/db/migrate/20130214130336_add_default_otp_channel_to_user.rbrename to modules/my_page/db/migrate/1021015_aggregated_my_page_migrations.rbindex 27c85e7325a..fb9a61caae0 100644--- a/modules/two_factor_authentication/db/migrate/20130214130336_add_default_otp_channel_to_user.rb+++ b/modules/my_page/db/migrate/1021015_aggregated_my_page_migrations.rb@@ -1,6 +1,6 @@# frozen_string_literal: true-#-- copyright+# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -26,14 +26,13 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++-class AddDefaultOtpChannelToUser < ActiveRecord::Migration[5.0]- def self.up- add_column :users, :default_otp_channel, :string, default: "text"- end+require Rails.root.join("db/migrate/migration_utils/squashed_migration").to_s- def self.down- remove_column :users, :default_otp_channel- end+class AggregatedMyPageMigrations < SquashedMigration+ squashed_migrations *%w[+ 20190220080647_migrate_my_page_layout+ 20190710132957_rename_my_page_widgets+ ]enddiff --git a/modules/openid_connect/db/migrate/1018015_aggregated_openid_connect_migrations.rb b/modules/openid_connect/db/migrate/1018015_aggregated_openid_connect_migrations.rbnew file mode 100644index 00000000000..2992078fbc7--- /dev/null+++ b/modules/openid_connect/db/migrate/1018015_aggregated_openid_connect_migrations.rb@@ -0,0 +1,41 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/migration_utils/squashed_migration").to_s+require_relative "tables/oidc_user_session_links"++class AggregatedOpenIDConnectMigrations < SquashedMigration+ tables Tables::OidcUserSessionLinks++ squashed_migrations *%w[+ 20221122072857_add_oidc_session_link+ 20240829140616_migrate_oidc_settings_to_providers+ ]+enddiff --git a/modules/openid_connect/db/migrate/20221122072857_add_oidc_session_link.rb b/modules/openid_connect/db/migrate/20221122072857_add_oidc_session_link.rbdeleted file mode 100644index 3a920eca4d4..00000000000--- a/modules/openid_connect/db/migrate/20221122072857_add_oidc_session_link.rb+++ /dev/null@@ -1,47 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddOidcSessionLink < ActiveRecord::Migration[7.0]- def change- create_unlogged_tables = ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.create_unlogged_tables-- begin- ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.create_unlogged_tables = true- create_table :oidc_user_session_links do |t|- t.string :oidc_session, null: false, index: true- t.references :session, index: true, foreign_key: { to_table: "sessions", on_delete: :cascade }-- t.timestamps- end- ensure- ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.create_unlogged_tables = create_unlogged_tables- end- end-enddiff --git a/modules/openid_connect/db/migrate/20240829140616_migrate_oidc_settings_to_providers.rb b/modules/openid_connect/db/migrate/20240829140616_migrate_oidc_settings_to_providers.rbdeleted file mode 100644index 39ebcbfb5ed..00000000000--- a/modules/openid_connect/db/migrate/20240829140616_migrate_oidc_settings_to_providers.rb+++ /dev/null@@ -1,76 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class MigrateOidcSettingsToProviders < ActiveRecord::Migration[7.1]- def up- settings = Setting.plugin_openproject_openid_connect- return if settings.blank?-- providers = Hash(settings).with_indifferent_access[:providers]- return if providers.blank?-- providers.each do |name, configuration|- migrate_provider!(name, configuration)- end- end-- def down- # This migration does not yet remove Setting.plugin_openproject_openid_connect- # so it can be retried.- end-- private-- def migrate_provider!(name, configuration)- Rails.logger.debug { "Trying to migrate OpenID provider #{name} from previous settings format..." }- call = ::OpenIDConnect::SyncService.new(name, configuration).call-- if call.success- Rails.logger.debug { <<~SUCCESS }- Successfully migrated OpenID provider #{name} from previous settings format.- You can now manage this provider in the new administrative UI within OpenProject under- the "Administration -> Authentication -> OpenID providers" section.- SUCCESS- else- raise <<~ERROR- Failed to create or update OpenID provider #{name} from previous settings format.- The error message was: #{call.message}-- Please check the logs for more information and open a bug report in our community:- https://www.openproject.org/docs/development/report-a-bug/-- If you would like to skip migrating the OpenID provider setting and discard them instead, you can use our documentation- to unset any previous OpenID provider settings:-- https://www.openproject.org/docs/system-admin-guide/authentication/openid-providers/- ERROR- end- end-enddiff --git a/modules/openid_connect/db/migrate/tables/oidc_user_session_links.rb b/modules/openid_connect/db/migrate/tables/oidc_user_session_links.rbnew file mode 100644index 00000000000..dc804c4dd4c--- /dev/null+++ b/modules/openid_connect/db/migrate/tables/oidc_user_session_links.rb@@ -0,0 +1,42 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::OidcUserSessionLinks < Tables::Base+ def self.table(migration)+ create_unlogged_table migration do |t|+ t.string :oidc_session, null: false, index: true+ t.references :session, index: true, foreign_key: { on_delete: :cascade }++ t.timestamps+ end+ end+enddiff --git a/modules/openid_connect/spec/migration/migrate_oidc_settings_to_providers_spec.rb b/modules/openid_connect/spec/migration/migrate_oidc_settings_to_providers_spec.rbdeleted file mode 100644index 4cb437a70ab..00000000000--- a/modules/openid_connect/spec/migration/migrate_oidc_settings_to_providers_spec.rb+++ /dev/null@@ -1,150 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require "spec_helper"--require Rails.root.join("modules/openid_connect/db/migrate/20240829140616_migrate_oidc_settings_to_providers.rb")-RSpec.describe MigrateOidcSettingsToProviders, type: :model do- # Define a custom class,- # Class.new doesn't work here as STI uses .constantize- # rubocop:disable Lint/ConstantDefinitionInBlock,RSpec/LeakyConstantDeclaration- class TestOpenIDConnectProvider < OpenIDConnect::Provider- self.table_name = "test_openid_connect_provider"- end- # rubocop:enable Lint/ConstantDefinitionInBlock,RSpec/LeakyConstantDeclaration-- subject { described_class.new.up }-- let(:test_provider_table_name) { "test_openid_connect_provider" }-- # Mock the create service so we can test with the test provider- before do- allow_any_instance_of(OpenIDConnect::Providers::CreateService) # rubocop:disable RSpec/AnyInstance- .to receive(:instance_class).and_return(TestOpenIDConnectProvider)- end-- around do |example|- ActiveRecord::Migration.suppress_messages do- ActiveRecord::Migration.create_table(test_provider_table_name) do |t|- t.string :type, null: false- t.string :display_name, null: false, index: { unique: true }- t.string :slug, null: false, index: { unique: true }- t.boolean :available, null: false, default: true- t.boolean :limit_self_registration, null: false, default: false- t.jsonb :options, default: {}, null: false- t.references :creator, null: false, index: true, foreign_key: { to_table: :users }-- t.timestamps- end-- example.run- ensure- ActiveRecord::Migration.drop_table(test_provider_table_name)- end- end-- context "when no provider present",- with_settings: { plugin_openproject_openid_connect: nil } do- it "does nothing" do- allow(OpenIDConnect::SyncService).to receive(:new)-- subject-- expect(OpenIDConnect::SyncService).not_to have_received(:new)- end- end-- context "when a provider present, but invalid",- with_settings: {- plugin_openproject_openid_connect: {- providers: {- keycloak: {- display_name: "Keycloak",- token_endpoint: "wat?"- }- }- }- } do- it "raises an error" do- expect { subject }.to raise_error do |error|- expect(error.message).to include "Failed to create or update OpenID provider keycloak from previous settings format"- expect(error.message).to include "Provided token_endpoint 'wat?' needs to be http(s) URL or path starting with a slash."- end- end- end-- context "when a provider correctly provided",- with_settings: {- plugin_openproject_openid_connect: {- providers: {- keycloak: {- display_name: "Keycloak",- host: "localhost",- port: "8080",- scheme: "http",- scope: ["foo", "bar"],- identifier: "http://localhost:3000",- secret: "IVl6GxxujAQ3mt6thAXKxyYYvmyRr8jw",- issuer: "http://localhost:8080/realms/test",- authorization_endpoint: "/realms/test/protocol/openid-connect/auth",- token_endpoint: "/realms/test/protocol/openid-connect/token",- userinfo_endpoint: "/realms/test/protocol/openid-connect/userinfo",- end_session_endpoint: "http://localhost:8080/realms/test/protocol/openid-connect/logout",- post_logout_redirect_uri: "http://localhost:3000",- limit_self_registration: true,- attribute_map: { login: "foo", admin: "isAdmin" }- }- }- }- } do- it "migrates correctly" do # rubocop:disable RSpec/MultipleExpectations- expect { subject }.to change(TestOpenIDConnectProvider, :count).by(1)-- provider = TestOpenIDConnectProvider.last- expect(provider.display_name).to eq "Keycloak"- expect(provider.host).to eq "localhost"- expect(provider.port).to eq "8080"- expect(provider.scheme).to eq "http"- expect(provider.scope).to eq "foo bar"- expect(provider.client_id).to eq "http://localhost:3000"- expect(provider.client_secret).to eq "IVl6GxxujAQ3mt6thAXKxyYYvmyRr8jw"- expect(provider.issuer).to eq "http://localhost:8080/realms/test"- expect(provider.authorization_endpoint).to eq "http://localhost:8080/realms/test/protocol/openid-connect/auth"- expect(provider.token_endpoint).to eq "http://localhost:8080/realms/test/protocol/openid-connect/token"- expect(provider.userinfo_endpoint).to eq "http://localhost:8080/realms/test/protocol/openid-connect/userinfo"- expect(provider.end_session_endpoint).to eq "http://localhost:8080/realms/test/protocol/openid-connect/logout"- expect(provider.post_logout_redirect_uri).to eq "http://localhost:3000"- expect(provider.limit_self_registration).to be true- expect(provider.mapping_login).to eq "foo"- expect(provider.mapping_admin).to eq "isAdmin"- expect(provider.mapping_email).to be_blank- end- end-enddiff --git a/modules/overviews/db/migrate/1019015_aggregated_overviews_migrations.rb b/modules/overviews/db/migrate/1019015_aggregated_overviews_migrations.rbnew file mode 100644index 00000000000..91da0e08289--- /dev/null+++ b/modules/overviews/db/migrate/1019015_aggregated_overviews_migrations.rb@@ -0,0 +1,38 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/migration_utils/squashed_migration").to_s++class AggregatedOverviewsMigrations < SquashedMigration+ squashed_migrations *%w[+ 20190826083604_my_project_page_to_grid+ 20241025072902_remove_project_details_widget+ ]+enddiff --git a/modules/overviews/db/migrate/20190826083604_my_project_page_to_grid.rb b/modules/overviews/db/migrate/20190826083604_my_project_page_to_grid.rbdeleted file mode 100644index 3e177419830..00000000000--- a/modules/overviews/db/migrate/20190826083604_my_project_page_to_grid.rb+++ /dev/null@@ -1,285 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class MyProjectPageToGrid < ActiveRecord::Migration[5.2]- # rubocop:disable Rails/ApplicationRecord- class MyPageEntry < ActiveRecord::Base- self.table_name = "my_projects_overviews"-- serialize :top- serialize :left- serialize :right- end- # rubocop:enable Rails/ApplicationRecord-- def up- return unless applicable?-- recreate_my_page_entries- remove_my_page_table- add_permission- end-- def down- # down migration will loose data- Grids::Overview.destroy_all-- create_table :my_projects_overviews, id: :integer do |t|- t.integer "project_id", default: 0, null: false- t.text "left", null: false- t.text "right", null: false- t.text "top", null: false- t.text "hidden", null: false- t.datetime "created_on", null: false- end- end-- def recreate_my_page_entries- migratable_entries.in_batches(of: 200).each do |entries|- entries.each do |entry|- grid = create_grid(entry)- move_attachments(entry, grid)- end- end- end-- def remove_my_page_table- drop_table :my_projects_overviews- end-- def add_permission- Role- .includes(:role_permissions)- .where(role_permissions: { permission: "edit_project" })- .each do |role|- role.add_permission!(:manage_overview)- end- end-- def create_grid(entry)- grid = Grids::Overview.new project_id: entry.project_id, column_count: 2, created_at: entry.created_on-- %i[top left right].each do |area|- entry.send(area).each do |widget|- build_widget(grid, widget, area)- end- end-- grid.row_count = grid.widgets.map(&:end_row).max || 1-- grid.save!- grid- end-- def move_attachments(entry, grid)- execute <<~SQL.squish- UPDATE attachments- SET container_type = 'Grids::Grid', container_id = #{grid.id}- WHERE container_type = 'MyProjectsOverview'- AND container_id = #{entry.id}- SQL- end-- def build_widget(grid, widget_config, position)- method = case widget_config- when Array- :build_custom_text_widget- when "project_details"- :build_project_details_widget- when "work_packages_assigned_to_me",- "work_packages_reported_by_me",- "work_packages_responsible_for",- "work_packages_watched"- :build_wp_table_widget- else- :build_default_widget- end-- send(method, grid, widget_config, position)- end-- def build_custom_text_widget(grid, widget_config, position)- build_widget_with_options(grid, "custom_text", position) do |options|- name = widget_config[1].presence || "Text"-- options[:name] = name- options[:text] = widget_config[2]- end- end-- def build_project_details_widget(grid, _identifier, position)- build_default_widget(grid, "subprojects", position)- build_default_widget(grid, "project_details", position)- end-- def build_wp_table_widget(grid, identifier, position)- query = query(grid, identifier)-- build_widget_with_options(grid, identifier, position) do |options|- options[:name] = wp_table_widget_name(identifier)- options[:queryId] = query.id.to_s- end- end-- def build_default_widget(grid, identifier, position)- build_widget_with_options(grid, identifier, position)- end-- def build_widget_with_options(grid, identifier, position)- position_args = next_position(grid, position)-- new_identifier = new_name(identifier)-- options = {- name: I18n.t("js.grid.widgets.#{new_identifier}.title")- }-- yield options if block_given?-- grid.widgets.build position_args.merge(options:, identifier: new_identifier)- end-- def new_name(name)- {- news_latest: "news",- work_package_tracking: "work_packages_overview",- spent_time: "time_entries_list",- work_packages_assigned_to_me: "work_packages_table",- work_packages_reported_by_me: "work_packages_table",- work_packages_responsible_for: "work_packages_table",- work_packages_watched: "work_packages_table"- }.with_indifferent_access[name] || name- end-- def next_position(grid, position)- send(:"next_#{position}_position", grid)- end-- def next_top_position(grid)- start_row = grid.widgets.map(&:end_row).max || 1-- {- start_row:,- end_row: start_row + 1,- start_column: 1,- end_column: 3- }- end-- def next_left_position(grid)- start_row = grid.widgets.select { |w| w.start_column == 1 }.map(&:end_row).max || 1-- {- start_row:,- end_row: start_row + 1,- start_column: 1,- end_column: 2- }- end-- def next_right_position(grid)- start_row = grid.widgets.select { |w| w.end_column == 3 }.map(&:end_row).max || 1-- {- start_row:,- end_row: start_row + 1,- start_column: 2,- end_column: 3- }- end-- def applicable?- ActiveRecord::Base.connection.table_exists?("my_projects_overviews")- end-- def attachments(id)- Attachment.where(container_type: "MyProjectsOverview", container_id: id)- end-- def new_default_query(attributes = nil)- Query.new(attributes).tap do |query|- query.add_default_filter- query.set_default_sort- query.show_hierarchies = true- end- end-- def query(grid, identifier)- query = new_default_query name: "_",- is_public: true,- hidden: true,- project_id: grid.project_id,- user: query_user(grid)-- query.add_filter(filter_name(identifier), "=", [::Queries::Filters::MeValue::KEY])- query.column_names = %w(id type subject)-- User.execute_as(query.user) do- query.save(validate: false)- end-- query- end-- def migratable_entries- MyPageEntry- .where("project_id IN (SELECT id from projects)")- end-- def filter_name(identifier)- case identifier- when "work_packages_assigned_to_me"- "assigned_to_id"- when "work_packages_reported_by_me"- "author_id"- when "work_packages_responsible_for"- "responsible_id"- when "work_packages_watched"- "watcher_id"- end- end-- def wp_table_widget_name(identifier)- new_identifier = case identifier- when "work_packages_assigned_to_me"- "work_packages_assigned"- when "work_packages_reported_by_me"- "work_packages_created"- when "work_packages_responsible_for"- "work_packages_accountable"- when "work_packages_watched"- "work_packages_watched"- end-- I18n.t("js.grid.widgets.#{new_identifier}.title")- end-- def query_user(grid)- User.includes(:members).where(members: { project_id: grid.project_id }).first || User.active.admin.first- end-enddiff --git a/db/migrate/20240424160513_add_settings_to_projects.rb b/modules/recaptcha/db/migrate/1016015_aggregated_recaptcha_migrations.rbsimilarity index 81%rename from db/migrate/20240424160513_add_settings_to_projects.rbrename to modules/recaptcha/db/migrate/1016015_aggregated_recaptcha_migrations.rbindex 3ededcf8bb0..c0b73fd8406 100644--- a/db/migrate/20240424160513_add_settings_to_projects.rb+++ b/modules/recaptcha/db/migrate/1016015_aggregated_recaptcha_migrations.rb@@ -28,8 +28,13 @@# See COPYRIGHT and LICENSE files for more details.#++-class AddSettingsToProjects < ActiveRecord::Migration[7.1]- def change- add_column :projects, :settings, :jsonb, null: false, default: {}- end+require Rails.root.join("db/migrate/migration_utils/squashed_migration").to_s+require_relative "tables/recaptcha_entries"++class AggregatedRecaptchaMigrations < SquashedMigration+ squashed_migrations *%w[+ 20190905130336_add_recaptcha_entries+ ]++ tables Tables::RecaptchaEntriesenddiff --git a/modules/recaptcha/db/migrate/20190905130336_add_recaptcha_entries.rb b/modules/recaptcha/db/migrate/tables/recaptcha_entries.rbsimilarity index 83%rename from modules/recaptcha/db/migrate/20190905130336_add_recaptcha_entries.rbrename to modules/recaptcha/db/migrate/tables/recaptcha_entries.rbindex 04dfb176c6e..8d54c2d6cbb 100644--- a/modules/recaptcha/db/migrate/20190905130336_add_recaptcha_entries.rb+++ b/modules/recaptcha/db/migrate/tables/recaptcha_entries.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,13 +26,15 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++++require Rails.root.join("db/migrate/tables/base").to_s-class AddRecaptchaEntries < ActiveRecord::Migration[5.2]- def change- create_table :recaptcha_entries, id: :integer do |t|+class Tables::RecaptchaEntries < Tables::Base+ def self.table(migration)+ create_table migration, id: :integer do |t|t.references :user, index: true, foreign_key: { on_delete: :cascade }- t.timestamps+ t.timestamps precision: nilt.integer :version, null: falseendenddiff --git a/modules/storages/db/migrate/20230721123022_remove_project_folder_mode_default.rb b/modules/reporting/db/migrate/1005015_aggregated_reporting_migrations.rbsimilarity index 80%rename from modules/storages/db/migrate/20230721123022_remove_project_folder_mode_default.rbrename to modules/reporting/db/migrate/1005015_aggregated_reporting_migrations.rbindex 53359bfcac2..0d6276e3483 100644--- a/modules/storages/db/migrate/20230721123022_remove_project_folder_mode_default.rb+++ b/modules/reporting/db/migrate/1005015_aggregated_reporting_migrations.rb@@ -28,8 +28,13 @@# See COPYRIGHT and LICENSE files for more details.#++-class RemoveProjectFolderModeDefault < ActiveRecord::Migration[7.0]- def change- change_column_default :projects_storages, :project_folder_mode, to: nil, from: :inactive- end+require Rails.root.join("db/migrate/migration_utils/squashed_migration").to_s+require_relative "tables/cost_queries"++class AggregatedReportingMigrations < SquashedMigration+ squashed_migrations *%w[+ 20180323130704_to_v710_aggregated_reporting_migrations+ ]++ tables Tables::CostQueriesenddiff --git a/modules/reporting/db/migrate/tables/cost_queries.rb b/modules/reporting/db/migrate/tables/cost_queries.rbnew file mode 100644index 00000000000..8d0b037fc44--- /dev/null+++ b/modules/reporting/db/migrate/tables/cost_queries.rb@@ -0,0 +1,45 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::CostQueries < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.bigint :user_id, null: false+ t.bigint :project_id+ t.string "name", null: false+ t.boolean "is_public", default: false, null: false+ t.datetime :created_at, precision: nil, null: false, default: -> { "CURRENT_TIMESTAMP" }+ t.datetime :updated_at, precision: nil, null: false, default: -> { "CURRENT_TIMESTAMP" }+ t.string "serialized", limit: 2000, null: false+ end+ end+enddiff --git a/modules/storages/db/migrate/1017015_aggregated_storages_migrations.rb b/modules/storages/db/migrate/1017015_aggregated_storages_migrations.rbnew file mode 100644index 00000000000..24cf7ca924a--- /dev/null+++ b/modules/storages/db/migrate/1017015_aggregated_storages_migrations.rb@@ -0,0 +1,66 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/migration_utils/squashed_migration").to_s+require Rails.root.join("db/migrate/tables/base").to_s+Dir[File.join(__dir__, "tables/*.rb")].each { |file| require file }++class AggregatedStoragesMigrations < SquashedMigration+ squashed_migrations *%w[+ 20220113144323_create_storage+ 20220113144759_create_file_links+ 20220121090847_create_projects_storages+ 20220712165928_add_storages_permissions_to_roles+ 20230123092649_make_containter_id_and_containter_type_optional_for_file_links+ 20230321194150_add_project_folder_to_projects_storages+ 20230420063148_add_provider_fields_to_storages+ 20230420071113_migrate_storages_to_use_provider_type_as_sti_column+ 20230512153303_change_storage_provider_fields_default+ 20230517075214_add_automatic_to_project_folder_modes+ 20230601082746_create_last_project_folders+ 20230713144232_create_storages_file_link_journals+ 20230721123022_remove_project_folder_mode_default+ 20230802085026_rename_projects_storages_table+ 20230824130730_remove_not_null_constraint_for_storage_host+ 20231009135807_remove_renamed_cronjobs+ 20231109080454_add_health_info_to_storages+ 20231208143303_add_health_checked_at_to_storages+ 20240405135016_update_access_management_of_configured_one_drive_storages+ 20240610130953_rename_manage_storages_in_project_permission+ 20230725165505_add_storage_name_to_storages_file_links_journals+ 20230731153909_add_file_link_journals_to_existing_containers+ ].freeze++ tables Tables::Storages,+ Tables::FileLinks,+ Tables::ProjectStorages,+ Tables::LastProjectFolders,+ Tables::StoragesFileLinksJournals+enddiff --git a/modules/storages/db/migrate/20220712165928_add_storages_permissions_to_roles.rb b/modules/storages/db/migrate/20220712165928_add_storages_permissions_to_roles.rbdeleted file mode 100644index 21a598c5649..00000000000--- a/modules/storages/db/migrate/20220712165928_add_storages_permissions_to_roles.rb+++ /dev/null@@ -1,53 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require Rails.root.join("db/migrate/migration_utils/permission_adder")--class AddStoragesPermissionsToRoles < ActiveRecord::Migration[6.1]- def up- Role.reset_column_information-- ::Migration::MigrationUtils::PermissionAdder- .add(:select_project_modules,- :manage_storages_in_project)-- ::Migration::MigrationUtils::PermissionAdder- .add(:view_work_packages,- :view_file_links)-- ::Migration::MigrationUtils::PermissionAdder- .add(:edit_work_packages,- :manage_file_links)- end-- def down- # Nothing to do- end-enddiff --git a/modules/storages/db/migrate/20230321194150_add_project_folder_to_projects_storages.rb b/modules/storages/db/migrate/20230321194150_add_project_folder_to_projects_storages.rbdeleted file mode 100644index a6fa04d472e..00000000000--- a/modules/storages/db/migrate/20230321194150_add_project_folder_to_projects_storages.rb+++ /dev/null@@ -1,51 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddProjectFolderToProjectsStorages < ActiveRecord::Migration[7.0]- def up- execute <<-SQL.squish- CREATE TYPE project_folder_modes AS ENUM ('inactive', 'manual');- SQL-- change_table :projects_storages do |table|- table.string :project_folder_id- table.enum :project_folder_mode, enum_type: :project_folder_modes, default: :inactive, null: false- end- end-- def down- remove_column :projects_storages, :project_folder_id- remove_column :projects_storages, :project_folder_mode-- execute <<-SQL.squish- DROP TYPE project_folder_modes;- SQL- end-enddiff --git a/modules/storages/db/migrate/20230420071113_migrate_storages_to_use_provider_type_as_sti_column.rb b/modules/storages/db/migrate/20230420071113_migrate_storages_to_use_provider_type_as_sti_column.rbdeleted file mode 100644index 76bed032ab1..00000000000--- a/modules/storages/db/migrate/20230420071113_migrate_storages_to_use_provider_type_as_sti_column.rb+++ /dev/null@@ -1,42 +0,0 @@-# frozen_string_literal: true--# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class MigrateStoragesToUseProviderTypeAsStiColumn < ActiveRecord::Migration[7.0]- def up- execute <<~SQL- UPDATE "storages" SET provider_type = 'Storages::NextcloudStorage' WHERE "storages"."provider_type" = 'nextcloud'- SQL- end-- def down- execute <<~SQL- UPDATE "storages" SET provider_type = 'nextcloud' WHERE "storages"."provider_type" = 'Storages::NextcloudStorage'- SQL- end-enddiff --git a/modules/storages/db/migrate/20230512153303_change_storage_provider_fields_default.rb b/modules/storages/db/migrate/20230512153303_change_storage_provider_fields_default.rbdeleted file mode 100644index 78b39dbf47f..00000000000--- a/modules/storages/db/migrate/20230512153303_change_storage_provider_fields_default.rb+++ /dev/null@@ -1,44 +0,0 @@-# frozen_string_literal: true--# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class ChangeStorageProviderFieldsDefault < ActiveRecord::Migration[7.0]- def change- change_column_default(:storages, :provider_fields, from: "{}", to: {})-- reversible do |dir|- dir.up do- execute <<~SQL- UPDATE "storages"- SET "provider_fields" = '{}'- WHERE "storages"."provider_fields" = '"{}"'- SQL- end- end- end-enddiff --git a/modules/storages/db/migrate/20230824130730_remove_not_null_constraint_for_storage_host.rb b/modules/storages/db/migrate/20230824130730_remove_not_null_constraint_for_storage_host.rbdeleted file mode 100644index 03c2ba20f8d..00000000000--- a/modules/storages/db/migrate/20230824130730_remove_not_null_constraint_for_storage_host.rb+++ /dev/null@@ -1,44 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class RemoveNotNullConstraintForStorageHost < ActiveRecord::Migration[7.0]- def up- change_column :storages, :host, :string, null: true- change_column :oauth_clients, :client_secret, :string, null: true- end-- def down- execute 'DELETE FROM "storages" WHERE "storages"."host" IS NULL'- change_column :storages, :host, :string, null: false-- ::OAuthClient.where(client_secret: nil).delete_all- change_column :oauth_clients, :client_secret, :string, null: false- end-enddiff --git a/modules/storages/db/migrate/20231109080454_add_health_info_to_storages.rb b/modules/storages/db/migrate/20231109080454_add_health_info_to_storages.rbdeleted file mode 100644index 84f96951b7f..00000000000--- a/modules/storages/db/migrate/20231109080454_add_health_info_to_storages.rb+++ /dev/null@@ -1,49 +0,0 @@-# frozen_string_literal: true--# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that itwill be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddHealthInfoToStorages < ActiveRecord::Migration[7.0]- def up- execute <<-SQL.squish- CREATE TYPE storage_health_statuses AS ENUM ('pending', 'healthy', 'unhealthy');- SQL- add_column(:storages, :health_status, :storage_health_statuses, null: false, default: "pending")- add_column(:storages, :health_changed_at, :datetime, null: false, default: -> { "current_timestamp" })- add_column(:storages, :health_reason, :string)- end-- def down- remove_column(:storages, :health_status)- remove_column(:storages, :health_changed_at)- remove_column(:storages, :health_reason)-- execute <<-SQL.squish- DROP TYPE storage_health_statuses;- SQL- end-enddiff --git a/modules/storages/db/migrate/20231208143303_add_health_checked_at_to_storages.rb b/modules/storages/db/migrate/20231208143303_add_health_checked_at_to_storages.rbdeleted file mode 100644index 5612edd13ce..00000000000--- a/modules/storages/db/migrate/20231208143303_add_health_checked_at_to_storages.rb+++ /dev/null@@ -1,11 +0,0 @@-# frozen_string_literal: true--class AddHealthCheckedAtToStorages < ActiveRecord::Migration[7.0]- def up- add_column(:storages, :health_checked_at, :datetime, null: false, default: -> { "current_timestamp" })- end-- def down- remove_column(:storages, :health_checked_at)- end-enddiff --git a/modules/storages/db/migrate/20240405135016_update_access_management_of_configured_one_drive_storages.rb b/modules/storages/db/migrate/20240405135016_update_access_management_of_configured_one_drive_storages.rbdeleted file mode 100644index 9f0cc7c7918..00000000000--- a/modules/storages/db/migrate/20240405135016_update_access_management_of_configured_one_drive_storages.rb+++ /dev/null@@ -1,41 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class UpdateAccessManagementOfConfiguredOneDriveStorages < ActiveRecord::Migration[7.1]- def up- execute <<-SQL.squish- UPDATE storages- SET provider_fields = jsonb_set(provider_fields, '{automatically_managed}', 'false', true)- WHERE provider_type = 'Storages::OneDriveStorage' AND provider_fields->>'automatically_managed' is null;- SQL- end-- def down; end-enddiff --git a/modules/storages/db/migrate/20240610130953_rename_manage_storages_in_project_permission.rb b/modules/storages/db/migrate/20240610130953_rename_manage_storages_in_project_permission.rbdeleted file mode 100644index 2d807b231ef..00000000000--- a/modules/storages/db/migrate/20240610130953_rename_manage_storages_in_project_permission.rb+++ /dev/null@@ -1,7 +0,0 @@-# frozen_string_literal: true--class RenameManageStoragesInProjectPermission < ActiveRecord::Migration[7.1]- def change- RolePermission.where(permission: "manage_storages_in_project").update_all(permission: "manage_files_in_project")- end-enddiff --git a/modules/storages/db/migrate/20220113144759_create_file_links.rb b/modules/storages/db/migrate/tables/file_links.rbsimilarity index 81%rename from modules/storages/db/migrate/20220113144759_create_file_links.rbrename to modules/storages/db/migrate/tables/file_links.rbindex 1ef3431251a..6c3bb21d2ab 100644--- a/modules/storages/db/migrate/20220113144759_create_file_links.rb+++ b/modules/storages/db/migrate/tables/file_links.rb@@ -1,6 +1,6 @@# frozen_string_literal: true-#-- copyright+# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -26,28 +26,30 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++-class CreateFileLinks < ActiveRecord::Migration[6.1]- def change- create_table :file_links do |t|+require Rails.root.join("db/migrate/tables/base").to_s++class Tables::FileLinks < Tables::Base+ def self.table(migration)+ create_table migration do |t|t.references :storage, foreign_key: { on_delete: :cascade }t.references :creator,null: false,index: true,foreign_key: { to_table: :users }- t.bigint :container_id, null: false- t.string :container_type, null: false+ t.bigint :container_id, null: true+ t.string :container_type, null: truet.string :origin_idt.string :origin_namet.string :origin_created_by_namet.string :origin_last_modified_by_namet.string :origin_mime_type- t.timestamp :origin_created_at- t.timestamp :origin_updated_at+ t.datetime :origin_created_at, precision: nil+ t.datetime :origin_updated_at, precision: nil- t.timestamps+ t.timestamps precision: nil# i.e. show all file links per WP.t.index %i[container_id container_type]diff --git a/modules/storages/db/migrate/20230601082746_create_last_project_folders.rb b/modules/storages/db/migrate/tables/last_project_folders.rbsimilarity index 70%rename from modules/storages/db/migrate/20230601082746_create_last_project_folders.rbrename to modules/storages/db/migrate/tables/last_project_folders.rbindex a52db1aa844..1fa073c5c34 100644--- a/modules/storages/db/migrate/20230601082746_create_last_project_folders.rb+++ b/modules/storages/db/migrate/tables/last_project_folders.rb@@ -1,6 +1,6 @@# frozen_string_literal: true-#-- copyright+# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -26,17 +26,22 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++-class CreateLastProjectFolders < ActiveRecord::Migration[7.0]- def change- create_table :last_project_folders,+require Rails.root.join("db/migrate/tables/base").to_s++class Tables::LastProjectFolders < Tables::Base+ def self.table(migration)+ create_table migration,comment: "This table contains the last used project folder IDs for a project storage per mode." do |t|- t.references :projects_storage, null: false, foreign_key: { on_delete: :cascade }+ t.references :project_storage, null: false, foreign_key: { on_delete: :cascade, name: "fk_rails_73e1c678f1" }t.string :origin_folder_id- t.enum :mode, enum_type: :project_folder_modes, default: :inactive, null: false- t.index %i[projects_storage_id mode], unique: true+ t.string :mode, enum_type: :project_folder_modes, default: "inactive", null: false+ t.index %i[project_storage_id mode], unique: truet.timestamps++ t.check_constraint("mode IN ('inactive', 'manual', 'automatic')",+ name: "last_project_folders_mode_check")endendenddiff --git a/modules/storages/db/migrate/20220121090847_create_projects_storages.rb b/modules/storages/db/migrate/tables/project_storages.rbsimilarity index 69%rename from modules/storages/db/migrate/20220121090847_create_projects_storages.rbrename to modules/storages/db/migrate/tables/project_storages.rbindex 40205780e69..6506aff6b32 100644--- a/modules/storages/db/migrate/20220121090847_create_projects_storages.rb+++ b/modules/storages/db/migrate/tables/project_storages.rb@@ -1,6 +1,6 @@# frozen_string_literal: true-#-- copyright+# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -26,21 +26,28 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++-class CreateProjectsStorages < ActiveRecord::Migration[6.1]- def change- create_table :projects_storages do |t|- t.references :project, null: false, foreign_key: { on_delete: :cascade }- t.references :storage, null: false, foreign_key: { on_delete: :cascade }+require Rails.root.join("db/migrate/tables/base").to_s++class Tables::ProjectStorages < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.references :project, null: false, foreign_key: { on_delete: :cascade, name: "fk_rails_96ab713fe3" }+ t.references :storage, null: false, foreign_key: { on_delete: :cascade, name: "fk_rails_04546d7b88" }t.references :creator,null: false,index: true,- foreign_key: { to_table: :users }+ foreign_key: { to_table: :users, name: "fk_rails_acca00a591" }- t.timestamps+ t.timestamps precision: nil+ t.string :project_folder_id+ t.string :project_folder_mode, null: false, default: nilt.index %i[project_id storage_id], unique: true++ t.check_constraint("project_folder_mode IN ('inactive', 'manual', 'automatic')",+ name: "project_storages_project_folder_mode_check")endendenddiff --git a/modules/storages/db/migrate/tables/storages.rb b/modules/storages/db/migrate/tables/storages.rbnew file mode 100644index 00000000000..c45047ef607--- /dev/null+++ b/modules/storages/db/migrate/tables/storages.rb@@ -0,0 +1,51 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::Storages < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.string :provider_type, null: false+ t.string :name, null: false, index: { unique: true }+ t.string :host, null: true, index: { unique: true }+ t.references :creator, null: false, index: true, foreign_key: { to_table: :users }+ t.timestamps precision: nil+ t.jsonb :provider_fields, null: false, default: {}+ t.string :health_status, null: false, default: "pending"+ t.datetime :health_changed_at, null: false, default: -> { "current_timestamp" }+ t.string :health_reason+ t.datetime :health_checked_at, null: false, default: -> { "current_timestamp" }++ t.check_constraint("health_status IN ('pending', 'healthy', 'unhealthy')",+ name: "storages_health_status_check")+ end+ end+enddiff --git a/db/migrate/20230713144232_create_storages_file_link_journals.rb b/modules/storages/db/migrate/tables/storages_file_links_journals.rbsimilarity index 84%rename from db/migrate/20230713144232_create_storages_file_link_journals.rbrename to modules/storages/db/migrate/tables/storages_file_links_journals.rbindex 80b898ee468..6be1204bacc 100644--- a/db/migrate/20230713144232_create_storages_file_link_journals.rb+++ b/modules/storages/db/migrate/tables/storages_file_links_journals.rb@@ -1,6 +1,6 @@# frozen_string_literal: true-#-- copyright+# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -26,17 +26,17 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++-class CreateStoragesFileLinkJournals < ActiveRecord::Migration[7.0]- def change- # rubocop:disable Rails/CreateTableWithTimestamps- create_table :storages_file_links_journals do |t|+require Rails.root.join("db/migrate/tables/base").to_s++class Tables::StoragesFileLinksJournals < Tables::Base+ def self.table(migration)+ create_table migration do |t|t.belongs_to :journal, null: false, foreign_key: truet.belongs_to :file_link, null: false-t.string :link_name, null: false+ t.string :storage_nameend- # rubocop:enable Rails/CreateTableWithTimestampsendenddiff --git a/db/migrate/20180419061910_timestamp_for_caching.rb b/modules/two_factor_authentication/db/migrate/1010015_aggregated_two_factor_authentication_migrations.rbsimilarity index 64%rename from db/migrate/20180419061910_timestamp_for_caching.rbrename to modules/two_factor_authentication/db/migrate/1010015_aggregated_two_factor_authentication_migrations.rbindex e9728a74784..fd643939ac9 100644--- a/db/migrate/20180419061910_timestamp_for_caching.rb+++ b/modules/two_factor_authentication/db/migrate/1010015_aggregated_two_factor_authentication_migrations.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,29 +26,24 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#++--class TimestampForCaching < ActiveRecord::Migration[5.1]- class MigratingAuthSource < ApplicationRecord- self.table_name = "auth_sources"- end-- def change- [Enumeration, Status, Category, MigratingAuthSource].each do |model|- add_timestamps(model)- end- end+# ++- def add_timestamps(model)- table = model.table_name+require Rails.root.join("db/migrate/migration_utils/squashed_migration").to_s+require Rails.root.join("db/migrate/tables/base").to_s+Dir[File.join(__dir__, "tables/*.rb")].each { |file| require file }- change_table table do |t|- t.timestamps null: true- end+class AggregatedTwoFactorAuthenticationMigrations < SquashedMigration+ squashed_migrations *%w[+ 20120214103300_aggregated_mobile_otp_migrations+ 20130214130336_add_default_otp_channel_to_user+ 20160331190036_change_default_channel+ 20171023190036_model_reorganization+ 20230627133534_add_webauthn_fields_to_two_factor_table+ ].freeze- model.update_all(updated_at: Time.now, created_at: Time.now)+ tables Tables::TwoFactorAuthenticationDevices- change_column_null table, :created_at, false- change_column_null table, :updated_at, false+ modifications do+ add_column :users, :webauthn_id, :string, null: trueendenddiff --git a/modules/two_factor_authentication/db/migrate/20120214103300_aggregated_mobile_otp_migrations.rb b/modules/two_factor_authentication/db/migrate/20120214103300_aggregated_mobile_otp_migrations.rbdeleted file mode 100644index 2736d783971..00000000000--- a/modules/two_factor_authentication/db/migrate/20120214103300_aggregated_mobile_otp_migrations.rb+++ /dev/null@@ -1,62 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require Rails.root.join("db/migrate/migration_utils/migration_squasher").to_s-require Rails.root.join("db/migrate/migration_utils/setting_renamer").to_s-require "open_project/plugins/migration_mapping"--# This migration aggregates the migrations detailed in MIGRATION_FILES-class AggregatedMobileOtpMigrations < ActiveRecord::Migration[5.0]- MIGRATION_FILES = <<-MIGRATIONS- 001_add_user_phone.rb- 002_create_extended_tokens.rb- 003_remove_user_phone.rb- 004_add_user_verified_phone_unverified_phone.rb- MIGRATIONS-- OLD_PLUGIN_NAME = "redmine_two_factor_authentication_authentication"-- def up- migration_names = OpenProject::Plugins::MigrationMapping.migration_files_to_migration_names(MIGRATION_FILES, OLD_PLUGIN_NAME)- Migration::MigrationSquasher.squash(migration_names) do- add_column :users, :verified_phone, :string- add_column :users, :unverified_phone, :string- User.reset_column_information- end- Migration::MigrationUtils::SettingRenamer.rename("plugin_redmine_two_factor_authentication_authentication",- "plugin_openproject_two_factor_authentication")- end-- def down- remove_column :users, :verified_phone- remove_column :users, :unverified_phone- User.reset_column_information- end-enddiff --git a/modules/two_factor_authentication/db/migrate/20160331190036_change_default_channel.rb b/modules/two_factor_authentication/db/migrate/20160331190036_change_default_channel.rbdeleted file mode 100644index 8108e213903..00000000000--- a/modules/two_factor_authentication/db/migrate/20160331190036_change_default_channel.rb+++ /dev/null@@ -1,41 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class ChangeDefaultChannel < ActiveRecord::Migration[5.0]- def self.up- change_column_default(:users, :default_otp_channel, "sms")- User.where(default_otp_channel: "text").update_all(default_otp_channel: "sms")- end-- def self.down- change_column_default(:users, :default_otp_channel, "text")- User.where(default_otp_channel: "sms").update_all(default_otp_channel: "text")- end-enddiff --git a/modules/two_factor_authentication/db/migrate/20171023190036_model_reorganization.rb b/modules/two_factor_authentication/db/migrate/20171023190036_model_reorganization.rbdeleted file mode 100644index e440d7c7ec1..00000000000--- a/modules/two_factor_authentication/db/migrate/20171023190036_model_reorganization.rb+++ /dev/null@@ -1,107 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class ModelReorganization < ActiveRecord::Migration[5.0]- def self.up- # Add devices table- create_table "two_factor_authentication_devices" do |t|- t.string "type"-- # Whether this is the default strategy- t.boolean "default", default: false, null: false-- # Whether the device has been fully registered- t.boolean "active", default: false, null: false-- # Channel the OTP is delivered through- # (e.g., voice, sms)- t.string "channel", null: false-- # Phone number for SMS/voice actions- t.string "phone_number", null: true-- # User-given identifier for this device- t.string "identifier", null: false-- # Default rails timestamps- t.timestamps-- # Last used datetime (relevant for totp)- t.integer "last_used_at", null: true-- # OTP secret for totp- t.text "otp_secret", null: true- end- add_reference :two_factor_authentication_devices, :user, foreign_key: true, type: :integer-- # Create existing SMS device for data currently in users table- User.transaction do- User.find_each do |user|- phone = user.verified_phone || user.unverified_phone- next if phone.blank?-- sms = ::TwoFactorAuthentication::Device::Sms.create!(- user_id: user.id,- identifier: "Mobile",- channel: user.default_otp_channel,- phone_number: phone,- active: true- )- sms.update_column(:default, true)- end- end-- change_table "users" do |t|- t.remove :verified_phone- t.remove :unverified_phone- t.remove :default_otp_channel- end- end-- def self.down- change_table "users" do |t|- t.string :verified_phone- t.string :unverified_phone- t.string :default_otp_channel, default: "sms"- end-- # Write back information from sms devices to table- User.transaction do- ::TwoFactorAuthentication::Device::Sms- .where(active: true)- .includes(:user)- .find_each do |device|- device.user.update_columns(unverified_phone: device.phone_number, default_otp_channel: device.channel)- end- end-- drop_table :two_factor_authentication_devices- end-enddiff --git a/modules/two_factor_authentication/db/migrate/20230627133534_add_webauthn_fields_to_two_factor_table.rb b/modules/two_factor_authentication/db/migrate/20230627133534_add_webauthn_fields_to_two_factor_table.rbdeleted file mode 100644index a9226166542..00000000000--- a/modules/two_factor_authentication/db/migrate/20230627133534_add_webauthn_fields_to_two_factor_table.rb+++ /dev/null@@ -1,13 +0,0 @@-# frozen_string_literal: true--class AddWebauthnFieldsToTwoFactorTable < ActiveRecord::Migration[7.0]- def change- add_column :two_factor_authentication_devices, :webauthn_external_id, :string, null: true- add_index :two_factor_authentication_devices, :webauthn_external_id, unique: true-- add_column :two_factor_authentication_devices, :webauthn_public_key, :string, null: true- add_column :two_factor_authentication_devices, :webauthn_sign_count, :bigint, null: false, default: 0-- add_column :users, :webauthn_id, :string, null: true- end-enddiff --git a/db/migrate/tables/delayed_jobs.rb b/modules/two_factor_authentication/db/migrate/tables/two_factor_authentication_devices.rbsimilarity index 50%rename from db/migrate/tables/delayed_jobs.rbrename to modules/two_factor_authentication/db/migrate/tables/two_factor_authentication_devices.rbindex 56b418c1cef..fb95c298e5a 100644--- a/db/migrate/tables/delayed_jobs.rb+++ b/modules/two_factor_authentication/db/migrate/tables/two_factor_authentication_devices.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,25 +26,48 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++-require_relative "base"+require Rails.root.join("db/migrate/tables/base").to_s-class Tables::DelayedJobs < Tables::Base+class Tables::TwoFactorAuthenticationDevices < Tables::Basedef self.table(migration)create_table migration do |t|- t.integer :priority, default: 0 # Allows some jobs to jump to the front of the queue- t.integer :attempts, default: 0 # Provides for retries, but still fail eventually.- t.text :handler # YAML-encoded string of the object that will do work- t.text :last_error # reason for last failure (See Note below)- t.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.- t.datetime :locked_at # Set when a client is working on this object- t.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)- t.string :locked_by # Who is working on this object (if locked)- t.timestamps null: true- t.string :queue-- t.index %i[priority run_at], name: "delayed_jobs_priority"+ t.string :type++ # Whether this is the default strategy+ t.boolean :default, default: false, null: false++ # Whether the device has been fully registered+ t.boolean :active, default: false, null: false++ # Channel the OTP is delivered through+ # (e.g., voice, sms)+ t.string :channel, null: false++ # Phone number for SMS/voice actions+ t.string :phone_number, null: true++ # User-given identifier for this device+ t.string :identifier, null: false++ # Default rails timestamps+ t.timestamps precision: false++ # Last used datetime (relevant for totp)+ t.integer :last_used_at, null: true++ # OTP secret for totp+ t.text :otp_secret, null: true++ t.references :user, foreign_key: true++ t.string :webauthn_external_id,+ null: true,+ index: { unique: true, name: "index_two_factor_authentication_devices_on_webauthn_external_id" }++ t.string :webauthn_public_key, null: true+ t.bigint :webauthn_sign_count, null: false, default: 0endendenddiff --git a/modules/webhooks/db/migrate/1006015_aggregated_webhook_migrations.rb b/modules/webhooks/db/migrate/1006015_aggregated_webhook_migrations.rbnew file mode 100644index 00000000000..c3602f1b571--- /dev/null+++ b/modules/webhooks/db/migrate/1006015_aggregated_webhook_migrations.rb@@ -0,0 +1,44 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++require Rails.root.join("db/migrate/migration_utils/squashed_migration").to_s+Dir[File.join(__dir__, "tables/*.rb")].each { |file| require file }++class AggregatedWebhookMigrations < SquashedMigration+ squashed_migrations *%w[+ 20171218205557_add_webhooks+ 20171219145752_create_webhook_logs+ ]++ tables Tables::WebhooksWebhooks,+ Tables::WebhooksEvents,+ Tables::WebhooksProjects,+ Tables::WebhooksLogs+enddiff --git a/modules/webhooks/db/migrate/20171218205557_add_webhooks.rb b/modules/webhooks/db/migrate/20171218205557_add_webhooks.rbdeleted file mode 100644index 17bbe877c8e..00000000000--- a/modules/webhooks/db/migrate/20171218205557_add_webhooks.rb+++ /dev/null@@ -1,52 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class AddWebhooks < ActiveRecord::Migration[5.0]- def change- create_table :webhooks_webhooks do |t|- t.string :name- t.text :url- t.text :description, null: false- t.string :secret, null: true- t.boolean :enabled, null: false- t.boolean :all_projects, null: false-- t.timestamps- end-- create_table :webhooks_events do |t|- t.string :name- t.references :webhooks_webhook, index: true, foreign_key: true- end-- create_table :webhooks_projects do |t|- t.references :project, index: true, foreign_key: true- t.references :webhooks_webhook, index: true, foreign_key: true- end- end-enddiff --git a/modules/webhooks/db/migrate/tables/webhooks_events.rb b/modules/webhooks/db/migrate/tables/webhooks_events.rbnew file mode 100644index 00000000000..7526a0990f5--- /dev/null+++ b/modules/webhooks/db/migrate/tables/webhooks_events.rb@@ -0,0 +1,40 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::WebhooksEvents < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.string :name+ t.references :webhooks_webhook, index: true, foreign_key: true+ end+ end+enddiff --git a/modules/webhooks/db/migrate/20171219145752_create_webhook_logs.rb b/modules/webhooks/db/migrate/tables/webhooks_logs.rbsimilarity index 85%rename from modules/webhooks/db/migrate/20171219145752_create_webhook_logs.rbrename to modules/webhooks/db/migrate/tables/webhooks_logs.rbindex 218d63c6834..5731d6cf5db 100644--- a/modules/webhooks/db/migrate/20171219145752_create_webhook_logs.rb+++ b/modules/webhooks/db/migrate/tables/webhooks_logs.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH#@@ -24,11 +26,13 @@# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.-#+++# ++++require Rails.root.join("db/migrate/tables/base").to_s-class CreateWebhookLogs < ActiveRecord::Migration[5.0]- def change- create_table :webhooks_logs do |t|+class Tables::WebhooksLogs < Tables::Base+ def self.table(migration)+ create_table migration do |t|t.references :webhooks_webhook, foreign_key: { on_delete: :cascade }t.string :event_name@@ -41,7 +45,7 @@ class CreateWebhookLogs < ActiveRecord::Migration[5.0]t.text :response_headerst.text :response_body- t.timestamps+ t.timestamps precision: nilendendenddiff --git a/modules/webhooks/db/migrate/tables/webhooks_projects.rb b/modules/webhooks/db/migrate/tables/webhooks_projects.rbnew file mode 100644index 00000000000..62f11ad9e63--- /dev/null+++ b/modules/webhooks/db/migrate/tables/webhooks_projects.rb@@ -0,0 +1,40 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::WebhooksProjects < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.references :project, index: true, foreign_key: true+ t.references :webhooks_webhook, index: true, foreign_key: true+ end+ end+enddiff --git a/modules/webhooks/db/migrate/tables/webhooks_webhooks.rb b/modules/webhooks/db/migrate/tables/webhooks_webhooks.rbnew file mode 100644index 00000000000..0809fe4bb3f--- /dev/null+++ b/modules/webhooks/db/migrate/tables/webhooks_webhooks.rb@@ -0,0 +1,46 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require Rails.root.join("db/migrate/tables/base").to_s++class Tables::WebhooksWebhooks < Tables::Base+ def self.table(migration)+ create_table migration do |t|+ t.string :name+ t.text :url+ t.text :description, null: false+ t.string :secret, null: true+ t.boolean :enabled, null: false+ t.boolean :all_projects, null: false++ t.timestamps precision: nil+ end+ end+enddiff --git a/spec/migrations/add_primary_key_to_custom_fields_projects_spec.rb b/spec/migrations/add_primary_key_to_custom_fields_projects_spec.rbdeleted file mode 100644index 8a13dd09027..00000000000--- a/spec/migrations/add_primary_key_to_custom_fields_projects_spec.rb+++ /dev/null@@ -1,68 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require "spec_helper"-require Rails.root.join("db/migrate/20240917105829_add_primary_key_to_custom_fields_projects.rb")--RSpec.describe AddPrimaryKeyToCustomFieldsProjects, type: :model do- shared_association_default(:project) { create(:project) }- let(:custom_fields) { create_list(:custom_field, 5) }-- it "adds an `id` primary key column with backfilled values" do- ActiveRecord::Migration.suppress_messages { described_class.migrate(:down) }- CustomFieldsProject.reset_column_information- CustomFieldsProject.reset_primary_key-- # Avoid using factory bot here as the factory will already expect an id column if any- # test using the factory has run before.- CustomFieldsProject.insert_all(- custom_fields.map { |cf| { project_id: project.id, custom_field_id: cf.id } }- )-- aggregate_failures "no primary key column" do- expect(CustomFieldsProject.column_names).not_to include("id")- expect(CustomFieldsProject.count).to eq 5- end-- ActiveRecord::Migration.suppress_messages { described_class.migrate(:up) }- CustomFieldsProject.reset_column_information- CustomFieldsProject.reset_primary_key-- aggregate_failures "primary key column added" do- expect(CustomFieldsProject.column_names).to include("id")- expect(CustomFieldsProject.last.id).to eq 5- end-- aggregate_failures "next record increments the primary key" do- expect { create(:custom_fields_project) }.to change(CustomFieldsProject, :count).by(1)- expect(CustomFieldsProject.last.id).to eq 6- end- end-enddiff --git a/spec/migrations/add_project_attribute_roles_spec.rb b/spec/migrations/add_project_attribute_roles_spec.rbdeleted file mode 100644index 8f326411fa3..00000000000--- a/spec/migrations/add_project_attribute_roles_spec.rb+++ /dev/null@@ -1,137 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require "spec_helper"-require Rails.root.join("db/migrate/20240620115412_add_project_attribute_roles.rb")--RSpec.describe AddProjectAttributeRoles, type: :model do- # Silencing migration logs, since we are not interested in that during testing- subject { ActiveRecord::Migration.suppress_messages { described_class.new.change } }-- shared_examples_for "not changing permissions" do- it "is not changed" do- expect { subject }.not_to change { role.reload.permissions }- end-- it "does not adds any new permissions" do- expect { subject }.not_to change(RolePermission, :count)- end- end-- shared_examples_for "migration is idempotent" do- context "when the migration is ran twice" do- before { subject }-- it_behaves_like "not changing permissions"- end- end-- shared_examples_for "adding permissions" do |new_permissions|- it "adds the #{new_permissions} permissions for the role" do- public_permissions = OpenProject::AccessControl.public_permissions.map(&:name)- expect { subject }.to change { role.reload.permissions }- .from(match_array(permissions + public_permissions))- .to match_array(permissions + public_permissions + new_permissions)- end-- it "adds #{new_permissions.size} new permissions" do- expect { subject }.to change(RolePermission, :count).by(new_permissions.size)- end- end-- context "for a role not eligible to view_project_attributes" do- let!(:role) do- create(:project_role,- add_public_permissions: false,- permissions: %i[permission1 permission2])- end-- it_behaves_like "not changing permissions"- it_behaves_like "migration is idempotent"- end-- context "for a role eligible to view_project_attributes" do- let(:permissions) { %i[view_project permission1 permission2] }- let!(:role) { create(:project_role, permissions:) }-- it_behaves_like "adding permissions", %i[view_project_attributes]- it_behaves_like "migration is idempotent"- end-- context "for a role with view_project_attributes" do- let(:permissions) { %i[view_project_attributes view_project permission1 permission2] }- let!(:role) { create(:project_role, permissions:) }-- it_behaves_like "not changing permissions"- it_behaves_like "migration is idempotent"- end-- context "for a role not eligible to edit_project_attributes" do- let(:permissions) do- %i[view_project_attributes permission1 permission2]- end- let!(:role) { create(:project_role, permissions:) }-- it_behaves_like "not changing permissions"- it_behaves_like "migration is idempotent"- end-- context "for a role eligible to edit_project_attributes having view_project_attributes" do- let(:permissions) do- %i[view_project_attributes edit_project- view_project permission1 permission2]- end- let!(:role) { create(:project_role, permissions:) }-- it_behaves_like "adding permissions", %i[edit_project_attributes]- it_behaves_like "migration is idempotent"- end-- context "for a role eligible to edit_project_attributes not having view_project_attributes" do- let(:permissions) do- %i[edit_project view_project permission1 permission2]- end- let!(:role) { create(:project_role, permissions:) }-- it_behaves_like "adding permissions", %i[edit_project_attributes view_project_attributes]- it_behaves_like "migration is idempotent"- end-- context "for a role that already has the edit_project_attributes and view_project_attributes permission" do- let(:permissions) do- %i[edit_project_attributes view_project_attributes- edit_project view_project permission1 permission2]- end- let!(:role) { create(:project_role, permissions:) }-- it_behaves_like "not changing permissions"- it_behaves_like "migration is idempotent"- end-enddiff --git a/spec/migrations/add_validity_period_to_journals_spec.rb b/spec/migrations/add_validity_period_to_journals_spec.rbdeleted file mode 100644index 8268e6c5064..00000000000--- a/spec/migrations/add_validity_period_to_journals_spec.rb+++ /dev/null@@ -1,203 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require "spec_helper"-require Rails.root.join("db/migrate/20230608151123_add_validity_period_to_journals.rb")--RSpec.describe AddValidityPeriodToJournals, type: :model do- # Silencing migration logs, since we are not interested in that during testing- subject do- ActiveRecord::Migration.suppress_messages do- described_class- .new- .tap { it.migrate(:down) }- .tap { it.migrate(:up) }- end- end-- let(:zero_time) { 30.minutes.ago }- let(:initial_journal_time) { zero_time } # Created with the work package -> No conflicts- let(:second_journal_time) { zero_time + 1.minute } # Created one minute later -> Conflicts with 3- let(:third_journal_time) { zero_time + 1.minute } # Created one minute later -> Conflicts with 2- let(:fourth_journal_time) { zero_time + 2.minutes } # Created two minutes later -> Conflicts with 5, 6 and 7- let(:fourth_journal_update_time) { zero_time + 3.minutes } # Updated three minute later -> Not relevant for this migration- let(:fifth_journal_time) { zero_time + 2.minutes } # Created two minutes later -> Conflicts with 4, 6 and 7- let(:sixth_journal_time) { zero_time + 2.minutes } # Created two minutes later -> Conflicts with 5, 5 and 7- let(:seventh_journal_time) { zero_time + 2.minutes } # Created two minutes later -> Conflicts with 4, 5 and 6-- let(:work_package) do- create(:work_package) do- Journal.destroy_all- end- end-- let(:user) { create(:user) }-- # The validity_periods defined herein are completely irrelevant for the specs.- # They are just added here so that the inserted journals are valid.- # The migration will remove the validity_period column on its down migration so that data will be lost then.- let!(:initial_journal) do- create(:work_package_journal,- version: 1,- user:,- created_at: initial_journal_time,- updated_at: initial_journal_time,- validity_period: zero_time...zero_time + 1.minute,- journable: work_package).reload- end- let!(:second_journal) do- create(:work_package_journal,- version: 2,- user:,- created_at: second_journal_time,- updated_at: second_journal_time,- validity_period: zero_time + 2.minutes...zero_time + 3.minutes,- journable: work_package).reload- end- let!(:third_journal) do- create(:work_package_journal,- version: 3,- user:,- created_at: third_journal_time,- updated_at: third_journal_time,- validity_period: zero_time + 4.minutes...zero_time + 5.minutes,- journable: work_package).reload- end- let!(:fourth_journal) do- create(:work_package_journal,- version: 4,- user:,- created_at: fourth_journal_time,- updated_at: fourth_journal_update_time,- validity_period: zero_time + 6.minutes...zero_time + 7.minutes,- journable: work_package).reload- end- let!(:fifth_journal) do- create(:work_package_journal,- version: 5,- user:,- created_at: fifth_journal_time,- updated_at: fifth_journal_time,- validity_period: zero_time + 8.minutes...zero_time + 9.minutes,- journable: work_package).reload- end- let!(:sixth_journal) do- create(:work_package_journal,- version: 6,- user:,- created_at: sixth_journal_time,- updated_at: sixth_journal_time,- validity_period: zero_time + 10.minutes...zero_time + 11.minutes,- journable: work_package).reload- end- let!(:seventh_journal) do- create(:work_package_journal,- version: 7,- user:,- created_at: seventh_journal_time,- updated_at: seventh_journal_time,- validity_period: zero_time + 11.minutes...zero_time + 12.minutes,- journable: work_package).reload- end-- # Comparing DateTime objects with a precision of 1 ms proves to be difficult.- # Attempting to just do DateTime.current - 0.001.seconds fails due to floating point inaccuracies.- RSpec::Matchers.define :be_x_ms_earlier_than do |reference_time, ms|- match do |time|- reference_time.strftime("%s%L").to_i - time.strftime("%s%L").to_i == ms- end-- failure_message do |time|- "expected #{time.strftime('%Y-%m-%d %H:%M:%S.%N')} to be #{ms} ms " \- "before #{reference_time.strftime('%Y-%m-%d %H:%M:%S.%N')}, " \- "but has a difference of #{reference_time.strftime('%s%L').to_i - time.strftime('%s%L').to_i} ms"- end- end-- it "resets the overlapping journals", :aggregate_failures do # rubocop:disable RSpec/ExampleLength- subject-- initial_journal.reload- second_journal.reload- third_journal.reload- fourth_journal.reload- fifth_journal.reload- sixth_journal.reload- seventh_journal.reload-- expect(initial_journal.created_at).to be_x_ms_earlier_than initial_journal_time, 0- expect(initial_journal.updated_at).to be_x_ms_earlier_than initial_journal_time, 0- expect(initial_journal.validity_period.begin).to be_x_ms_earlier_than initial_journal_time, 0- expect(initial_journal.validity_period.end).to be_x_ms_earlier_than second_journal_time, 1-- expect(second_journal.created_at).to be_x_ms_earlier_than third_journal_time, 1- expect(second_journal.updated_at).to be_x_ms_earlier_than third_journal_time, 1- expect(second_journal.validity_period.begin).to be_x_ms_earlier_than third_journal_time, 1- expect(second_journal.validity_period.end).to be_x_ms_earlier_than third_journal_time, 0-- expect(third_journal.created_at).to be_x_ms_earlier_than third_journal_time, 0- expect(third_journal.updated_at).to be_x_ms_earlier_than third_journal_time, 0- expect(third_journal.validity_period.begin).to be_x_ms_earlier_than third_journal_time, 0- # Since the fourth journal had to be moved 3 times (by 3 ms in total) to avoid conflicts with its subsequent 3 journals,- # the validity period ends at the old fourth journal time minus 3 ms.- expect(third_journal.validity_period.end).to be_x_ms_earlier_than fourth_journal_time, 3-- # The fourth journal had to be moved 3 times to avoid conflicts with its subsequent 3 journals.- # All timestamps had to be moved by 1 ms each time.- expect(fourth_journal.created_at).to be_x_ms_earlier_than fourth_journal_time, 3- # This time is not updated at all. It already had a different time than the created_at.- # It now overlaps with the fifth, sixth and seventh journal. This can happen and is okay.- # It might e.g. be, that the comment on the journal was updated.- expect(fourth_journal.updated_at).to be_x_ms_earlier_than fourth_journal_update_time, 0- expect(fourth_journal.validity_period.begin).to be_x_ms_earlier_than fourth_journal_time, 3- expect(fourth_journal.validity_period.end).to be_x_ms_earlier_than fifth_journal_time, 2-- # The fifth journal had to be moved 2 times to avoid conflicts with its subsequent 2 journals.- # All timestamps had to be moved by 1 ms each time.- expect(fifth_journal.created_at).to be_x_ms_earlier_than fifth_journal_time, 2- expect(fifth_journal.updated_at).to be_x_ms_earlier_than fifth_journal_time, 2- expect(fifth_journal.validity_period.begin).to be_x_ms_earlier_than fifth_journal_time, 2- expect(fifth_journal.validity_period.end).to be_x_ms_earlier_than sixth_journal_time, 1-- # The sixth journal had to be moved 1 times to avoid conflicts with its subsequent 1 journals.- # All timestamps had to be moved by 1 ms.- expect(sixth_journal.created_at).to be_x_ms_earlier_than sixth_journal_time, 1- expect(sixth_journal.updated_at).to be_x_ms_earlier_than sixth_journal_time, 1- expect(sixth_journal.validity_period.begin).to be_x_ms_earlier_than sixth_journal_time, 1- expect(sixth_journal.validity_period.end).to be_x_ms_earlier_than seventh_journal_time, 0-- # The seventh journal is the last in the list of conflicting journals so it itself had not to be moved.- expect(seventh_journal.created_at).to be_x_ms_earlier_than seventh_journal_time, 0- expect(seventh_journal.updated_at).to be_x_ms_earlier_than seventh_journal_time, 0- expect(seventh_journal.validity_period.begin).to be_x_ms_earlier_than seventh_journal_time, 0- # Since it is the currently last journal, its range is open-ended.- expect(seventh_journal.validity_period.end).to be_nil- end-enddiff --git a/spec/migrations/change_default_value_of_alternative_color_spec.rb b/spec/migrations/change_default_value_of_alternative_color_spec.rbdeleted file mode 100644index d36024e12a4..00000000000--- a/spec/migrations/change_default_value_of_alternative_color_spec.rb+++ /dev/null@@ -1,116 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require "spec_helper"-require Rails.root.join("db/migrate/20240306083241_change_default_value_of_alternative_color.rb")--RSpec.describe ChangeDefaultValueOfAlternativeColor, type: :model do- context "when migrating up" do- context "when there is no custom value set" do- let(:design_color) do- DesignColor.new variable: "alternative-color",- hexcode: OpenProject::CustomStyles::ColorThemes::DEPRECATED_ALTERNATIVE_COLOR- end-- before do- design_color.save!- end-- # Silencing migration logs, since we are not interested in that during testing- subject { ActiveRecord::Migration.suppress_messages { described_class.new.up } }-- it "changes the default value" do- expect { subject }- .to change { DesignColor.where(variable: "alternative-color").first.hexcode }- .from(OpenProject::CustomStyles::ColorThemes::DEPRECATED_ALTERNATIVE_COLOR)- .to(OpenProject::CustomStyles::ColorThemes::PRIMER_PRIMARY_BUTTON_COLOR)- end- end-- context "when there is a custom value set" do- let(:design_color) do- DesignColor.new variable: "alternative-color", hexcode: "#AB1234"- end-- before do- design_color.save!- end-- # Silencing migration logs, since we are not interested in that during testing- subject { ActiveRecord::Migration.suppress_messages { described_class.new.up } }-- it "does not change the default value" do- expect { subject }- .not_to change { DesignColor.where(variable: "alternative-color").first.hexcode }- end- end- end-- context "when migrating down" do- context "when there is no custom value set" do- let(:design_color) do- DesignColor.new variable: "alternative-color",- hexcode: OpenProject::CustomStyles::ColorThemes::PRIMER_PRIMARY_BUTTON_COLOR- end-- before do- design_color.save!- end-- # Silencing migration logs, since we are not interested in that during testing- subject { ActiveRecord::Migration.suppress_messages { described_class.new.down } }-- it "changes the default value" do- expect { subject }- .to change { DesignColor.where(variable: "alternative-color").first.hexcode }- .from(OpenProject::CustomStyles::ColorThemes::PRIMER_PRIMARY_BUTTON_COLOR)- .to(OpenProject::CustomStyles::ColorThemes::DEPRECATED_ALTERNATIVE_COLOR)- end- end-- context "when there is a custom value set" do- let(:design_color) do- DesignColor.new variable: "alternative-color", hexcode: "#AB1234"- end-- before do- design_color.save!- end-- # Silencing migration logs, since we are not interested in that during testing- subject { ActiveRecord::Migration.suppress_messages { described_class.new.down } }-- it "does not change the default value" do- expect { subject }- .not_to change { DesignColor.where(variable: "alternative-color").first.hexcode }- end- end- end-enddiff --git a/spec/migrations/create_custom_field_sections_spec.rb b/spec/migrations/create_custom_field_sections_spec.rbdeleted file mode 100644index c476535305e..00000000000--- a/spec/migrations/create_custom_field_sections_spec.rb+++ /dev/null@@ -1,54 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require "spec_helper"-require Rails.root.join("db/migrate/20231123111357_create_custom_field_sections.rb")--RSpec.describe CreateCustomFieldSections, type: :model do- # Silencing migration logs, since we are not interested in that during testing- subject(:run_migration) do- ActiveRecord::Migration.suppress_messages { described_class.new.tap(&:down).tap(&:up) }- end-- it "creates the custom field section" do- create_list(:project_custom_field, 2)- create_list(:wp_custom_field, 2)-- run_migration-- expect(ProjectCustomFieldSection.count).to eq 1- expect(ProjectCustomFieldSection.first.name).to eq "Project attributes"- expect(WorkPackageCustomField.pluck(:custom_field_section_id)).to all be_nil- expect(WorkPackageCustomField.pluck(:position_in_custom_field_section)).to all be_nil- expect(ProjectCustomField.pluck(:custom_field_section_id))- .to all eq ProjectCustomFieldSection.first.id- expect(ProjectCustomField.pluck(:position_in_custom_field_section)).to eq [1, 2]- end-enddiff --git a/spec/migrations/fix_invalid_journals_spec.rb b/spec/migrations/fix_invalid_journals_spec.rbdeleted file mode 100644index cca8b0197aa..00000000000--- a/spec/migrations/fix_invalid_journals_spec.rb+++ /dev/null@@ -1,118 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require "spec_helper"-require Rails.root.join("db/migrate/20220818074150_fix_invalid_journals.rb")--RSpec.describe FixInvalidJournals, type: :model do- # Silencing migration logs, since we are not interested in that during testing- subject(:run_migration) { ActiveRecord::Migration.suppress_messages { described_class.new.up } }-- let(:attachment) { create :attachment }- let(:custom_field) { create :custom_field }- let!(:work_package_journals) { create_list :work_package_journal, 3 }-- let!(:valid_journal) do- user = create :user-- ActiveRecord::Base.connection.execute("- INSERT INTO journals- (journable_type, data_type, data_id, user_id, created_at, updated_at, validity_period)- VALUES- ('WikiContent', 'Journal::WikiContentJournal', 0, #{user.id}, '2023-07-01', '2023-07-01', '[\"2021-05-03 12:53:28.245599+00\",)')- ")-- journal = Journal.last-- ActiveRecord::Base.connection.execute("- INSERT INTO attachable_journals- (journal_id, attachment_id, filename)- VALUES- (#{journal.id}, #{attachment.id}, 'foo')- ")-- ActiveRecord::Base.connection.execute("- INSERT INTO customizable_journals- (journal_id, custom_field_id, value)- VALUES- (#{journal.id}, #{custom_field.id}, 'foo')- ")-- journal- end-- let!(:invalid_journal) do- user = create :user-- ActiveRecord::Base.connection.execute("- INSERT INTO journals- (journable_type, data_type, data_id, user_id, created_at, updated_at, validity_period)- VALUES- ('WikiContent', 'Journal::FooJournal', 0, #{user.id}, '2023-07-01',- '2023-07-01', '[\"2021-05-03 12:53:28.245599+00\",)')- ")-- journal = Journal.last-- ActiveRecord::Base.connection.execute("- INSERT INTO attachable_journals- (journal_id, attachment_id, filename)- VALUES- (#{journal.id}, #{attachment.id}, 'bar')- ")-- ActiveRecord::Base.connection.execute("- INSERT INTO customizable_journals- (journal_id, custom_field_id, value)- VALUES- (#{journal.id}, #{custom_field.id}, 'bar')- ")-- journal- end-- before do- run_migration- end-- it "removes invalid journals and its associations", :aggregate_failures do- expect(Journal.find_by(id: invalid_journal.id)).to be_nil-- expect(Journal::AttachableJournal.find_by(journal_id: invalid_journal.id)).to be_nil- expect(Journal::CustomizableJournal.find_by(journal_id: invalid_journal.id)).to be_nil-- # Keeps the valid, outdated journal- expect(Journal.find_by(id: valid_journal.id)).to be_present- expect(Journal::AttachableJournal.find_by(journal_id: valid_journal.id)).to be_present- expect(Journal::CustomizableJournal.find_by(journal_id: valid_journal.id)).to be_present-- expect(Journal.find(work_package_journals.map(&:id))).to eq work_package_journals- end-enddiff --git a/spec/migrations/fix_untranslated_work_package_roles_spec.rb b/spec/migrations/fix_untranslated_work_package_roles_spec.rbdeleted file mode 100644index de70f8de124..00000000000--- a/spec/migrations/fix_untranslated_work_package_roles_spec.rb+++ /dev/null@@ -1,94 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require "spec_helper"-require Rails.root.join("db/migrate/20240206173841_fix_untranslated_work_package_roles.rb")--RSpec.describe FixUntranslatedWorkPackageRoles, type: :model do- # Silencing migration logs, since we are not interested in that during testing- subject(:run_migration) { ActiveRecord::Migration.suppress_messages { described_class.new.up } }-- context "when work package roles are already present" do- before do- create(:work_package_role, builtin: WorkPackageRole::BUILTIN_WORK_PACKAGE_EDITOR, name: "foo")- create(:work_package_role, builtin: WorkPackageRole::BUILTIN_WORK_PACKAGE_COMMENTER, name: "bar")- create(:work_package_role, builtin: WorkPackageRole::BUILTIN_WORK_PACKAGE_VIEWER, name: "baz")- end-- it "updates them with correct names" do- expect { run_migration }- .not_to change(WorkPackageRole, :count).from(3)-- expect(WorkPackageRole.find_by(builtin: WorkPackageRole::BUILTIN_WORK_PACKAGE_EDITOR))- .to have_attributes(name: "Work package editor")- expect(WorkPackageRole.find_by(builtin: WorkPackageRole::BUILTIN_WORK_PACKAGE_COMMENTER))- .to have_attributes(name: "Work package commenter")- expect(WorkPackageRole.find_by(builtin: WorkPackageRole::BUILTIN_WORK_PACKAGE_VIEWER))- .to have_attributes(name: "Work package viewer")- end-- [- "OPENPROJECT_SEED_LOCALE",- "OPENPROJECT_DEFAULT_LANGUAGE"- ].each do |env_var_name|- describe "when #{env_var_name} is set with a non-English language", :settings_reset do- it "renames the work package roles in the language specified", :settings_reset do- with_env(env_var_name => "de") do- reset(:default_language)- run_migration- ensure- reset(:default_language)- end-- expect(WorkPackageRole.find_by(builtin: WorkPackageRole::BUILTIN_WORK_PACKAGE_EDITOR))- .to have_attributes(name: "Arbeitspaket-Bearbeiter")- expect(WorkPackageRole.find_by(builtin: WorkPackageRole::BUILTIN_WORK_PACKAGE_COMMENTER))- .to have_attributes(name: "Arbeitspaket-Kommentator")- expect(WorkPackageRole.find_by(builtin: WorkPackageRole::BUILTIN_WORK_PACKAGE_VIEWER))- .to have_attributes(name: "Arbeitspaket-Betrachter")- end- end-- describe "when #{env_var_name} is set with an unsupported language", :settings_reset do- it "uses the English name", :settings_reset do- allow(Setting).to receive(:default_language).and_return("pt-br")- run_migration-- expect(WorkPackageRole.find_by(builtin: WorkPackageRole::BUILTIN_WORK_PACKAGE_EDITOR))- .to have_attributes(name: "Work package editor")- expect(WorkPackageRole.find_by(builtin: WorkPackageRole::BUILTIN_WORK_PACKAGE_COMMENTER))- .to have_attributes(name: "Work package commenter")- expect(WorkPackageRole.find_by(builtin: WorkPackageRole::BUILTIN_WORK_PACKAGE_VIEWER))- .to have_attributes(name: "Work package viewer")- end- end- end- end-enddiff --git a/spec/migrations/migrate_legacy_default_theme_to_light_theme_spec.rb b/spec/migrations/migrate_legacy_default_theme_to_light_theme_spec.rbdeleted file mode 100644index 030ff5fe841..00000000000--- a/spec/migrations/migrate_legacy_default_theme_to_light_theme_spec.rb+++ /dev/null@@ -1,60 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require "spec_helper"-require Rails.root.join("db/migrate/20240909151818_migrate_legacy_default_theme_to_light_theme.rb")--RSpec.describe MigrateLegacyDefaultThemeToLightTheme, type: :model do- RSpec::Matchers.define_negated_matcher :not_change, :change-- # Silencing migration logs, since we are not interested in that during testing- subject(:run_migration) { ActiveRecord::Migration.suppress_messages { described_class.new.up } }-- shared_let(:user_with_default_theme) { create(:user, preferences: { settings: { theme: "default", foo: "bar" } }) }- shared_let(:user_with_light_theme) { create(:user, preferences: { settings: { theme: "light", foo: "bar" } }) }- shared_let(:user_with_light_high_contrast_theme) do- create(:user, preferences: { settings: { theme: "light_high_contrast", foo: "bar" } })- end- shared_let(:user_with_dark_theme) { create(:user, preferences: { settings: { theme: "dark", foo: "bar" } }) }-- it "sets the theme to light for users with the 'default' theme" do- expect { run_migration }- .to change { user_with_default_theme.reload.pref.settings["theme"] }- .from("default")- .to("light")- end-- it "does not change the theme for users with another theme that isn't 'default'" do- expect { run_migration }- .to not_change { user_with_light_theme.reload.pref.settings["theme"] }- .and(not_change { user_with_light_high_contrast_theme.reload.pref.settings["theme"] })- .and(not_change { user_with_dark_theme.reload.pref.settings["theme"] })- end-enddiff --git a/spec/migrations/migrate_team_planner_permissions_spec.rb b/spec/migrations/migrate_team_planner_permissions_spec.rbdeleted file mode 100644index 3ebd0b6d5a0..00000000000--- a/spec/migrations/migrate_team_planner_permissions_spec.rb+++ /dev/null@@ -1,135 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require "spec_helper"-require Rails.root.join("db/migrate/20220414085531_migrate_team_planner_permissions.rb")--RSpec.describe MigrateTeamPlannerPermissions, type: :model do- # Silencing migration logs, since we are not interested in that during testing- subject { ActiveRecord::Migration.suppress_messages { described_class.new.up } }-- shared_examples_for "not changing permissions" do- it "is not changed" do- expect { subject }.not_to change { role.reload.permissions }- end-- it "does not adds any new permissions" do- expect { subject }.not_to change(RolePermission, :count)- end- end-- shared_examples_for "migration is idempotent" do- context "when the migration is ran twice" do- before { subject }-- it_behaves_like "not changing permissions"- end- end-- shared_examples_for "adding permissions" do |new_permissions|- it "adds the #{new_permissions} permissions for the role" do- public_permissions = OpenProject::AccessControl.public_permissions.map(&:name)- expect { subject }.to change { role.reload.permissions }- .from(match_array(permissions + public_permissions))- .to match_array(permissions + public_permissions + new_permissions)- end-- it "adds #{new_permissions.size} new permissions" do- expect { subject }.to change(RolePermission, :count).by(new_permissions.size)- end- end-- context "for a role not eligible to view_team_planner" do- let!(:role) { create(:project_role, permissions: %i[permission1 permission2]) }-- it_behaves_like "not changing permissions"- it_behaves_like "migration is idempotent"- end-- context "for a role eligible to view_team_planner" do- let(:permissions) { %i[view_work_packages permission1 permission2] }- let!(:role) { create(:project_role, permissions:) }-- it_behaves_like "adding permissions", %i[view_team_planner]- it_behaves_like "migration is idempotent"- end-- context "for a role with view_team_planner" do- let(:permissions) { %i[view_team_planner view_work_packages permission1 permission2] }- let!(:role) { create(:project_role, permissions:) }-- it_behaves_like "not changing permissions"- it_behaves_like "migration is idempotent"- end-- context "for a role not eligible to manage_team_planner" do- let(:permissions) do- %i[view_team_planner view_work_packages edit_work_packages- save_queries manage_public_queries permission1 permission2]- end- let!(:role) { create(:project_role, permissions:) }-- it_behaves_like "not changing permissions"- it_behaves_like "migration is idempotent"- end-- context "for a role eligible to manage_team_planner having view_team_planner" do- let(:permissions) do- %i[view_team_planner view_work_packages add_work_packages edit_work_packages- save_queries manage_public_queries permission1 permission2]- end- let!(:role) { create(:project_role, permissions:) }-- it_behaves_like "adding permissions", %i[manage_team_planner]- it_behaves_like "migration is idempotent"- end-- context "for a role eligible to manage_team_planner not having view_team_planner" do- let(:permissions) do- %i[view_work_packages add_work_packages edit_work_packages- save_queries manage_public_queries permission1 permission2]- end- let!(:role) { create(:project_role, permissions:) }-- it_behaves_like "adding permissions", %i[manage_team_planner view_team_planner]- it_behaves_like "migration is idempotent"- end-- context "for a role that already has the manage_team_planner and view_team_planner permission" do- let(:permissions) do- %i[manage_team_planner view_team_planner view_work_packages add_work_packages- edit_work_packages save_queries manage_public_queries permission1 permission2]- end- let!(:role) { create(:project_role, permissions:) }-- it_behaves_like "not changing permissions"- it_behaves_like "migration is idempotent"- end-enddiff --git a/spec/migrations/reduce_configurable_design_variables_spec.rb b/spec/migrations/reduce_configurable_design_variables_spec.rbdeleted file mode 100644index eb1d3cde182..00000000000--- a/spec/migrations/reduce_configurable_design_variables_spec.rb+++ /dev/null@@ -1,80 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require "spec_helper"-require Rails.root.join("db/migrate/20240307102541_reduce_configurable_design_variables.rb")--RSpec.describe ReduceConfigurableDesignVariables, type: :model do- context "when migrating up" do- before do- create(:design_color, variable: "alternative-color")- create(:design_color, variable: "primary-color")- create(:design_color, variable: "primary-color-dark")- create(:design_color, variable: "content-link-color")- end-- # Silencing migration logs, since we are not interested in that during testing- subject { ActiveRecord::Migration.suppress_messages { described_class.new.up } }-- it "removes the obsolete variables and renames 'alternative-color'" do- expect { subject }- .to change(DesignColor, :count).from(4).to(2)-- expect(DesignColor.find_by(variable: "primary-button-color")).not_to be_nil- expect(DesignColor.find_by(variable: "accent-color")).not_to be_nil- expect(DesignColor.find_by(variable: "primary-color")).to be_nil- expect(DesignColor.find_by(variable: "primary-color-dark")).to be_nil- expect(DesignColor.find_by(variable: "alternative-color")).to be_nil- expect(DesignColor.find_by(variable: "content-link-color")).to be_nil- end- end-- context "when migrating down" do- before do- create(:design_color, variable: "primary-button-color")- create(:design_color, variable: "accent-color")- end-- # Silencing migration logs, since we are not interested in that during testing- subject { ActiveRecord::Migration.suppress_messages { described_class.new.down } }-- it "re-creates the removed variables and reverts the renaming" do- expect { subject }- .to change(DesignColor, :count).from(2).to(4)-- expect(DesignColor.find_by(variable: "primary-button-color")).to be_nil- expect(DesignColor.find_by(variable: "accent-color")).to be_nil- expect(DesignColor.find_by(variable: "primary-color")).not_to be_nil- expect(DesignColor.find_by(variable: "primary-color-dark")).not_to be_nil- expect(DesignColor.find_by(variable: "alternative-color")).not_to be_nil- expect(DesignColor.find_by(variable: "content-link-color")).not_to be_nil- end- end-enddiff --git a/spec/migrations/remove_project_details_widget_spec.rb b/spec/migrations/remove_project_details_widget_spec.rbdeleted file mode 100644index 18adc48b3f1..00000000000--- a/spec/migrations/remove_project_details_widget_spec.rb+++ /dev/null@@ -1,64 +0,0 @@-# frozen_string_literal: true--# -- copyright-# OpenProject is an open source project management software.-# Copyright (C) 2010-2024 the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-# ++--require "spec_helper"-require Rails.root.join("db/migrate/20241025072902_remove_project_details_widget.rb")--RSpec.describe RemoveProjectDetailsWidget, type: :model do- subject do- ActiveRecord::Migration.suppress_messages do- described_class- .new- .tap { it.migrate(:up) }- end- end-- let!(:overview) do- create(:overview) do |o|- create(:grid_widget, grid: o, identifier: "widget_a", start_row: 1, end_row: 2, start_column: 1, end_column: 2)- create(:grid_widget, grid: o, identifier: "widget_b", start_row: 1, end_row: 2, start_column: 2, end_column: 3)- create(:grid_widget, grid: o, identifier: "project_details", start_row: 2, end_row: 3, start_column: 1, end_column: 2)- create(:grid_widget, grid: o, identifier: "widget_c", start_row: 2, end_row: 3, start_column: 2, end_column: 3)- create(:grid_widget, grid: o, identifier: "widget_d", start_row: 3, end_row: 4, start_column: 1, end_column: 2)- create(:grid_widget, grid: o, identifier: "widget_1", start_row: 4, end_row: 4, start_column: 2, end_column: 3)- end- end-- it "removes only the project_details widget", :aggregate_failures do- subject-- expect(Grids::Widget.where(identifier: "project_details")).not_to exist- expect(Grids::Widget.where(identifier: "widget_a", start_row: 1, end_row: 2, start_column: 1, end_column: 2)).to exist- expect(Grids::Widget.where(identifier: "widget_b", start_row: 1, end_row: 2, start_column: 2, end_column: 3)).to exist- expect(Grids::Widget.where(identifier: "widget_c", start_row: 2, end_row: 3, start_column: 2, end_column: 3)).to exist- expect(Grids::Widget.where(identifier: "widget_d", start_row: 3, end_row: 4, start_column: 1, end_column: 2)).to exist- expect(Grids::Widget.where(identifier: "widget_1", start_row: 4, end_row: 4, start_column: 2, end_column: 3)).to exist- end-enddiff --git a/spec/migrations/remove_totals_from_childless_work_packages_spec.rb b/spec/migrations/remove_totals_from_childless_work_packages_spec.rbdeleted file mode 100644index 98325941951..00000000000--- a/spec/migrations/remove_totals_from_childless_work_packages_spec.rb+++ /dev/null@@ -1,101 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require "spec_helper"-require Rails.root.join("db/migrate/20240506091102_remove_totals_from_childless_work_packages.rb")--RSpec.describe RemoveTotalsFromChildlessWorkPackages, type: :model do- # Silencing migration logs, since we are not interested in that during testing- subject(:run_migration) do- perform_enqueued_jobs do- ActiveRecord::Migration.suppress_messages { described_class.new.up }- end- end-- shared_let(:author) { create(:user) }- shared_let(:priority) { create(:priority, name: "Normal") }- shared_let(:project) { create(:project, name: "Main project") }- shared_let(:status_new) { create(:status, name: "New") }-- before_all do- set_factory_default(:user, author)- set_factory_default(:priority, priority)- set_factory_default(:project_with_types, project)- set_factory_default(:status, status_new)- end-- describe "journal creation" do- before do- Setting.work_package_done_ratio = "field"- end-- context "when the migration is run" do- let_work_packages(<<~TABLE)- hierarchy | work | remaining work | % complete | ∑ work | ∑ remaining work | ∑ % complete- wp totals set | 5h | 3h | 40% | 5h | 3h | 40%- wp only pc set | | | 60% | | |- wp parent consistent | 10h | 4h | 60% | 20h | 8h | 60%- wp all set consistent | 10h | 4h | 60% | | |- wp child totals set | 0h | 0h | | 0h | 0h |- TABLE-- before do- run_migration- end-- it "removes totals from childless work packages" do- expect_work_packages_after_reload(table_work_packages, <<~TABLE)- hierarchy | work | remaining work | % complete | ∑ work | ∑ remaining work | ∑ % complete- wp totals set | 5h | 3h | 40% | | |- wp only pc set | | | 60% | | |- wp parent consistent | 10h | 4h | 60% | 20h | 8h | 60%- wp all set consistent | 10h | 4h | 60% | | |- wp child totals set | 0h | 0h | | | |- TABLE- end-- it "creates a journal entry only for each altered work package" do- expected_altered_work_packages = [wp_totals_set, wp_child_totals_set]- expected_altered_work_packages.each do |work_package|- expect(work_package.journals.count).to eq 2- last_journal = work_package.last_journal- expect(last_journal.user).to eq(User.system)- expect(last_journal.cause_type).to eq("system_update")- expect(last_journal.cause_feature).to eq("totals_removed_from_childless_work_packages")- end-- expected_non_altered_work_packages = table_work_packages - expected_altered_work_packages- expected_non_altered_work_packages.each do |work_package|- expect(work_package.journals.count).to eq 1- end- end- end- end-enddiff --git a/spec/migrations/rename_visible_to_admin_only_in_custom_fields_spec.rb b/spec/migrations/rename_visible_to_admin_only_in_custom_fields_spec.rbdeleted file mode 100644index a79ddd47998..00000000000--- a/spec/migrations/rename_visible_to_admin_only_in_custom_fields_spec.rb+++ /dev/null@@ -1,86 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require "spec_helper"-require Rails.root.join("db/migrate/20240805104004_rename_visible_to_admin_only_in_custom_fields.rb")--RSpec.describe RenameVisibleToAdminOnlyInCustomFields, type: :model do- after do- # Reset after each spec to ensure we have the column information up to date.- CustomField.reset_column_information- end-- context "when migrating up" do- # Roll back the migration so we can migrate up- before do- ActiveRecord::Migration.suppress_messages { described_class.new.migrate(:down) }- CustomField.reset_column_information- end-- # Silencing migration logs, since we are not interested in that during testing- subject { ActiveRecord::Migration.suppress_messages { described_class.new.migrate(:up) } }-- it "changes the visible field to admin_only and flips the value" do- ProjectCustomField.new(visible: false).save(validate: false)-- expect { subject }- .to change { CustomField.first.attributes.slice("visible", "admin_only") }- .from("visible" => false)- .to("admin_only" => true)-- # it changes the default value to false- ProjectCustomField.reset_column_information- custom_field = ProjectCustomField.new- custom_field.save(validate: false)-- expect(custom_field.admin_only).to be false- end- end-- context "when migrating down" do- subject { ActiveRecord::Migration.suppress_messages { described_class.new.migrate(:down) } }-- it "rolls back the admin_only field to visible and flips the value" do- ProjectCustomField.new(admin_only: false).save(validate: false)-- expect { subject }- .to change { CustomField.first.attributes.slice("visible", "admin_only") }- .from("admin_only" => false)- .to("visible" => true)-- # it changes the default value to tru- ProjectCustomField.reset_column_information- custom_field = ProjectCustomField.new- custom_field.save(validate: false)-- expect(custom_field.visible).to be true- end- end-enddiff --git a/spec/migrations/reorder_project_children_spec.rb b/spec/migrations/reorder_project_children_spec.rbdeleted file mode 100644index c8024cd178a..00000000000--- a/spec/migrations/reorder_project_children_spec.rb+++ /dev/null@@ -1,69 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require "spec_helper"-require Rails.root.join("db/migrate/20220202140507_reorder_project_children.rb")--RSpec.describe ReorderProjectChildren, type: :model do- # Silencing migration logs, since we are not interested in that during testing- subject(:run_migration) { ActiveRecord::Migration.suppress_messages { described_class.new.up } }-- shared_let(:parent_project_a) { create(:project, name: "ParentA") }- shared_let(:parent_project_b) { create(:project, name: "ParentB") }-- shared_let(:child_a) { create(:project, name: "A", parent: parent_project_a) }- shared_let(:child_b) { create(:project, name: "B", parent: parent_project_b) }- shared_let(:child_c) { create(:project, name: "C", parent: parent_project_a) }- shared_let(:child_d) { create(:project, name: "D", parent: parent_project_b) }- shared_let(:child_f) { create(:project, name: "F", parent: parent_project_a) }-- let(:ordered) { Project.all.reorder(:lft) }-- before do- # Update the names, including lower case to test case insensitivity- parent_project_a.update_column(:name, "ParentLast")- parent_project_b.update_column(:name, "ParentFirst")- child_a.update_column(:name, "SecondChild")- child_b.update_column(:name, "ThirdChild")- child_c.update_column(:name, "firstChild")- child_d.update_column(:name, "FourthChild")- child_f.update_column(:name, "FifthChild")- end-- it "corrects the order" do- expect(ordered.pluck(:name)).to eq %w[ParentLast SecondChild firstChild FifthChild- ParentFirst ThirdChild FourthChild]-- subject-- expect(ordered.reload.pluck(:name)).to eq %w[ParentFirst FourthChild ThirdChild- ParentLast FifthChild firstChild SecondChild]- end-enddiff --git a/spec/migrations/restore_defaults_on_empty_settings_spec.rb b/spec/migrations/restore_defaults_on_empty_settings_spec.rbdeleted file mode 100644index 3a4e37281d0..00000000000--- a/spec/migrations/restore_defaults_on_empty_settings_spec.rb+++ /dev/null@@ -1,94 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require "spec_helper"-require Rails.root.join("db/migrate/20220428071221_restore_defaults_on_empty_settings.rb")--RSpec.describe RestoreDefaultsOnEmptySettings, type: :model do- # Silencing migration logs, since we are not interested in that during testing- subject(:run_migration) { ActiveRecord::Migration.suppress_messages { described_class.new.up } }-- shared_examples_for "a successful migration of an empty setting" do- let(:setting_name) { raise "define me!" }- let(:old_value) { nil }- let(:expected_value) { raise "define me!" }-- before do- Setting.create name: setting_name, value: ""- end-- it "migrates the value to the expected value" do- expect { run_migration }- .to change { Setting.find_by(name: setting_name).value }- .from(old_value)- .to(expected_value)- end-- it "does not raise a type error" do- expect { run_migration }.not_to raise_error- end- end-- context "with an empty setting which must be an array" do- it_behaves_like "a successful migration of an empty setting" do- let(:setting_name) { "apiv3_cors_origins" }- let(:expected_value) { [] }- end- end-- context "with an empty setting which must be a string" do- it_behaves_like "a successful migration of an empty setting" do- let(:setting_name) { "default_language" }- let(:old_value) { "" }- let(:expected_value) { "en" }- end- end-- context "with an empty setting which must be a boolean" do- it_behaves_like "a successful migration of an empty setting" do- let(:setting_name) { "smtp_enable_starttls_auto" }- let(:expected_value) { false }- end- end-- context "with an empty setting which is not writable" do- let(:setting_name) { "smtp_openssl_verify_mode" }-- it "deletes the setting from the database" do- setting = Setting.new name: setting_name- setting.set_value!("", force: true)- setting.save!-- run_migration- expect(Setting.where(id: setting.id)).not_to exist- expect(Setting.send(setting_name)).to eq("peer")- end- end-enddiff --git a/spec/migrations/update_default_project_columns_spec.rb b/spec/migrations/update_default_project_columns_spec.rbdeleted file mode 100644index c8711800f7b..00000000000--- a/spec/migrations/update_default_project_columns_spec.rb+++ /dev/null@@ -1,102 +0,0 @@-# frozen_string_literal: true--# -- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-# ++--require "spec_helper"-require Rails.root.join("db/migrate/20240430143313_update_default_project_columns.rb")--RSpec.describe UpdateDefaultProjectColumns, type: :model do- # Silencing migration logs, since we are not interested in that during testing- subject(:run_migration) do- perform_enqueued_jobs do- ActiveRecord::Migration.suppress_messages { described_class.new.up }- end- end-- context "with no setting existing" do- it "does not create the setting" do- run_migration-- expect(Setting.find_by(name: "enabled_projects_columns"))- .to be_nil- end- end-- context "with the setting not having name nor favored column" do- before do- Setting.enabled_projects_columns = %w[project_status public]- end-- it "prepends favored and name" do- run_migration-- expect(Setting.find_by(name: "enabled_projects_columns").value)- .to eql %w[favored name project_status public]- end- end-- context "with the setting having name but not the favored column" do- before do- Setting.enabled_projects_columns = %w[project_status name public]- end-- it "prepends favored and name" do- run_migration-- expect(Setting.find_by(name: "enabled_projects_columns").value)- .to eql %w[favored project_status name public]- end- end-- context "with the setting not having name but the favored column" do- before do- Setting.enabled_projects_columns = %w[project_status favored public]- end-- it "prepends favored and name" do- run_migration-- expect(Setting.find_by(name: "enabled_projects_columns").value)- .to eql %w[name project_status favored public]- end- end-- context "with the setting having both name and favored column" do- before do- Setting.enabled_projects_columns = %w[project_status favored public name]- end-- it "prepends favored and name" do- run_migration-- expect(Setting.find_by(name: "enabled_projects_columns").value)- .to eql %w[project_status favored public name]- end- end-enddiff --git a/spec/migrations/update_progress_calculation_spec.rb b/spec/migrations/update_progress_calculation_spec.rbdeleted file mode 100644index 5ab274cc527..00000000000--- a/spec/migrations/update_progress_calculation_spec.rb+++ /dev/null@@ -1,924 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require "spec_helper"-require Rails.root.join("db/migrate/20240402072213_update_progress_calculation.rb")--RSpec.describe UpdateProgressCalculation, type: :model do- # Silencing migration logs, since we are not interested in that during testing- subject(:run_migration) do- perform_enqueued_jobs do- ActiveRecord::Migration.suppress_messages { described_class.new.up }- end- end-- shared_let(:author) { create(:user) }- shared_let(:priority) { create(:priority, name: "Normal") }- shared_let(:project) { create(:project, name: "Main project") }- shared_let(:status_new) { create(:status, name: "New") }-- before_all do- set_factory_default(:user, author)- set_factory_default(:priority, priority)- set_factory_default(:project, project)- set_factory_default(:project_with_types, project)- set_factory_default(:status, status_new)- end-- def expect_migrates(from:, to:)- table = create_table(from)-- run_migration-- expect_work_packages_after_reload(table.work_packages, to)-- table.work_packages- end-- describe "journal creation" do- before do- Setting.work_package_done_ratio = "field"- end-- context "when a work package progress values are not changed" do- let_work_packages(<<~TABLE)- hierarchy | work | remaining work | % complete | ∑ work | ∑ remaining work | ∑ % complete- wp all unset | | | | | |- wp only pc set | | | 60% | | |- wp parent consistent | 10h | 4h | 60% | 20h | 8h | 60%- wp all set consistent | 10h | 4h | 60% | | |- TABLE-- before do- run_migration- end-- it "does create a journal entry only for the work package with a total % complete" do- expect(wp_all_unset.journals.count).to eq(1)- expect(wp_only_pc_set.journals.count).to eq(1)- expect(wp_all_set_consistent.journals.count).to eq(1)-- # This one will receive a journal entry since we treat the total % complete field- # as if it was introduced by the migration (OP 14.0) even though the field existed before.- # But the calculation was off and we did not present the activity on the field anyway.- expect(wp_parent_consistent.journals.count).to eq(2)-- expect(wp_parent_consistent.last_journal.get_changes)- .to include("derived_done_ratio" => [nil, 60],- "cause" => [nil, { "feature" => "progress_calculation_adjusted", "type" => "system_update" }])- end- end-- context "when some work package progress values are changed" do- let_work_packages(<<~TABLE)- subject | work | remaining work | % complete- wp only w set | 10h | |- wp only rw set | | 4h |- wp both w and pc set | 10h | | 60%- wp all set inconsistent | 10h | 1h | 10%- TABLE-- before do- run_migration- end-- it "creates one and only one additional journal entry" do- table_work_packages.each do |wp|- expect(wp.journals.count).to eq(2)- end- end-- it "the journal author is the system user" do- journal = WorkPackage.last.last_journal- expect(journal.user).to eq(User.system)- end-- it "changes the lock_version of the work package" do- previous_lock_version = wp_only_w_set.lock_version- wp_only_w_set.reload- expect(wp_only_w_set.lock_version).not_to eq(previous_lock_version)- end-- it "changes the updated_at of the work package" do- wp_only_w_set.reload- expect(wp_only_w_set.updated_at).not_to eq(wp_only_w_set.created_at)- first_journal = wp_only_w_set.journals.first- expect(wp_only_w_set.updated_at).not_to eq(first_journal.updated_at)-- expect(wp_only_w_set.updated_at).to be > wp_only_w_set.created_at- last_journal = wp_only_w_set.journals.last- expect(wp_only_w_set.updated_at).to eq(last_journal.updated_at)- end- end- end-- context "when in disabled mode" do- before do- Setting.work_package_done_ratio = "disabled"- end-- it "changes progress calculation mode to work-based" do- run_migration- expect(Setting.find_by(name: "work_package_done_ratio")).to have_attributes(value: "field")- end-- it "unset all % complete values and creates a journal entry for it" do- work_packages = expect_migrates(- from: <<~TABLE,- subject | work | remaining work | % complete- wp only pc set | | | 60%- TABLE- to: <<~TABLE- subject | work | remaining work | % complete- wp only pc set | | |- TABLE- )-- wp_only_pc_set = work_packages.first- expect(wp_only_pc_set.last_journal.details).to include("done_ratio" => [60, nil])- expect(wp_only_pc_set.last_journal.cause).to eq("type" => "system_update",- "feature" => "progress_calculation_adjusted_from_disabled_mode")- end-- context "when all unset" do- it "does nothing, everything is still unset and no journal is created" do- work_packages = expect_migrates(- from: <<~TABLE,- subject | work | remaining work | % complete- wp all unset | | |- TABLE- to: <<~TABLE- subject | work | remaining work | % complete- wp all unset | | |- TABLE- )-- wp_all_unset = work_packages.first- # no new journals as nothing changed- expect(wp_all_unset.journals.count).to eq(1)- end- end-- context "when Work is set and Remaining work is unset" do- it "sets Remaining work to Work, and % Complete to 0%" do- expect_migrates(- from: <<~TABLE,- subject | work | remaining work | % complete- wp only w set | 10h | |- wp both w and pc set | 10h | | 60%- wp only w set 0h | 0h | |- TABLE- # % Complete is discarded and derived because of the "disabled" mode- to: <<~TABLE- subject | work | remaining work | % complete- wp only w set | 10h | 10h | 0%- wp both w and pc set | 10h | 10h | 0%- wp only w set 0h | 0h | 0h |- TABLE- )- end- end-- context "when Work is unset and Remaining work is set" do- it "sets Work to Remaining work, and % Complete to 0%" do- expect_migrates(- from: <<~TABLE,- subject | work | remaining work | % complete- wp only rw set | | 4h |- wp both rw and pc set | | 4h | 60%- wp only rw set 0h | | 0h |- TABLE- # % Complete is discarded and derived because of the "disabled" mode- to: <<~TABLE- subject | work | remaining work | % complete- wp only rw set | 4h | 4h | 0%- wp both rw and pc set | 4h | 4h | 0%- wp only rw set 0h | 0h | 0h |- TABLE- )- end- end-- context "when Work is greater than Remaining work" do- it "derives % Complete value" do- expect_migrates(- from: <<~TABLE,- subject | work | remaining work | % complete- wp both w and rw set | 10h | 4h |- wp both w and rw set 0h | 10h | 0h |- wp all set consistent | 10h | 4h | 60%- wp all set inconsistent | 10h | 1h | 10%- TABLE- # % Complete is discarded and derived because of the "disabled" mode- to: <<~TABLE- subject | work | remaining work | % complete- wp both w and rw set | 10h | 4h | 60%- wp both w and rw set 0h | 10h | 0h | 100%- wp all set consistent | 10h | 4h | 60%- wp all set inconsistent | 10h | 1h | 90%- TABLE- )- end- end-- context "when Work is equal to Remaining work" do- it "sets % Complete to 0%" do- expect_migrates(- from: <<~TABLE,- subject | work | remaining work | % complete- wp both w and rw set | 10h | 10h |- wp both w and rw set 0h | 0h | 0h |- wp all set inconsistent | 10h | 10h | 60%- wp all set inconsistent 0h| 0h | 0h | 60%- TABLE- # % Complete is discarded and derived because of the "disabled" mode- to: <<~TABLE- subject | work | remaining work | % complete- wp both w and rw set | 10h | 10h | 0%- wp both w and rw set 0h | 0h | 0h |- wp all set inconsistent | 10h | 10h | 0%- wp all set inconsistent 0h| 0h | 0h |- TABLE- )- end- end-- context "when Remaining work is greater than Work" do- it "sets Remaining work to Work, and % Complete to 0%" do- expect_migrates(- from: <<~TABLE,- subject | work | remaining work | % complete- wp both w and big rw set | 10h | 99h |- wp all set big wp | 10h | 99h | 60%- TABLE- # % Complete is discarded and derived because of the "disabled" mode- to: <<~TABLE- subject | work | remaining work | % complete- wp both w and big rw set | 10h | 10h | 0%- wp all set big wp | 10h | 10h | 0%- TABLE- )- end- end- end-- ###-- context "when in work-based mode" do- before do- Setting.work_package_done_ratio = "field"- end-- it "creates a journal entry for modified work packages to indicate that progress calculation was updated" do- work_package_adjusted, work_package_not_adjusted = expect_migrates(- from: <<~TABLE,- subject | work | remaining work | % complete- work package adjusted | 10h | |- work package not adjusted | 10h | 10h | 0%- TABLE- to: <<~TABLE- subject | work | remaining work | % complete- work package adjusted | 10h | 10h | 0%- work package not adjusted | 10h | 10h | 0%- TABLE- )- expect(work_package_adjusted.journals.count).to eq(2)- expect(work_package_adjusted.last_journal.cause)- .to eq("type" => "system_update",- "feature" => "progress_calculation_adjusted")- expect(work_package_not_adjusted.journals.count).to eq(1)- end-- context "when all unset" do- it "does nothing and everything is still unset" do- expect_migrates(- from: <<~TABLE,- subject | work | remaining work | % complete- wp all unset | | |- TABLE- to: <<~TABLE- subject | work | remaining work | % complete- wp all unset | | |- TABLE- )- end- end-- context "when only Work is set" do- it "sets Remaining work to Work, and % Complete to 0%" do- expect_migrates(- from: <<~TABLE,- subject | work | remaining work | % complete- wp only w set | 10h | |- wp only w set 0h | 0h | |- TABLE- to: <<~TABLE- subject | work | remaining work | % complete- wp only w set | 10h | 10h | 0%- wp only w set 0h | 0h | 0h |- TABLE- )- end- end-- context "when only Remaining work is set" do- it "sets Work to Remaining work, and % Complete to 0%" do- expect_migrates(- from: <<~TABLE,- subject | work | remaining work | % complete- wp only rw set | | 4h |- wp only rw set 0h | | 0h |- TABLE- to: <<~TABLE- subject | work | remaining work | % complete- wp only rw set | 4h | 4h | 0%- wp only rw set 0h | 0h | 0h |- TABLE- )- end- end-- context "when only % Complete is set" do- it "does nothing and % Complete is kept" do- expect_migrates(- from: <<~TABLE,- subject | work | remaining work | % complete- wp only pc set | | | 60%- TABLE- to: <<~TABLE- subject | work | remaining work | % complete- wp only pc set | | | 60%- TABLE- )- end- end-- context "when Work and % Complete are set, and Remaining work is unset" do- it "derives Remaining work from Work and % Complete" do- expect_migrates(- from: <<~TABLE,- subject | work | remaining work | % complete- wp w and pc set | 10h | | 60%- wp w and pc set 0h | 0h | | 0%- wp w and pc set 5.678h | 5.678h | | 0%- TABLE- to: <<~TABLE- subject | work | remaining work | % complete- wp w and pc set | 10h | 4h | 60%- wp w and pc set 0h | 0h | 0h |- # no rounding if rounding remaining work would exceed work- wp w and pc set 5.678h | 5.678h | 5.678h | 0%- TABLE- )- end- end-- context "when Remaining work and % Complete are set, and Work is unset" do- it "derives Work from Remaining work and % Complete" do- expect_migrates(- from: <<~TABLE,- subject | work | remaining work | % complete- wp rw and pc set | | 4h | 60%- wp rw and pc set 0% | | 4h | 0%- wp rw and pc set dec | | 4h | 67%- wp rw and pc set 0h | | 0h | 0%- wp rw and pc set 5.678h | | 5.678h | 0%- TABLE- to: <<~TABLE- subject | work | remaining work | % complete- wp rw and pc set | 10h | 4h | 60%- wp rw and pc set 0% | 4h | 4h | 0%- wp rw and pc set dec | 12.12h | 4h | 67%- wp rw and pc set 0h | 0h | 0h |- # no rounding when % complete is 0%- wp rw and pc set 5.678h | 5.678h | 5.678h | 0%- TABLE- )- end- end-- context "when Remaining work is set, % Complete is 100%, and Work is unset" do- it "sets Work to Remaining work, sets Remaining work to 0h and keep % Complete" do- expect_migrates(- from: <<~TABLE,- subject | work | remaining work | % complete- wp both rw and pc set 100% | | 4h | 100%- TABLE- to: <<~TABLE- subject | work | remaining work | % complete- wp both rw and pc set 100% | 4h | 0h | 100%- TABLE- )- end- end-- context "when Work is greater than Remaining work and % Complete is unset" do- it "derives % Complete value" do- expect_migrates(- from: <<~TABLE,- subject | work | remaining work | % complete- wp both w and rw set | 10h | 4h |- wp both w and rw set 0h | 10h | 0h |- TABLE- to: <<~TABLE- subject | work | remaining work | % complete- wp both w and rw set | 10h | 4h | 60%- wp both w and rw set 0h | 10h | 0h | 100%- TABLE- )- end- end-- context "when Work is equal to Remaining work and % Complete is unset" do- it "sets % Complete to 0%" do- expect_migrates(- from: <<~TABLE,- subject | work | remaining work | % complete- wp both w and rw set | 10h | 10h |- wp both w and rw set 0h | 0h | 0h |- TABLE- to: <<~TABLE- subject | work | remaining work | % complete- wp both w and rw set | 10h | 10h | 0%- wp both w and rw set 0h | 0h | 0h |- TABLE- )- end- end-- context "when Remaining work is greater than Work and % Complete is unset" do- it "sets Remaining work to Work, and % Complete to 0%" do- expect_migrates(- from: <<~TABLE,- subject | work | remaining work | % complete- wp both w and big rw set | 10h | 99h |- TABLE- to: <<~TABLE- subject | work | remaining work | % complete- wp both w and big rw set | 10h | 10h | 0%- TABLE- )- end- end-- context "when Work is greater than Remaining work and % Complete is set" do- it "derives % Complete value" do- expect_migrates(- from: <<~TABLE,- subject | work | remaining work | % complete- wp all set consistent | 10h | 4h | 60%- wp all set inconsistent | 10h | 1h | 10%- TABLE- to: <<~TABLE- subject | work | remaining work | % complete- wp all set consistent | 10h | 4h | 60%- wp all set inconsistent | 10h | 9h | 10%- TABLE- )- end- end-- context "when Work is equal to Remaining work and % Complete is set" do- it "sets % Complete to 0%" do- expect_migrates(- from: <<~TABLE,- subject | work | remaining work | % complete- wp all set consistent | 10h | 10h | 0%- wp all set inconsistent | 10h | 10h | 60%- wp all set 0h | 0h | 0h | 55%- TABLE- to: <<~TABLE- subject | work | remaining work | % complete- wp all set consistent | 10h | 10h | 0%- wp all set inconsistent | 10h | 4h | 60%- wp all set 0h | 0h | 0h |- TABLE- )- end- end-- context "when Remaining work is greater than Work and % Complete is set" do- it "computes Remaining work from Work and % Complete" do- expect_migrates(- from: <<~TABLE,- subject | work | remaining work | % complete- wp all set big wp | 10h | 99h | 60%- wp all set big wp round | 8h | 2.4h | 70%- TABLE- to: <<~TABLE- subject | work | remaining work | % complete- wp all set big wp | 10h | 4h | 60%- # would be 2.4000000000000004h without rounding- wp all set big wp round | 8h | 2.4h | 70%- TABLE- )- end- end- end-- ###-- context "when in status mode" do- shared_let(:status_0p_todo) { create(:status, name: "To do (0%)", default_done_ratio: 0) }- shared_let(:status_30p_doing) { create(:status, name: "Doing (30%)", default_done_ratio: 30) }- shared_let(:status_100p_done) { create(:status, name: "Done (100%)", default_done_ratio: 100) }-- before do- Setting.work_package_done_ratio = "status"- end-- it "creates a journal entry for modified work packages to indicate that progress calculation was updated" do- wp_adjusted, wp_not_adjusted = expect_migrates(- from: <<~TABLE,- subject | status | work | remaining work | % complete- wp adjusted | Done (100%) | 10h | |- wp not adjusted | Done (100%) | 10h | 0h | 100%- TABLE- to: <<~TABLE- subject | status | work | remaining work | % complete- wp adjusted | Done (100%) | 10h | 0h | 100%- wp not adjusted | Done (100%) | 10h | 0h | 100%- TABLE- )- expect(wp_adjusted.journals.count).to eq(2)- expect(wp_adjusted.last_journal.cause)- .to eq("type" => "system_update",- "feature" => "progress_calculation_adjusted")- expect(wp_not_adjusted.journals.count).to eq(1)- end-- context "when only % Complete is set, and is the same as its status" do- it "does nothing, the % Complete value is kept, work and remaining work are kept unset, and no journal is created" do- work_packages = expect_migrates(- from: <<~TABLE,- subject | status | work | remaining work | % complete- wp 0% | To do (0%) | | | 0%- wp 30% | Doing (30%) | | | 30%- wp 100% | Done (100%) | | | 100%- TABLE- to: <<~TABLE- subject | status | work | remaining work | % complete- wp 0% | To do (0%) | | | 0%- wp 30% | Doing (30%) | | | 30%- wp 100% | Done (100%) | | | 100%- TABLE- )-- work_packages.each do |wp|- # no new journals as nothing changed- expect(wp.journals.count).to eq(1)- end- end- end-- context "when % Complete is different from its status value (set or unset)" do- it "updates % Complete value to the status value, and a journal entry is created" do- work_packages = expect_migrates(- from: <<~TABLE,- subject | status | work | remaining work | % complete- wp | Doing (30%) | | |- wp 0% | To do (0%) | | | 55%- wp 30% | Doing (30%) | | | 55%- wp 100% | Done (100%) | | | 55%- TABLE- to: <<~TABLE- subject | status | work | remaining work | % complete- wp | Doing (30%) | | | 30%- wp 0% | To do (0%) | | | 0%- wp 30% | Doing (30%) | | | 30%- wp 100% | Done (100%) | | | 100%- TABLE- )-- wp = work_packages.first- # one new journal as % complete was changed- expect(wp.journals.count).to eq(2)- end- end-- context "when only Work is set" do- it "sets % Complete value to the status value, and derives Remaining work" do- expect_migrates(- from: <<~TABLE,- subject | status | work | remaining work | % complete- wp w 0% | To do (0%) | 10h | |- wp w 0% dec | To do (0%) | 5.678h | |- wp w 30% | Doing (30%) | 10h | |- wp w 100% | Done (100%) | 10h | |- wp w 0% 0h | To do (0%) | 0h | |- wp w 100% 0h| Done (100%) | 0h | |- TABLE- to: <<~TABLE- subject | status | work | remaining work | % complete- wp w 0% | To do (0%) | 10h | 10h | 0%- wp w 0% dec | To do (0%) | 5.678h | 5.678h | 0%- wp w 30% | Doing (30%) | 10h | 7h | 30%- wp w 100% | Done (100%) | 10h | 0h | 100%- wp w 0% 0h | To do (0%) | 0h | 0h | 0%- wp w 100% 0h| Done (100%) | 0h | 0h | 100%- TABLE- )- end- end-- context "when only Remaining work is set" do- it "sets % Complete value to the status value, and derives Work" do- expect_migrates(- from: <<~TABLE,- subject | status | work | remaining work | % complete- rw 0% | To do (0%) | | 10h |- rw 30% | Doing (30%) | | 7h |- rw 100% 5h | Done (100%) | | 5h |- rw 0% 0h | To do (0%) | | 0h |- rw 100% 0h | Done (100%) | | 0h |- TABLE- to: <<~TABLE- subject | status | work | remaining work | % complete- rw 0% | To do (0%) | 10h | 10h | 0%- rw 30% | Doing (30%) | 10h | 7h | 30%- rw 100% 5h | Done (100%) | 5h | 0h | 100%- rw 0% 0h | To do (0%) | 0h | 0h | 0%- rw 100% 0h | Done (100%) | 0h | 0h | 100%- TABLE- )- end- end-- context "when both Work and Remaining work are set" do- it "sets % Complete value to the status value, and derives Remaining work" do- expect_migrates(- from: <<~TABLE,- subject | status | work | remaining work | % complete- rw 0% | To do (0%) | 10h | 10h |- rw 30% 0h | Doing (30%) | 10h | 0h |- rw 30% 99h | Doing (30%) | 10h | 99h |- rw 30% 5h | Doing (30%) | 10h | 5h |- rw 30% 10h | Doing (30%) | 10h | 10h |- rw 100% | Done (100%) | 10h | 0h |- rw 0% 0h | To do (0%) | 0h | 0h |- rw 100% 0h | Done (100%) | 0h | 0h |- TABLE- to: <<~TABLE- subject | status | work | remaining work | % complete- rw 0% | To do (0%) | 10h | 10h | 0%- rw 30% 0h | Doing (30%) | 10h | 7h | 30%- rw 30% 99h | Doing (30%) | 10h | 7h | 30%- rw 30% 5h | Doing (30%) | 10h | 7h | 30%- rw 30% 10h | Doing (30%) | 10h | 7h | 30%- rw 100% | Done (100%) | 10h | 0h | 100%- rw 0% 0h | To do (0%) | 0h | 0h | 0%- rw 100% 0h | Done (100%) | 0h | 0h | 100%- TABLE- )- end- end-- context "when parent is open without any work or remaining work set, " \- "and children have a 100% complete status" do- it "sets parent total % complete to 100%" do- expect_migrates(- from: <<~TABLE,- hierarchy | status | work | remaining work | % complete- parent | To do (0%) | | | 0%- child1 | Done (100%) | 10h | 0h | 100%- child2 | Done (100%) | 10h | 0h | 100%- TABLE- to: <<~TABLE- hierarchy | status | work | remaining work | % complete | ∑ work | ∑ remaining work | ∑ % complete- parent | To do (0%) | | | 0% | 20h | 0h | 100%- child1 | Done (100%) | 10h | 0h | 100% | | |- child2 | Done (100%) | 10h | 0h | 100% | | |- TABLE- )- end- end- end-- describe "totals computation" do- context "when totals are not up-to-date" do- # rubocop:disable RSpec/ExampleLength- it "computes them" do- expect_migrates(- from: <<~TABLE,- hierarchy | work | remaining work | ∑ work | ∑ remaining work | ∑ % complete- grandparent | 10h | 1h |- parent 1 | 10h | 2h |- child 11 | 10h | 3h |- child 12 | 10h | 4h |- child 13 | 10h | 5h |- parent 2 | 10h | 6h |- child 21 | 10h | 7h |- child 22 | 10h | 8h |- child 23 | 10h | 9h |- child 24 | 10h | 10h |- TABLE- to: <<~TABLE- subject | work | remaining work | ∑ work | ∑ remaining work | ∑ % complete- grandparent | 10h | 1h | 100h | 55h | 45%- parent 1 | 10h | 2h | 40h | 14h | 65%- child 11 | 10h | 3h | | |- child 12 | 10h | 4h | | |- child 13 | 10h | 5h | | |- parent 2 | 10h | 6h | 50h | 40h | 20%- child 21 | 10h | 7h | | |- child 22 | 10h | 8h | | |- child 23 | 10h | 9h | | |- child 24 | 10h | 10h | | |- TABLE- )- end- # rubocop:enable RSpec/ExampleLength- end-- context "when total work and total remaining work are 0h" do- it "unset total % complete" do- expect_migrates(- from: <<~TABLE,- hierarchy | work | remaining work |- parent | 0h | 0h |- child | 0h | 0h |- TABLE- to: <<~TABLE- subject | work | remaining work | ∑ work | ∑ remaining work | ∑ % complete- parent | 0h | 0h | 0h | 0h |- child | 0h | 0h | | |- TABLE- )- end- end-- context "when parent does not have any work or remaining work set, " \- "and children have a 100% complete status" do- it "sets parent total % complete to 100%" do- expect_migrates(- from: <<~TABLE,- hierarchy | work | remaining work | % complete- parent | | |- child1 | 10h | 0h | 100%- child2 | 10h | 0h | 100%- TABLE- to: <<~TABLE- hierarchy | work | remaining work | % complete | ∑ work | ∑ remaining work | ∑ % complete- parent | | | | 20h | 0h | 100%- child1 | 10h | 0h | 100% | | |- child2 | 10h | 0h | 100% | | |- TABLE- )- end- end-- context "when work and remaining work are unset" do- it "does not set total work, total remaining work, and total % complete" do- expect_migrates(- from: <<~TABLE,- subject | work | remaining work | % complete- wp all unset | | |- wp 0% | | | 0%- wp 30% | | | 30%- wp 100% | | | 100%- TABLE- to: <<~TABLE- subject | work | remaining work | % complete | ∑ work | ∑ remaining work | ∑ % complete- wp all unset | | | | | |- wp 0% | | | 0% | | |- wp 30% | | | 30% | | |- wp 100% | | | 100% | | |- TABLE- )- end- end-- context "when ∑ % complete has had some values (including wrong ones)" do- let_work_packages(<<~TABLE)- hierarchy | work | remaining work | % complete | ∑ work | ∑ remaining work | ∑ % complete |- wp zero | | | 0 | | | 0 |- wp correct | 100h | 50h | 50 | 100h | 50h | 50 |- wp correct child | | | | | | |- wp wrong | | | 90 | 100h | 50h | 90 |- wp wrong child | 100h | 50h | 20 | 10h | 10h | 20 |- TABLE-- before do- run_migration- end-- it "fixes the total values and sets ∑ % complete to nil (not 0) and keeps % complete (unless wrong)" do- expect_work_packages_after_reload(table_work_packages, <<~TABLE)- subject | work | remaining work | % complete | ∑ work | ∑ remaining work | ∑ % complete |- wp zero | | | 0 | | | |- wp correct | 100h | 50h | 50 | 100h | 50h | 50 |- wp correct child | | | | | | |- wp wrong | | | 90 | 100h | 80h | 20 |- wp wrong child | 100h | 80h | 20 | | | |- TABLE- end-- it "reworks the pre migration journals to unset ∑ % complete" do- pre_journals = table_work_packages- .map(&:reload)- .flat_map { |wp| wp.journals[...-1] } # remove the last journal-- pre_journals.each do |journal|- expect(journal.get_changes.keys).not_to include("derived_done_ratio")- end- end-- it "creates no journals for work packages transitioning only ∑ % complete from 0 to nil" do- expect(wp_zero.journals.count).to eq(1)- end-- it "creates a journal for the correct work package as the old ∑ % complete value has been set to null during the job" do- expect(wp_correct.journals.count).to eq(2)-- expect(wp_correct.journals.first.get_changes.keys)- .not_to include("derived_done_ratio")-- expect(wp_correct.journals.last.get_changes["derived_done_ratio"])- .to eql [nil, 50]- end-- it "creates a journal for the work package transitioning ∑ remaining work from 50h to 80h " \- "and ∑ % complete from 90% to 20%" do- expect(wp_wrong.journals.count).to eq(2)-- expect(wp_wrong.journals.first.get_changes.keys)- .not_to include("derived_done_ratio")-- expect(wp_wrong.journals.last.get_changes).to include(- "derived_remaining_hours" => [50.0, 80.0],- "derived_done_ratio" => [nil, 20]- )- end- end- end-- describe "error during job execution" do- let_work_packages(<<~TABLE)- subject | work | remaining work | % complete- wp working | | 4h | 60%- wp breaking | | 4h | 60%- TABLE-- before do- Setting.work_package_done_ratio = "field"-- allow(Journals::CreateService)- .to receive(:new)- .with(wp_working, User.system)- .and_call_original-- allow(Journals::CreateService)- .to receive(:new)- .with(wp_breaking, User.system)- .and_return(nil)-- ActiveRecord::Migration.suppress_messages { described_class.new.up }-- begin- perform_enqueued_jobs- rescue StandardError- end- end-- it "does not create a journal entry" do- table_work_packages.each do |wp|- expect(wp.journals.count).to eq(1)- end- end-- it "does not update the work packages" do- expect_work_packages(WorkPackage.all, <<~TABLE)- subject | work | remaining work | % complete- wp working | | 4h | 60%- wp breaking | | 4h | 60%- TABLE- end- end-enddiff --git a/spec/seeders/root_seeder_standard_edition_spec.rb b/spec/seeders/root_seeder_standard_edition_spec.rbindex 88075fe7859..1adea4bac5f 100644--- a/spec/seeders/root_seeder_standard_edition_spec.rb+++ b/spec/seeders/root_seeder_standard_edition_spec.rb@@ -238,28 +238,6 @@ RSpec.describe RootSeeder,endend- describe "demo data with work package role migration having been run" do- shared_let(:root_seeder) { described_class.new }-- before_all do- # call the migration which will add data for work package roles. This- # needs to be done manually as running tests automatically calls the- # `db:test:purge` rake task.- require(Rails.root.join("db/migrate/20231128080650_add_work_package_roles"))- AddWorkPackageRoles.new.up-- with_edition("standard") do- root_seeder.seed!-- # Run background jobs as those are also triggered by seeding.- # But since those background jobs retrigger themselves, don't wrap the seeding inside a block.- perform_enqueued_jobs- end- end-- include_examples "creates standard demo data"- end-describe "demo data mock-translated in another language" doshared_let(:root_seeder) { described_class.new }diff --git a/spec/workers/work_packages/progress/migrate_remove_totals_from_childless_work_packages_job_spec.rb b/spec/workers/work_packages/progress/migrate_remove_totals_from_childless_work_packages_job_spec.rbdeleted file mode 100644index a909e332ede..00000000000--- a/spec/workers/work_packages/progress/migrate_remove_totals_from_childless_work_packages_job_spec.rb+++ /dev/null@@ -1,151 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require "rails_helper"--RSpec.describe WorkPackages::Progress::MigrateRemoveTotalsFromChildlessWorkPackagesJob do- shared_let(:user) { create(:user) }- shared_let(:priority) { create(:priority, name: "Normal") }- shared_let(:project) { create(:project, name: "Main project") }- shared_let(:status_new) { create(:status, name: "New") }-- before_all do- set_factory_default(:user, user)- set_factory_default(:priority, priority)- set_factory_default(:project_with_types, project)- set_factory_default(:status, status_new)- end-- subject(:job) { described_class }-- def expect_performing_job_changes(from:, to:)- table = create_table(from)- job.perform_now- expect_work_packages_after_reload(table.work_packages, to)- table.work_packages- end-- context "when some work packages without children have total work, total remaining work or total % complete set" do- it "unsets totals and create a journal entry" do- work_packages = expect_performing_job_changes(- from: <<~TABLE,- subject | ∑ work | ∑ remaining work | ∑ % complete- wp tw set | 5h | |- wp trw set | | 2h |- wp tpc set | | | 60%- wp tall set | 5h | 2h | 60%- TABLE- to: <<~TABLE- subject | ∑ work | ∑ remaining work | ∑ % complete- wp tw set | | |- wp trw set | | |- wp tpc set | | |- wp tall set | | |- TABLE- )- work_packages.each do |work_package|- expect(work_package.journals.count).to eq 2- last_journal = work_package.last_journal- expect(last_journal.user).to eq(User.system)- expect(last_journal.cause_type).to eq("system_update")- expect(last_journal.cause_feature).to eq("totals_removed_from_childless_work_packages")- end- end- end-- context "when some work packages without children have all totals unset" do- it "does not update them and does not create any new journal entries" do- work_packages = expect_performing_job_changes(- from: <<~TABLE,- subject | work | remaining work | % complete | ∑ work | ∑ remaining work | ∑ % complete- work package | 10h | 7h | 30% | | |- wp blank | | | | | |- TABLE- to: <<~TABLE- subject | work | remaining work | % complete | ∑ work | ∑ remaining work | ∑ % complete- work package | 10h | 7h | 30% | | |- wp blank | | | | | |- TABLE- )- work_packages.each do |work_package|- expect(work_package.journals.count).to eq 1- end- end- end-- context "when some parent work packages have total work, total remaining work or total % complete set" do- # rubocop:disable RSpec/ExampleLength- it "does not update them and does not create any new journal entries" do- work_packages = expect_performing_job_changes(- from: <<~TABLE,- hierarchy | ∑ work | ∑ remaining work | ∑ % complete- wp tw set | 5h | |- child1 | | |- wp trw set | | 2h |- child2 | | |- wp tpc set | | | 60%- child3 | | |- wp tall set | 5h | 2h | 60%- child4 | | |- TABLE- to: <<~TABLE- subject | ∑ work | ∑ remaining work | ∑ % complete- wp tw set | 5h | |- child1 | | |- wp trw set | | 2h |- child2 | | |- wp tpc set | | | 60%- child3 | | |- wp tall set | 5h | 2h | 60%- child4 | | |- TABLE- )- work_packages.each do |work_package|- expect(work_package.journals.count).to eq 1- end- end- # rubocop:enable RSpec/ExampleLength-- it "does not even try to recompute totals for parent work packages (not that job's business)" do- expect_performing_job_changes(- from: <<~TABLE,- hierarchy | work | remaining work | % complete | ∑ work | ∑ remaining work | ∑ % complete- parent | | | | | |- child | 10h | 7h | 30% | | |- TABLE- to: <<~TABLE- subject | work | remaining work | % complete | ∑ work | ∑ remaining work | ∑ % complete- parent | | | | | |- child | 10h | 7h | 30% | | |- TABLE- )- end- end-end