From 492fe24a7590bdda65bafc9417d19a228145af35 Mon Sep 17 00:00:00 2001 From: Liangjun Song <146005915+adai26@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:08:26 +0800 Subject: [PATCH] Merge pull request #20480 from overleaf/ls-convert-migration-scripts-to-esm Convert migration scripts to ESM GitOrigin-RevId: 46f04a1837ebb8244b1156af2d58162d024b6b2d --- services/web/.eastrc | 5 ++-- ...s => 20190720165251_create_migrations.mjs} | 14 +++++++--- ...e.js => 20190730093801_script_example.mjs} | 14 +++++++--- ...0190912145001_create_contacts_indexes.mjs} | 14 +++++++--- ...145002_create_deletedProjects_indexes.mjs} | 14 +++++++--- ...3_create_deletedSubscriptions_indexes.mjs} | 14 +++++++--- ...145004_create_docHistoryIndex_indexes.mjs} | 14 +++++++--- ...90912145005_create_docHistory_indexes.mjs} | 14 +++++++--- ... 20190912145006_create_docOps_indexes.mjs} | 14 +++++++--- ...912145007_create_docSnapshots_indexes.mjs} | 14 +++++++--- ...=> 20190912145008_create_docs_indexes.mjs} | 14 +++++++--- ...eate_githubSyncEntityVersions_indexes.mjs} | 14 +++++++--- ...reate_githubSyncProjectStates_indexes.mjs} | 14 +++++++--- ...ate_githubSyncUserCredentials_indexes.mjs} | 14 +++++++--- ...912145012_create_institutions_indexes.mjs} | 14 +++++++--- ...0190912145013_create_messages_indexes.mjs} | 14 +++++++--- ...12145014_create_notifications_indexes.mjs} | 14 +++++++--- ...5015_create_oauthAccessTokens_indexes.mjs} | 14 +++++++--- ...5016_create_oauthApplications_indexes.mjs} | 14 +++++++--- ...reate_oauthAuthorizationCodes_indexes.mjs} | 14 +++++++--- ...create_projectHistoryFailures_indexes.mjs} | 14 +++++++--- ...9_create_projectHistoryLabels_indexes.mjs} | 14 +++++++--- ...create_projectHistoryMetaData_indexes.mjs} | 14 +++++++--- ...reate_projectHistorySyncState_indexes.mjs} | 14 +++++++--- ..._create_projectImportFailures_indexes.mjs} | 17 +++++++---- ...2145023_create_projectInvites_indexes.mjs} | 14 +++++++--- ...0190912145024_create_projects_indexes.mjs} | 14 +++++++--- ...90912145025_create_publishers_indexes.mjs} | 14 +++++++--- ...> 20190912145026_create_rooms_indexes.mjs} | 14 +++++++--- ...27_create_spellingPreferences_indexes.mjs} | 14 +++++++--- ...12145028_create_subscriptions_indexes.mjs} | 14 +++++++--- ...=> 20190912145029_create_tags_indexes.mjs} | 14 +++++++--- ...190912145030_create_templates_indexes.mjs} | 14 +++++++--- ... 20190912145031_create_tokens_indexes.mjs} | 14 +++++++--- ...> 20190912145032_create_users_indexes.mjs} | 14 +++++++--- ...190912145033_create_userstubs_indexes.mjs} | 14 +++++++--- ...js => 20191106102104_saml-log-indexes.mjs} | 20 +++++++++---- ...0191107191318_saml-indentifiers-index.mjs} | 20 +++++++++---- ...> 20200110183327_brandVarationIdIndex.mjs} | 14 +++++++--- ...00120163346_atlas_recommended_indexes.mjs} | 14 +++++++--- ...84301_remove-duplicate-deleted-things.mjs} | 12 ++++++-- ...21103_uniqueify-deletedthings-indexes.mjs} | 14 +++++++--- ...3624_users_affiliationUnchecked_index.mjs} | 14 +++++++--- ...0200522145727_dropProjectImportFailures.js | 11 -------- ...200522145727_dropProjectImportFailures.mjs | 17 +++++++++++ ...522145741_dropProjectImportBatchRecords.js | 11 -------- ...22145741_dropProjectImportBatchRecords.mjs | 17 +++++++++++ ... => 20200608213302_saml-cache-indexes.mjs} | 14 +++++++--- ...pdate_subscriptions_manager_ids_index.mjs} | 14 +++++++--- ...6094956_active-projects-index-with-id.mjs} | 14 +++++++--- ...5_create_deletedFiles_projectId_index.mjs} | 14 +++++++--- ...407085118_token-expiry-with-ttl-index.mjs} | 14 +++++++--- ...cs_project_id_deleted_deletedAt_index.mjs} | 14 +++++++--- ...21081758_create_history_display_index.mjs} | 14 +++++++--- ...23_convert_confirmedAt_strings_to_dates.js | 11 -------- ...3_convert_confirmedAt_strings_to_dates.mjs | 17 +++++++++++ ...plit_tests_assigned_at_strings_to_dates.js | 11 -------- ...lit_tests_assigned_at_strings_to_dates.mjs | 17 +++++++++++ ...0727123346_ce_sp_backfill_deleted_files.js | 14 ---------- ...727123346_ce_sp_backfill_deleted_files.mjs | 20 +++++++++++++ ...10727150530_ce_sp_backfill_deleted_docs.js | 13 --------- ...0727150530_ce_sp_backfill_deleted_docs.mjs | 19 +++++++++++++ ...8115327_ce_sp_backfill_dummy_doc_meta.mjs} | 14 +++++++--- ... 20210924140139_splittests-name-index.mjs} | 17 +++++++---- ...0105123000_cleanup_unused_collections.mjs} | 14 +++++++--- .../20220105130000_fix_saml_indexes.js | 19 ------------- .../20220105130000_fix_saml_indexes.mjs | 28 +++++++++++++++++++ ...2095146_split_tests_analytics_enabled.mjs} | 12 ++++++-- ...11111800_create_dropboxEntities_index.mjs} | 14 +++++++--- ...15105500_create_dropboxProjects_index.mjs} | 14 +++++++--- ...17120900_create_dropboxProjects_index.mjs} | 14 +++++++--- ...220825160708_recreate_dropboxEntities.mjs} | 14 +++++++--- ...220826104236_disable_alpha_beta_program.js | 11 -------- ...20826104236_disable_alpha_beta_program.mjs | 17 +++++++++++ ...x_user_labsProgram_labsProgramGalileo.mjs} | 14 +++++++--- ...0220913105500_create_auditLog_indexes.mjs} | 14 +++++++--- ...3125500_migrate_auditLog_to_collections.js | 14 ---------- ...125500_migrate_auditLog_to_collections.mjs | 20 +++++++++++++ ...> 20220929193200_add_auditLog_indexes.mjs} | 14 +++++++--- ...1111111111_ce_sp_convert_archived_state.js | 9 ------ ...111111111_ce_sp_convert_archived_state.mjs | 15 ++++++++++ ...191857_project_history_chunks_indexes.mjs} | 14 +++++++--- ...10140452_rename_recurly_cached_status.mjs} | 14 +++++++--- ...=> 20230124092607_clear_old_2fa_setup.mjs} | 15 +++++++--- ...4844_group_invite_emails_to_lowercase.mjs} | 14 +++++++--- ...5311_fix_deleted_history_chunks_index.mjs} | 14 +++++++--- .../20230315170739_back_fill_doc_rev.js | 9 ------ .../20230315170739_back_fill_doc_rev.mjs | 15 ++++++++++ ...0405190240_oauth_refresh_tokens_index.mjs} | 14 +++++++--- ...js => 20230406125632_oauth_tokens_ttl.mjs} | 14 +++++++--- ...5212_personal_oauth_tokens_user_index.mjs} | 14 +++++++--- ...story_chunks_garbage_collection_index.mjs} | 14 +++++++--- ...230502180757_server_pro_oauth_indexes.mjs} | 14 +++++++--- ...230512100122_ensure_history_migration.mjs} | 15 +++++++--- ...153016_user_features_updated_at_index.mjs} | 14 +++++++--- ..._back_fill_gitBridge_feature_server_pro.js | 11 -------- ...back_fill_gitBridge_feature_server_pro.mjs | 18 ++++++++++++ ...scriptions_managed_users_feature_flag.mjs} | 12 ++++++-- ...1016101457_drop_history_display_index.mjs} | 14 +++++++--- ...5094810_sso_config_certificates_array.mjs} | 12 ++++++-- ... 20231030160030_managed_users_enabled.mjs} | 14 +++++++--- ...20231031164732_drop_redundant_indexes.mjs} | 14 +++++++--- ...31101153447_partial_last_opened_index.mjs} | 14 +++++++--- ...=> 20231101191643_drop_unused_indexes.mjs} | 14 +++++++--- ...231101204352_drop_unused_saas_indexes.mjs} | 14 +++++++--- ...move_doc_versions_from_docops_to_docs.mjs} | 15 +++++++--- .../20231110192205_drop_docops_collection.js | 11 -------- .../20231110192205_drop_docops_collection.mjs | 18 ++++++++++++ ...> 20231113173237_tokens_user_id_index.mjs} | 14 +++++++--- ... => 20240115172206_oauth_issuer_index.mjs} | 14 +++++++--- ...ve_deleted_users_from_token_access_refs.js | 9 ------ ...e_deleted_users_from_token_access_refs.mjs | 15 ++++++++++ ..._add_token_hmac_project_invite_tokens.mjs} | 16 +++++++---- ...31082910_remove_project_invite_tokens.mjs} | 14 +++++++--- ...8125145_cleanup_user_features_templates.js | 12 -------- ...125145_cleanup_user_features_templates.mjs | 20 +++++++++++++ ...5101055_add_ai_policy_to_group_policy.mjs} | 12 ++++++-- ...2407131109055_admin_reversed_hostname.mjs} | 12 ++++++-- ...155209_create_project_imageName_index.mjs} | 14 +++++++--- .../lib/{adapter.js => adapter.mjs} | 16 +++++++---- .../lib/{helpers.js => helpers.mjs} | 10 ++----- .../lib/{template.js => template.mjs} | 14 +++++++--- services/web/package.json | 2 +- services/web/scripts/confirmed_at_to_dates.js | 2 +- .../scripts/example/script_for_migration.js | 3 +- .../{mark_migration.js => mark_migration.mjs} | 15 ++++++---- 126 files changed, 1202 insertions(+), 557 deletions(-) rename services/web/migrations/{20190720165251_create_migrations.js => 20190720165251_create_migrations.mjs} (65%) rename services/web/migrations/{20190730093801_script_example.js => 20190730093801_script_example.mjs} (64%) rename services/web/migrations/{20190912145001_create_contacts_indexes.js => 20190912145001_create_contacts_indexes.mjs} (67%) rename services/web/migrations/{20190912145002_create_deletedProjects_indexes.js => 20190912145002_create_deletedProjects_indexes.mjs} (73%) rename services/web/migrations/{20190912145003_create_deletedSubscriptions_indexes.js => 20190912145003_create_deletedSubscriptions_indexes.mjs} (75%) rename services/web/migrations/{20190912145004_create_docHistoryIndex_indexes.js => 20190912145004_create_docHistoryIndex_indexes.mjs} (67%) rename services/web/migrations/{20190912145005_create_docHistory_indexes.js => 20190912145005_create_docHistory_indexes.mjs} (79%) rename services/web/migrations/{20190912145006_create_docOps_indexes.js => 20190912145006_create_docOps_indexes.mjs} (58%) rename services/web/migrations/{20190912145007_create_docSnapshots_indexes.js => 20190912145007_create_docSnapshots_indexes.mjs} (71%) rename services/web/migrations/{20190912145008_create_docs_indexes.js => 20190912145008_create_docs_indexes.mjs} (66%) rename services/web/migrations/{20190912145009_create_githubSyncEntityVersions_indexes.js => 20190912145009_create_githubSyncEntityVersions_indexes.mjs} (75%) rename services/web/migrations/{20190912145010_create_githubSyncProjectStates_indexes.js => 20190912145010_create_githubSyncProjectStates_indexes.mjs} (74%) rename services/web/migrations/{20190912145011_create_githubSyncUserCredentials_indexes.js => 20190912145011_create_githubSyncUserCredentials_indexes.mjs} (71%) rename services/web/migrations/{20190912145012_create_institutions_indexes.js => 20190912145012_create_institutions_indexes.mjs} (70%) rename services/web/migrations/{20190912145013_create_messages_indexes.js => 20190912145013_create_messages_indexes.mjs} (68%) rename services/web/migrations/{20190912145014_create_notifications_indexes.js => 20190912145014_create_notifications_indexes.mjs} (73%) rename services/web/migrations/{20190912145015_create_oauthAccessTokens_indexes.js => 20190912145015_create_oauthAccessTokens_indexes.mjs} (75%) rename services/web/migrations/{20190912145016_create_oauthApplications_indexes.js => 20190912145016_create_oauthApplications_indexes.mjs} (70%) rename services/web/migrations/{20190912145017_create_oauthAuthorizationCodes_indexes.js => 20190912145017_create_oauthAuthorizationCodes_indexes.mjs} (72%) rename services/web/migrations/{20190912145018_create_projectHistoryFailures_indexes.js => 20190912145018_create_projectHistoryFailures_indexes.mjs} (71%) rename services/web/migrations/{20190912145019_create_projectHistoryLabels_indexes.js => 20190912145019_create_projectHistoryLabels_indexes.mjs} (73%) rename services/web/migrations/{20190912145020_create_projectHistoryMetaData_indexes.js => 20190912145020_create_projectHistoryMetaData_indexes.mjs} (71%) rename services/web/migrations/{20190912145021_create_projectHistorySyncState_indexes.js => 20190912145021_create_projectHistorySyncState_indexes.mjs} (75%) rename services/web/migrations/{20190912145022_create_projectImportFailures_indexes.js => 20190912145022_create_projectImportFailures_indexes.mjs} (69%) rename services/web/migrations/{20190912145023_create_projectInvites_indexes.js => 20190912145023_create_projectInvites_indexes.mjs} (71%) rename services/web/migrations/{20190912145024_create_projects_indexes.js => 20190912145024_create_projects_indexes.mjs} (91%) rename services/web/migrations/{20190912145025_create_publishers_indexes.js => 20190912145025_create_publishers_indexes.mjs} (70%) rename services/web/migrations/{20190912145026_create_rooms_indexes.js => 20190912145026_create_rooms_indexes.mjs} (66%) rename services/web/migrations/{20190912145027_create_spellingPreferences_indexes.js => 20190912145027_create_spellingPreferences_indexes.mjs} (67%) rename services/web/migrations/{20190912145028_create_subscriptions_indexes.js => 20190912145028_create_subscriptions_indexes.mjs} (87%) rename services/web/migrations/{20190912145029_create_tags_indexes.js => 20190912145029_create_tags_indexes.mjs} (71%) rename services/web/migrations/{20190912145030_create_templates_indexes.js => 20190912145030_create_templates_indexes.mjs} (74%) rename services/web/migrations/{20190912145031_create_tokens_indexes.js => 20190912145031_create_tokens_indexes.mjs} (68%) rename services/web/migrations/{20190912145032_create_users_indexes.js => 20190912145032_create_users_indexes.mjs} (93%) rename services/web/migrations/{20190912145033_create_userstubs_indexes.js => 20190912145033_create_userstubs_indexes.mjs} (70%) rename services/web/migrations/{20191106102104_saml-log-indexes.js => 20191106102104_saml-log-indexes.mjs} (75%) rename services/web/migrations/{20191107191318_saml-indentifiers-index.js => 20191107191318_saml-indentifiers-index.mjs} (74%) rename services/web/migrations/{20200110183327_brandVarationIdIndex.js => 20200110183327_brandVarationIdIndex.mjs} (65%) rename services/web/migrations/{20200120163346_atlas_recommended_indexes.js => 20200120163346_atlas_recommended_indexes.mjs} (76%) rename services/web/migrations/{20200210084301_remove-duplicate-deleted-things.js => 20200210084301_remove-duplicate-deleted-things.mjs} (85%) rename services/web/migrations/{20200210121103_uniqueify-deletedthings-indexes.js => 20200210121103_uniqueify-deletedthings-indexes.mjs} (87%) rename services/web/migrations/{20200302143624_users_affiliationUnchecked_index.js => 20200302143624_users_affiliationUnchecked_index.mjs} (65%) delete mode 100644 services/web/migrations/20200522145727_dropProjectImportFailures.js create mode 100644 services/web/migrations/20200522145727_dropProjectImportFailures.mjs delete mode 100644 services/web/migrations/20200522145741_dropProjectImportBatchRecords.js create mode 100644 services/web/migrations/20200522145741_dropProjectImportBatchRecords.mjs rename services/web/migrations/{20200608213302_saml-cache-indexes.js => 20200608213302_saml-cache-indexes.mjs} (75%) rename services/web/migrations/{20200729120824_update_subscriptions_manager_ids_index.js => 20200729120824_update_subscriptions_manager_ids_index.mjs} (80%) rename services/web/migrations/{20201106094956_active-projects-index-with-id.js => 20201106094956_active-projects-index-with-id.mjs} (61%) rename services/web/migrations/{20210310111225_create_deletedFiles_projectId_index.js => 20210310111225_create_deletedFiles_projectId_index.mjs} (57%) rename services/web/migrations/{20210407085118_token-expiry-with-ttl-index.js => 20210407085118_token-expiry-with-ttl-index.mjs} (72%) rename services/web/migrations/{20210408123210_create_docs_project_id_deleted_deletedAt_index.js => 20210408123210_create_docs_project_id_deleted_deletedAt_index.mjs} (60%) rename services/web/migrations/{20210721081758_create_history_display_index.js => 20210721081758_create_history_display_index.mjs} (62%) delete mode 100644 services/web/migrations/20210726083523_convert_confirmedAt_strings_to_dates.js create mode 100644 services/web/migrations/20210726083523_convert_confirmedAt_strings_to_dates.mjs delete mode 100644 services/web/migrations/20210726083523_convert_split_tests_assigned_at_strings_to_dates.js create mode 100644 services/web/migrations/20210726083523_convert_split_tests_assigned_at_strings_to_dates.mjs delete mode 100644 services/web/migrations/20210727123346_ce_sp_backfill_deleted_files.js create mode 100644 services/web/migrations/20210727123346_ce_sp_backfill_deleted_files.mjs delete mode 100644 services/web/migrations/20210727150530_ce_sp_backfill_deleted_docs.js create mode 100644 services/web/migrations/20210727150530_ce_sp_backfill_deleted_docs.mjs rename services/web/migrations/{20210728115327_ce_sp_backfill_dummy_doc_meta.js => 20210728115327_ce_sp_backfill_dummy_doc_meta.mjs} (58%) rename services/web/migrations/{20210924140139_splittests-name-index.js => 20210924140139_splittests-name-index.mjs} (63%) rename services/web/migrations/{20220105123000_cleanup_unused_collections.js => 20220105123000_cleanup_unused_collections.mjs} (76%) delete mode 100644 services/web/migrations/20220105130000_fix_saml_indexes.js create mode 100644 services/web/migrations/20220105130000_fix_saml_indexes.mjs rename services/web/migrations/{20220222095146_split_tests_analytics_enabled.js => 20220222095146_split_tests_analytics_enabled.mjs} (87%) rename services/web/migrations/{20220811111800_create_dropboxEntities_index.js => 20220811111800_create_dropboxEntities_index.mjs} (61%) rename services/web/migrations/{20220815105500_create_dropboxProjects_index.js => 20220815105500_create_dropboxProjects_index.mjs} (64%) rename services/web/migrations/{20220817120900_create_dropboxProjects_index.js => 20220817120900_create_dropboxProjects_index.mjs} (64%) rename services/web/migrations/{20220825160708_recreate_dropboxEntities.js => 20220825160708_recreate_dropboxEntities.mjs} (82%) delete mode 100644 services/web/migrations/20220826104236_disable_alpha_beta_program.js create mode 100644 services/web/migrations/20220826104236_disable_alpha_beta_program.mjs rename services/web/migrations/{20220830140459_create_index_user_labsProgram_labsProgramGalileo.js => 20220830140459_create_index_user_labsProgram_labsProgramGalileo.mjs} (67%) rename services/web/migrations/{20220913105500_create_auditLog_indexes.js => 20220913105500_create_auditLog_indexes.mjs} (72%) delete mode 100644 services/web/migrations/20220913125500_migrate_auditLog_to_collections.js create mode 100644 services/web/migrations/20220913125500_migrate_auditLog_to_collections.mjs rename services/web/migrations/{20220929193200_add_auditLog_indexes.js => 20220929193200_add_auditLog_indexes.mjs} (74%) delete mode 100644 services/web/migrations/20221111111111_ce_sp_convert_archived_state.js create mode 100644 services/web/migrations/20221111111111_ce_sp_convert_archived_state.mjs rename services/web/migrations/{20221122191857_project_history_chunks_indexes.js => 20221122191857_project_history_chunks_indexes.mjs} (69%) rename services/web/migrations/{20230110140452_rename_recurly_cached_status.js => 20230110140452_rename_recurly_cached_status.mjs} (86%) rename services/web/migrations/{20230124092607_clear_old_2fa_setup.js => 20230124092607_clear_old_2fa_setup.mjs} (66%) rename services/web/migrations/{20230207134844_group_invite_emails_to_lowercase.js => 20230207134844_group_invite_emails_to_lowercase.mjs} (77%) rename services/web/migrations/{20230217205311_fix_deleted_history_chunks_index.js => 20230217205311_fix_deleted_history_chunks_index.mjs} (73%) delete mode 100644 services/web/migrations/20230315170739_back_fill_doc_rev.js create mode 100644 services/web/migrations/20230315170739_back_fill_doc_rev.mjs rename services/web/migrations/{20230405190240_oauth_refresh_tokens_index.js => 20230405190240_oauth_refresh_tokens_index.mjs} (87%) rename services/web/migrations/{20230406125632_oauth_tokens_ttl.js => 20230406125632_oauth_tokens_ttl.mjs} (77%) rename services/web/migrations/{20230426095212_personal_oauth_tokens_user_index.js => 20230426095212_personal_oauth_tokens_user_index.mjs} (60%) rename services/web/migrations/{20230428154643_history_chunks_garbage_collection_index.js => 20230428154643_history_chunks_garbage_collection_index.mjs} (82%) rename services/web/migrations/{20230502180757_server_pro_oauth_indexes.js => 20230502180757_server_pro_oauth_indexes.mjs} (84%) rename services/web/migrations/{20230512100122_ensure_history_migration.js => 20230512100122_ensure_history_migration.mjs} (86%) rename services/web/migrations/{20230616153016_user_features_updated_at_index.js => 20230616153016_user_features_updated_at_index.mjs} (62%) delete mode 100644 services/web/migrations/20230817081910_back_fill_gitBridge_feature_server_pro.js create mode 100644 services/web/migrations/20230817081910_back_fill_gitBridge_feature_server_pro.mjs rename services/web/migrations/{20230928092537_backfill_subscriptions_managed_users_feature_flag.js => 20230928092537_backfill_subscriptions_managed_users_feature_flag.mjs} (69%) rename services/web/migrations/{20231016101457_drop_history_display_index.js => 20231016101457_drop_history_display_index.mjs} (56%) rename services/web/migrations/{20231025094810_sso_config_certificates_array.js => 20231025094810_sso_config_certificates_array.mjs} (84%) rename services/web/migrations/{20231030160030_managed_users_enabled.js => 20231030160030_managed_users_enabled.mjs} (65%) rename services/web/migrations/{20231031164732_drop_redundant_indexes.js => 20231031164732_drop_redundant_indexes.mjs} (78%) rename services/web/migrations/{20231101153447_partial_last_opened_index.js => 20231101153447_partial_last_opened_index.mjs} (71%) rename services/web/migrations/{20231101191643_drop_unused_indexes.js => 20231101191643_drop_unused_indexes.mjs} (87%) rename services/web/migrations/{20231101204352_drop_unused_saas_indexes.js => 20231101204352_drop_unused_saas_indexes.mjs} (78%) rename services/web/migrations/{20231105000000_move_doc_versions_from_docops_to_docs.js => 20231105000000_move_doc_versions_from_docops_to_docs.mjs} (82%) delete mode 100644 services/web/migrations/20231110192205_drop_docops_collection.js create mode 100644 services/web/migrations/20231110192205_drop_docops_collection.mjs rename services/web/migrations/{20231113173237_tokens_user_id_index.js => 20231113173237_tokens_user_id_index.mjs} (58%) rename services/web/migrations/{20240115172206_oauth_issuer_index.js => 20240115172206_oauth_issuer_index.mjs} (67%) delete mode 100644 services/web/migrations/20240220130452_remove_deleted_users_from_token_access_refs.js create mode 100644 services/web/migrations/20240220130452_remove_deleted_users_from_token_access_refs.mjs rename services/web/migrations/{20240524135408_add_token_hmac_project_invite_tokens.js => 20240524135408_add_token_hmac_project_invite_tokens.mjs} (53%) rename services/web/migrations/{20240531082910_remove_project_invite_tokens.js => 20240531082910_remove_project_invite_tokens.mjs} (52%) delete mode 100644 services/web/migrations/20240618125145_cleanup_user_features_templates.js create mode 100644 services/web/migrations/20240618125145_cleanup_user_features_templates.mjs rename services/web/migrations/{20240625101055_add_ai_policy_to_group_policy.js => 20240625101055_add_ai_policy_to_group_policy.mjs} (63%) rename services/web/migrations/{202407131109055_admin_reversed_hostname.js => 202407131109055_admin_reversed_hostname.mjs} (88%) rename services/web/migrations/{20240730155209_create_project_imageName_index.js => 20240730155209_create_project_imageName_index.mjs} (55%) rename services/web/migrations/lib/{adapter.js => adapter.mjs} (72%) rename services/web/migrations/lib/{helpers.js => helpers.mjs} (90%) rename services/web/migrations/lib/{template.js => template.mjs} (67%) rename services/web/scripts/{mark_migration.js => mark_migration.mjs} (75%) diff --git a/services/web/.eastrc b/services/web/.eastrc index 6c22d9e35a..ac757c1dd9 100644 --- a/services/web/.eastrc +++ b/services/web/.eastrc @@ -1,4 +1,5 @@ { - "adapter": "./migrations/lib/adapter", - "migrationNumberFormat": "dateTime" + "adapter": "./migrations/lib/adapter.mjs", + "migrationNumberFormat": "dateTime", + "migrationExtension": "mjs" } diff --git a/services/web/migrations/20190720165251_create_migrations.js b/services/web/migrations/20190720165251_create_migrations.mjs similarity index 65% rename from services/web/migrations/20190720165251_create_migrations.js rename to services/web/migrations/20190720165251_create_migrations.mjs index c22011b8aa..c412e6eb18 100644 --- a/services/web/migrations/20190720165251_create_migrations.js +++ b/services/web/migrations/20190720165251_create_migrations.mjs @@ -1,10 +1,10 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.migrations, [ { @@ -14,7 +14,7 @@ exports.migrate = async client => { ]) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -23,3 +23,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190730093801_script_example.js b/services/web/migrations/20190730093801_script_example.mjs similarity index 64% rename from services/web/migrations/20190730093801_script_example.js rename to services/web/migrations/20190730093801_script_example.mjs index cf266e7c99..e4542d8508 100644 --- a/services/web/migrations/20190730093801_script_example.js +++ b/services/web/migrations/20190730093801_script_example.mjs @@ -8,15 +8,21 @@ * or "hello ", when User.findOne() finds something. */ -const runScript = require('../scripts/example/script_for_migration.js') +import runScript from '../scripts/example/script_for_migration.js' -exports.tags = [] +const tags = [] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await runScript() } -exports.rollback = async client => { +const rollback = async client => { const { db } = client } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145001_create_contacts_indexes.js b/services/web/migrations/20190912145001_create_contacts_indexes.mjs similarity index 67% rename from services/web/migrations/20190912145001_create_contacts_indexes.js rename to services/web/migrations/20190912145001_create_contacts_indexes.mjs index c348560d44..17b437095f 100644 --- a/services/web/migrations/20190912145001_create_contacts_indexes.js +++ b/services/web/migrations/20190912145001_create_contacts_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const indexes = [ { @@ -14,13 +14,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.contacts, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -29,3 +29,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145002_create_deletedProjects_indexes.js b/services/web/migrations/20190912145002_create_deletedProjects_indexes.mjs similarity index 73% rename from services/web/migrations/20190912145002_create_deletedProjects_indexes.js rename to services/web/migrations/20190912145002_create_deletedProjects_indexes.mjs index 6c50287e2f..9c8365ac15 100644 --- a/services/web/migrations/20190912145002_create_deletedProjects_indexes.js +++ b/services/web/migrations/20190912145002_create_deletedProjects_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const indexes = [ { @@ -19,13 +19,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.deletedProjects, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -34,3 +34,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145003_create_deletedSubscriptions_indexes.js b/services/web/migrations/20190912145003_create_deletedSubscriptions_indexes.mjs similarity index 75% rename from services/web/migrations/20190912145003_create_deletedSubscriptions_indexes.js rename to services/web/migrations/20190912145003_create_deletedSubscriptions_indexes.mjs index db94ae8b8a..6215af13b4 100644 --- a/services/web/migrations/20190912145003_create_deletedSubscriptions_indexes.js +++ b/services/web/migrations/20190912145003_create_deletedSubscriptions_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -20,13 +20,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.deletedSubscriptions, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -35,3 +35,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145004_create_docHistoryIndex_indexes.js b/services/web/migrations/20190912145004_create_docHistoryIndex_indexes.mjs similarity index 67% rename from services/web/migrations/20190912145004_create_docHistoryIndex_indexes.js rename to services/web/migrations/20190912145004_create_docHistoryIndex_indexes.mjs index 10d1931177..2582f12fcc 100644 --- a/services/web/migrations/20190912145004_create_docHistoryIndex_indexes.js +++ b/services/web/migrations/20190912145004_create_docHistoryIndex_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const indexes = [ { @@ -13,13 +13,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.docHistoryIndex, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -28,3 +28,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145005_create_docHistory_indexes.js b/services/web/migrations/20190912145005_create_docHistory_indexes.mjs similarity index 79% rename from services/web/migrations/20190912145005_create_docHistory_indexes.js rename to services/web/migrations/20190912145005_create_docHistory_indexes.mjs index 026f930a8d..22d9b4ef6c 100644 --- a/services/web/migrations/20190912145005_create_docHistory_indexes.js +++ b/services/web/migrations/20190912145005_create_docHistory_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const indexes = [ { @@ -41,13 +41,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.docHistory, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -56,3 +56,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145006_create_docOps_indexes.js b/services/web/migrations/20190912145006_create_docOps_indexes.mjs similarity index 58% rename from services/web/migrations/20190912145006_create_docOps_indexes.js rename to services/web/migrations/20190912145006_create_docOps_indexes.mjs index 31ab9c44c6..36a1faeb9c 100644 --- a/services/web/migrations/20190912145006_create_docOps_indexes.js +++ b/services/web/migrations/20190912145006_create_docOps_indexes.mjs @@ -1,6 +1,6 @@ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const indexes = [ { @@ -12,12 +12,18 @@ const indexes = [ }, ] -exports.migrate = async ({ nativeDb }) => { +const migrate = async ({ nativeDb }) => { const docOps = nativeDb.collection('docOps') await Helpers.addIndexesToCollection(docOps, indexes) } -exports.rollback = async ({ nativeDb }) => { +const rollback = async ({ nativeDb }) => { const docOps = nativeDb.collection('docOps') await Helpers.dropIndexesFromCollection(docOps, indexes) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145007_create_docSnapshots_indexes.js b/services/web/migrations/20190912145007_create_docSnapshots_indexes.mjs similarity index 71% rename from services/web/migrations/20190912145007_create_docSnapshots_indexes.js rename to services/web/migrations/20190912145007_create_docSnapshots_indexes.mjs index 554f06c475..67726460ee 100644 --- a/services/web/migrations/20190912145007_create_docSnapshots_indexes.js +++ b/services/web/migrations/20190912145007_create_docSnapshots_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const indexes = [ { @@ -20,13 +20,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.docSnapshots, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -35,3 +35,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145008_create_docs_indexes.js b/services/web/migrations/20190912145008_create_docs_indexes.mjs similarity index 66% rename from services/web/migrations/20190912145008_create_docs_indexes.js rename to services/web/migrations/20190912145008_create_docs_indexes.mjs index 82b1df3497..23cbd156e4 100644 --- a/services/web/migrations/20190912145008_create_docs_indexes.js +++ b/services/web/migrations/20190912145008_create_docs_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const indexes = [ { @@ -13,13 +13,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.docs, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -28,3 +28,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145009_create_githubSyncEntityVersions_indexes.js b/services/web/migrations/20190912145009_create_githubSyncEntityVersions_indexes.mjs similarity index 75% rename from services/web/migrations/20190912145009_create_githubSyncEntityVersions_indexes.js rename to services/web/migrations/20190912145009_create_githubSyncEntityVersions_indexes.mjs index 1822368330..cfde39951c 100644 --- a/services/web/migrations/20190912145009_create_githubSyncEntityVersions_indexes.js +++ b/services/web/migrations/20190912145009_create_githubSyncEntityVersions_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -21,13 +21,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.githubSyncEntityVersions, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -39,3 +39,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145010_create_githubSyncProjectStates_indexes.js b/services/web/migrations/20190912145010_create_githubSyncProjectStates_indexes.mjs similarity index 74% rename from services/web/migrations/20190912145010_create_githubSyncProjectStates_indexes.js rename to services/web/migrations/20190912145010_create_githubSyncProjectStates_indexes.mjs index aaae4a36e2..129560a011 100644 --- a/services/web/migrations/20190912145010_create_githubSyncProjectStates_indexes.js +++ b/services/web/migrations/20190912145010_create_githubSyncProjectStates_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -19,13 +19,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.githubSyncProjectStates, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -34,3 +34,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145011_create_githubSyncUserCredentials_indexes.js b/services/web/migrations/20190912145011_create_githubSyncUserCredentials_indexes.mjs similarity index 71% rename from services/web/migrations/20190912145011_create_githubSyncUserCredentials_indexes.js rename to services/web/migrations/20190912145011_create_githubSyncUserCredentials_indexes.mjs index b52f62f91a..a330d50fa3 100644 --- a/services/web/migrations/20190912145011_create_githubSyncUserCredentials_indexes.js +++ b/services/web/migrations/20190912145011_create_githubSyncUserCredentials_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -13,13 +13,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.githubSyncUserCredentials, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -31,3 +31,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145012_create_institutions_indexes.js b/services/web/migrations/20190912145012_create_institutions_indexes.mjs similarity index 70% rename from services/web/migrations/20190912145012_create_institutions_indexes.js rename to services/web/migrations/20190912145012_create_institutions_indexes.mjs index 6b6e124b80..75341bbe80 100644 --- a/services/web/migrations/20190912145012_create_institutions_indexes.js +++ b/services/web/migrations/20190912145012_create_institutions_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -14,13 +14,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.institutions, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -29,3 +29,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145013_create_messages_indexes.js b/services/web/migrations/20190912145013_create_messages_indexes.mjs similarity index 68% rename from services/web/migrations/20190912145013_create_messages_indexes.js rename to services/web/migrations/20190912145013_create_messages_indexes.mjs index 774aff2c1b..03ab14702a 100644 --- a/services/web/migrations/20190912145013_create_messages_indexes.js +++ b/services/web/migrations/20190912145013_create_messages_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const indexes = [ { @@ -14,13 +14,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.messages, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -29,3 +29,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145014_create_notifications_indexes.js b/services/web/migrations/20190912145014_create_notifications_indexes.mjs similarity index 73% rename from services/web/migrations/20190912145014_create_notifications_indexes.js rename to services/web/migrations/20190912145014_create_notifications_indexes.mjs index e62da86f42..becc61949e 100644 --- a/services/web/migrations/20190912145014_create_notifications_indexes.js +++ b/services/web/migrations/20190912145014_create_notifications_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const indexes = [ { @@ -26,13 +26,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.notifications, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -41,3 +41,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145015_create_oauthAccessTokens_indexes.js b/services/web/migrations/20190912145015_create_oauthAccessTokens_indexes.mjs similarity index 75% rename from services/web/migrations/20190912145015_create_oauthAccessTokens_indexes.js rename to services/web/migrations/20190912145015_create_oauthAccessTokens_indexes.mjs index 2532c8c510..7b1dfdd538 100644 --- a/services/web/migrations/20190912145015_create_oauthAccessTokens_indexes.js +++ b/services/web/migrations/20190912145015_create_oauthAccessTokens_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -21,13 +21,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.oauthAccessTokens, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -36,3 +36,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145016_create_oauthApplications_indexes.js b/services/web/migrations/20190912145016_create_oauthApplications_indexes.mjs similarity index 70% rename from services/web/migrations/20190912145016_create_oauthApplications_indexes.js rename to services/web/migrations/20190912145016_create_oauthApplications_indexes.mjs index 964fa9ebc6..7f8ad8dfd9 100644 --- a/services/web/migrations/20190912145016_create_oauthApplications_indexes.js +++ b/services/web/migrations/20190912145016_create_oauthApplications_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -14,13 +14,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.oauthApplications, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -29,3 +29,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145017_create_oauthAuthorizationCodes_indexes.js b/services/web/migrations/20190912145017_create_oauthAuthorizationCodes_indexes.mjs similarity index 72% rename from services/web/migrations/20190912145017_create_oauthAuthorizationCodes_indexes.js rename to services/web/migrations/20190912145017_create_oauthAuthorizationCodes_indexes.mjs index 0c5c8a096b..f21979bc56 100644 --- a/services/web/migrations/20190912145017_create_oauthAuthorizationCodes_indexes.js +++ b/services/web/migrations/20190912145017_create_oauthAuthorizationCodes_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -14,13 +14,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.oauthAuthorizationCodes, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -29,3 +29,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145018_create_projectHistoryFailures_indexes.js b/services/web/migrations/20190912145018_create_projectHistoryFailures_indexes.mjs similarity index 71% rename from services/web/migrations/20190912145018_create_projectHistoryFailures_indexes.js rename to services/web/migrations/20190912145018_create_projectHistoryFailures_indexes.mjs index 13161eb9c4..fa9a65a1c4 100644 --- a/services/web/migrations/20190912145018_create_projectHistoryFailures_indexes.js +++ b/services/web/migrations/20190912145018_create_projectHistoryFailures_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -13,13 +13,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.projectHistoryFailures, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -28,3 +28,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145019_create_projectHistoryLabels_indexes.js b/services/web/migrations/20190912145019_create_projectHistoryLabels_indexes.mjs similarity index 73% rename from services/web/migrations/20190912145019_create_projectHistoryLabels_indexes.js rename to services/web/migrations/20190912145019_create_projectHistoryLabels_indexes.mjs index 8cec0eae62..3181c085ec 100644 --- a/services/web/migrations/20190912145019_create_projectHistoryLabels_indexes.js +++ b/services/web/migrations/20190912145019_create_projectHistoryLabels_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -19,13 +19,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.projectHistoryLabels, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -34,3 +34,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145020_create_projectHistoryMetaData_indexes.js b/services/web/migrations/20190912145020_create_projectHistoryMetaData_indexes.mjs similarity index 71% rename from services/web/migrations/20190912145020_create_projectHistoryMetaData_indexes.js rename to services/web/migrations/20190912145020_create_projectHistoryMetaData_indexes.mjs index 4babe72f24..ef9115a8bf 100644 --- a/services/web/migrations/20190912145020_create_projectHistoryMetaData_indexes.js +++ b/services/web/migrations/20190912145020_create_projectHistoryMetaData_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -13,13 +13,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.projectHistoryMetaData, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -28,3 +28,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145021_create_projectHistorySyncState_indexes.js b/services/web/migrations/20190912145021_create_projectHistorySyncState_indexes.mjs similarity index 75% rename from services/web/migrations/20190912145021_create_projectHistorySyncState_indexes.js rename to services/web/migrations/20190912145021_create_projectHistorySyncState_indexes.mjs index 5a9e5b182d..b71edbb444 100644 --- a/services/web/migrations/20190912145021_create_projectHistorySyncState_indexes.js +++ b/services/web/migrations/20190912145021_create_projectHistorySyncState_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -20,13 +20,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.projectHistorySyncState, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -35,3 +35,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145022_create_projectImportFailures_indexes.js b/services/web/migrations/20190912145022_create_projectImportFailures_indexes.mjs similarity index 69% rename from services/web/migrations/20190912145022_create_projectImportFailures_indexes.js rename to services/web/migrations/20190912145022_create_projectImportFailures_indexes.mjs index 75e6cc162b..9ff7805a1c 100644 --- a/services/web/migrations/20190912145022_create_projectImportFailures_indexes.js +++ b/services/web/migrations/20190912145022_create_projectImportFailures_indexes.mjs @@ -1,9 +1,10 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') -const { getCollectionInternal } = require('../app/src/infrastructure/mongodb') +import Helpers from './lib/helpers.mjs' +import mongodb from '../app/src/infrastructure/mongodb.js' +const { getCollectionInternal } = mongodb -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -19,12 +20,12 @@ async function getCollection() { return await getCollectionInternal('projectImportFailures') } -exports.migrate = async client => { +const migrate = async client => { const collection = await getCollection() await Helpers.addIndexesToCollection(collection, indexes) } -exports.rollback = async client => { +const rollback = async client => { const collection = await getCollection() try { await Helpers.dropIndexesFromCollection(collection, indexes) @@ -32,3 +33,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145023_create_projectInvites_indexes.js b/services/web/migrations/20190912145023_create_projectInvites_indexes.mjs similarity index 71% rename from services/web/migrations/20190912145023_create_projectInvites_indexes.js rename to services/web/migrations/20190912145023_create_projectInvites_indexes.mjs index b3848d1d19..f490d23b18 100644 --- a/services/web/migrations/20190912145023_create_projectInvites_indexes.js +++ b/services/web/migrations/20190912145023_create_projectInvites_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const indexes = [ { @@ -20,13 +20,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.projectInvites, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -35,3 +35,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145024_create_projects_indexes.js b/services/web/migrations/20190912145024_create_projects_indexes.mjs similarity index 91% rename from services/web/migrations/20190912145024_create_projects_indexes.js rename to services/web/migrations/20190912145024_create_projects_indexes.mjs index e3f8fee8a2..6096a2c543 100644 --- a/services/web/migrations/20190912145024_create_projects_indexes.js +++ b/services/web/migrations/20190912145024_create_projects_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const indexes = [ { @@ -123,13 +123,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.projects, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -138,3 +138,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145025_create_publishers_indexes.js b/services/web/migrations/20190912145025_create_publishers_indexes.mjs similarity index 70% rename from services/web/migrations/20190912145025_create_publishers_indexes.js rename to services/web/migrations/20190912145025_create_publishers_indexes.mjs index 389e08fca0..26b2887cb6 100644 --- a/services/web/migrations/20190912145025_create_publishers_indexes.js +++ b/services/web/migrations/20190912145025_create_publishers_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -14,13 +14,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.publishers, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -29,3 +29,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145026_create_rooms_indexes.js b/services/web/migrations/20190912145026_create_rooms_indexes.mjs similarity index 66% rename from services/web/migrations/20190912145026_create_rooms_indexes.js rename to services/web/migrations/20190912145026_create_rooms_indexes.mjs index 9c455e6cf3..1f245453c1 100644 --- a/services/web/migrations/20190912145026_create_rooms_indexes.js +++ b/services/web/migrations/20190912145026_create_rooms_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const indexes = [ { @@ -13,13 +13,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.rooms, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -28,3 +28,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145027_create_spellingPreferences_indexes.js b/services/web/migrations/20190912145027_create_spellingPreferences_indexes.mjs similarity index 67% rename from services/web/migrations/20190912145027_create_spellingPreferences_indexes.js rename to services/web/migrations/20190912145027_create_spellingPreferences_indexes.mjs index c7c18dcb82..f105fcdfb4 100644 --- a/services/web/migrations/20190912145027_create_spellingPreferences_indexes.js +++ b/services/web/migrations/20190912145027_create_spellingPreferences_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const indexes = [ { @@ -13,13 +13,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.spellingPreferences, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -28,3 +28,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145028_create_subscriptions_indexes.js b/services/web/migrations/20190912145028_create_subscriptions_indexes.mjs similarity index 87% rename from services/web/migrations/20190912145028_create_subscriptions_indexes.js rename to services/web/migrations/20190912145028_create_subscriptions_indexes.mjs index a6a118de1a..012e94639e 100644 --- a/services/web/migrations/20190912145028_create_subscriptions_indexes.js +++ b/services/web/migrations/20190912145028_create_subscriptions_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -68,13 +68,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.subscriptions, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -83,3 +83,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145029_create_tags_indexes.js b/services/web/migrations/20190912145029_create_tags_indexes.mjs similarity index 71% rename from services/web/migrations/20190912145029_create_tags_indexes.js rename to services/web/migrations/20190912145029_create_tags_indexes.mjs index 2c8c9c54b0..5ca479a3b0 100644 --- a/services/web/migrations/20190912145029_create_tags_indexes.js +++ b/services/web/migrations/20190912145029_create_tags_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const indexes = [ { @@ -21,13 +21,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.tags, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -36,3 +36,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145030_create_templates_indexes.js b/services/web/migrations/20190912145030_create_templates_indexes.mjs similarity index 74% rename from services/web/migrations/20190912145030_create_templates_indexes.js rename to services/web/migrations/20190912145030_create_templates_indexes.mjs index f41f373959..ed7ddce90d 100644 --- a/services/web/migrations/20190912145030_create_templates_indexes.js +++ b/services/web/migrations/20190912145030_create_templates_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-pro', 'saas'] +const tags = ['server-pro', 'saas'] const indexes = [ { @@ -26,13 +26,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.templates, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -41,3 +41,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145031_create_tokens_indexes.js b/services/web/migrations/20190912145031_create_tokens_indexes.mjs similarity index 68% rename from services/web/migrations/20190912145031_create_tokens_indexes.js rename to services/web/migrations/20190912145031_create_tokens_indexes.mjs index 5d09104fd0..6a5f2a3253 100644 --- a/services/web/migrations/20190912145031_create_tokens_indexes.js +++ b/services/web/migrations/20190912145031_create_tokens_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const indexes = [ { @@ -15,13 +15,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.tokens, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -30,3 +30,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145032_create_users_indexes.js b/services/web/migrations/20190912145032_create_users_indexes.mjs similarity index 93% rename from services/web/migrations/20190912145032_create_users_indexes.js rename to services/web/migrations/20190912145032_create_users_indexes.mjs index b8b5c7e10b..38d1c9aff6 100644 --- a/services/web/migrations/20190912145032_create_users_indexes.js +++ b/services/web/migrations/20190912145032_create_users_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const indexes = [ { @@ -147,13 +147,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.users, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -162,3 +162,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20190912145033_create_userstubs_indexes.js b/services/web/migrations/20190912145033_create_userstubs_indexes.mjs similarity index 70% rename from services/web/migrations/20190912145033_create_userstubs_indexes.js rename to services/web/migrations/20190912145033_create_userstubs_indexes.mjs index 25f392a93e..28af185ac3 100644 --- a/services/web/migrations/20190912145033_create_userstubs_indexes.js +++ b/services/web/migrations/20190912145033_create_userstubs_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -13,13 +13,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.userstubs, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -28,3 +28,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20191106102104_saml-log-indexes.js b/services/web/migrations/20191106102104_saml-log-indexes.mjs similarity index 75% rename from services/web/migrations/20191106102104_saml-log-indexes.js rename to services/web/migrations/20191106102104_saml-log-indexes.mjs index c68d2752e2..a68a3575f8 100644 --- a/services/web/migrations/20191106102104_saml-log-indexes.js +++ b/services/web/migrations/20191106102104_saml-log-indexes.mjs @@ -1,9 +1,10 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') -const { getCollectionInternal } = require('../app/src/infrastructure/mongodb') +import Helpers from './lib/helpers.mjs' +import mongodb from '../app/src/infrastructure/mongodb.js' +const { getCollectionInternal } = mongodb -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -29,7 +30,7 @@ const indexes = [ ] // Export indexes for use in the fix-up migration 20220105130000_fix_saml_indexes.js. -exports.samlLogsIndexes = indexes +const samlLogsIndexes = indexes async function getCollection() { // This collection was incorrectly named - it should have been `samlLogs` @@ -38,12 +39,12 @@ async function getCollection() { return await getCollectionInternal('samllog') } -exports.migrate = async client => { +const migrate = async client => { const collection = await getCollection() await Helpers.addIndexesToCollection(collection, indexes) } -exports.rollback = async client => { +const rollback = async client => { const collection = await getCollection() try { await Helpers.dropIndexesFromCollection(collection, indexes) @@ -51,3 +52,10 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, + samlLogsIndexes, +} diff --git a/services/web/migrations/20191107191318_saml-indentifiers-index.js b/services/web/migrations/20191107191318_saml-indentifiers-index.mjs similarity index 74% rename from services/web/migrations/20191107191318_saml-indentifiers-index.js rename to services/web/migrations/20191107191318_saml-indentifiers-index.mjs index d5d75f2a40..a39e88d245 100644 --- a/services/web/migrations/20191107191318_saml-indentifiers-index.js +++ b/services/web/migrations/20191107191318_saml-indentifiers-index.mjs @@ -1,9 +1,10 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') -const { getCollectionInternal } = require('../app/src/infrastructure/mongodb') +import Helpers from './lib/helpers.mjs' +import mongodb from '../app/src/infrastructure/mongodb.js' +const { getCollectionInternal } = mongodb -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -17,7 +18,7 @@ const indexes = [ ] // Export indexes for use in the fix-up migration 20220105130000_fix_saml_indexes.js. -exports.usersIndexes = indexes +const usersIndexes = indexes async function getCollection() { // This collection was incorrectly named - it should have been `users` instead @@ -26,12 +27,12 @@ async function getCollection() { return await getCollectionInternal('user') } -exports.migrate = async client => { +const migrate = async client => { const collection = await getCollection() await Helpers.addIndexesToCollection(collection, indexes) } -exports.rollback = async client => { +const rollback = async client => { const collection = await getCollection() try { await Helpers.dropIndexesFromCollection(collection, indexes) @@ -39,3 +40,10 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, + usersIndexes, +} diff --git a/services/web/migrations/20200110183327_brandVarationIdIndex.js b/services/web/migrations/20200110183327_brandVarationIdIndex.mjs similarity index 65% rename from services/web/migrations/20200110183327_brandVarationIdIndex.js rename to services/web/migrations/20200110183327_brandVarationIdIndex.mjs index df1458bb6e..e85cb22fc0 100644 --- a/services/web/migrations/20200110183327_brandVarationIdIndex.js +++ b/services/web/migrations/20200110183327_brandVarationIdIndex.mjs @@ -1,6 +1,6 @@ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -11,14 +11,20 @@ const indexes = [ }, ] -exports.migrate = async ({ db }) => { +const migrate = async ({ db }) => { await Helpers.addIndexesToCollection(db.projects, indexes) } -exports.rollback = async ({ db }) => { +const rollback = async ({ db }) => { try { await Helpers.dropIndexesFromCollection(db.projects, indexes) } catch (err) { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20200120163346_atlas_recommended_indexes.js b/services/web/migrations/20200120163346_atlas_recommended_indexes.mjs similarity index 76% rename from services/web/migrations/20200120163346_atlas_recommended_indexes.js rename to services/web/migrations/20200120163346_atlas_recommended_indexes.mjs index e35fc84893..17269cf29b 100644 --- a/services/web/migrations/20200120163346_atlas_recommended_indexes.js +++ b/services/web/migrations/20200120163346_atlas_recommended_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const indexes = { docSnapshots: [{ key: { project_id: 1, ts: 1 }, name: 'project_id_1_ts_1' }], @@ -15,7 +15,7 @@ const indexes = { docs: [{ key: { project_id: 1, inS3: 1 }, name: 'project_id_1_inS3_1' }], } -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Promise.all( @@ -25,7 +25,7 @@ exports.migrate = async client => { ) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await Promise.all( @@ -34,3 +34,9 @@ exports.rollback = async client => { ) ) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20200210084301_remove-duplicate-deleted-things.js b/services/web/migrations/20200210084301_remove-duplicate-deleted-things.mjs similarity index 85% rename from services/web/migrations/20200210084301_remove-duplicate-deleted-things.js rename to services/web/migrations/20200210084301_remove-duplicate-deleted-things.mjs index 12f5f12618..004652a8e8 100644 --- a/services/web/migrations/20200210084301_remove-duplicate-deleted-things.js +++ b/services/web/migrations/20200210084301_remove-duplicate-deleted-things.mjs @@ -1,6 +1,6 @@ /* eslint-disable no-unused-vars */ -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] async function removeDuplicates(collection, field) { const duplicates = await collection.aggregate( @@ -31,12 +31,18 @@ async function removeDuplicates(collection, field) { } } -exports.migrate = async client => { +const migrate = async client => { const { db } = client await removeDuplicates(db.deletedProjects, 'deletedProjectId') await removeDuplicates(db.deletedUsers, 'deletedUserId') } -exports.rollback = async client => { +const rollback = async client => { // can't really do anything here } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20200210121103_uniqueify-deletedthings-indexes.js b/services/web/migrations/20200210121103_uniqueify-deletedthings-indexes.mjs similarity index 87% rename from services/web/migrations/20200210121103_uniqueify-deletedthings-indexes.js rename to services/web/migrations/20200210121103_uniqueify-deletedthings-indexes.mjs index b6cd640f29..2058e9c2fd 100644 --- a/services/web/migrations/20200210121103_uniqueify-deletedthings-indexes.js +++ b/services/web/migrations/20200210121103_uniqueify-deletedthings-indexes.mjs @@ -1,10 +1,10 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] -exports.migrate = async client => { +const migrate = async client => { const { db } = client // deletedUsers did not have an index before await Helpers.dropIndexesFromCollection(db.deletedProjects, [ @@ -37,7 +37,7 @@ exports.migrate = async client => { ]) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await Helpers.dropIndexesFromCollection(db.deletedProjects, [ { @@ -68,3 +68,9 @@ exports.rollback = async client => { ]) // deletedUsers did not have an index before } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20200302143624_users_affiliationUnchecked_index.js b/services/web/migrations/20200302143624_users_affiliationUnchecked_index.mjs similarity index 65% rename from services/web/migrations/20200302143624_users_affiliationUnchecked_index.js rename to services/web/migrations/20200302143624_users_affiliationUnchecked_index.mjs index 59e941b2e4..814f84a8f4 100644 --- a/services/web/migrations/20200302143624_users_affiliationUnchecked_index.js +++ b/services/web/migrations/20200302143624_users_affiliationUnchecked_index.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -exports.tags = ['saas'] +import Helpers from './lib/helpers.mjs' -const Helpers = require('./lib/helpers') +const tags = ['saas'] const indexes = [ { @@ -14,12 +14,18 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.users, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await Helpers.dropIndexesFromCollection(db.users, indexes) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20200522145727_dropProjectImportFailures.js b/services/web/migrations/20200522145727_dropProjectImportFailures.js deleted file mode 100644 index 503cac3d6f..0000000000 --- a/services/web/migrations/20200522145727_dropProjectImportFailures.js +++ /dev/null @@ -1,11 +0,0 @@ -const Helpers = require('./lib/helpers') - -exports.tags = ['saas'] - -exports.migrate = async client => { - await Helpers.dropCollection('projectImportFailures') -} - -exports.rollback = async client => { - // can't really do anything here -} diff --git a/services/web/migrations/20200522145727_dropProjectImportFailures.mjs b/services/web/migrations/20200522145727_dropProjectImportFailures.mjs new file mode 100644 index 0000000000..83fde3a146 --- /dev/null +++ b/services/web/migrations/20200522145727_dropProjectImportFailures.mjs @@ -0,0 +1,17 @@ +import Helpers from './lib/helpers.mjs' + +const tags = ['saas'] + +const migrate = async client => { + await Helpers.dropCollection('projectImportFailures') +} + +const rollback = async client => { + // can't really do anything here +} + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20200522145741_dropProjectImportBatchRecords.js b/services/web/migrations/20200522145741_dropProjectImportBatchRecords.js deleted file mode 100644 index 46f1618c34..0000000000 --- a/services/web/migrations/20200522145741_dropProjectImportBatchRecords.js +++ /dev/null @@ -1,11 +0,0 @@ -const Helpers = require('./lib/helpers') - -exports.tags = ['saas'] - -exports.migrate = async client => { - await Helpers.dropCollection('projectImportBatchRecords') -} - -exports.rollback = async client => { - // can't really do anything here -} diff --git a/services/web/migrations/20200522145741_dropProjectImportBatchRecords.mjs b/services/web/migrations/20200522145741_dropProjectImportBatchRecords.mjs new file mode 100644 index 0000000000..a725a5a563 --- /dev/null +++ b/services/web/migrations/20200522145741_dropProjectImportBatchRecords.mjs @@ -0,0 +1,17 @@ +import Helpers from './lib/helpers.mjs' + +const tags = ['saas'] + +const migrate = async client => { + await Helpers.dropCollection('projectImportBatchRecords') +} + +const rollback = async client => { + // can't really do anything here +} + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20200608213302_saml-cache-indexes.js b/services/web/migrations/20200608213302_saml-cache-indexes.mjs similarity index 75% rename from services/web/migrations/20200608213302_saml-cache-indexes.js rename to services/web/migrations/20200608213302_saml-cache-indexes.mjs index 0441e9c832..37d6c59311 100644 --- a/services/web/migrations/20200608213302_saml-cache-indexes.js +++ b/services/web/migrations/20200608213302_saml-cache-indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -21,13 +21,13 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.samlCache, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -36,3 +36,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20200729120824_update_subscriptions_manager_ids_index.js b/services/web/migrations/20200729120824_update_subscriptions_manager_ids_index.mjs similarity index 80% rename from services/web/migrations/20200729120824_update_subscriptions_manager_ids_index.js rename to services/web/migrations/20200729120824_update_subscriptions_manager_ids_index.mjs index 88f8b5979b..aaff149a1a 100644 --- a/services/web/migrations/20200729120824_update_subscriptions_manager_ids_index.js +++ b/services/web/migrations/20200729120824_update_subscriptions_manager_ids_index.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const oldIndex = { unique: true, @@ -25,14 +25,14 @@ const newIndex = { sparse: true, } -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.dropIndexesFromCollection(db.subscriptions, [oldIndex]) await Helpers.addIndexesToCollection(db.subscriptions, [newIndex]) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client try { @@ -42,3 +42,9 @@ exports.rollback = async client => { console.error('Something went wrong rolling back the migrations', err) } } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20201106094956_active-projects-index-with-id.js b/services/web/migrations/20201106094956_active-projects-index-with-id.mjs similarity index 61% rename from services/web/migrations/20201106094956_active-projects-index-with-id.js rename to services/web/migrations/20201106094956_active-projects-index-with-id.mjs index 9d341fa468..1f4a2c9b65 100644 --- a/services/web/migrations/20201106094956_active-projects-index-with-id.js +++ b/services/web/migrations/20201106094956_active-projects-index-with-id.mjs @@ -1,6 +1,6 @@ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const index = { key: { _id: 1, lastOpened: 1, active: 1 }, @@ -10,12 +10,18 @@ const index = { }, } -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.projects, [index]) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await Helpers.dropIndexesFromCollection(db.projects, [index]) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20210310111225_create_deletedFiles_projectId_index.js b/services/web/migrations/20210310111225_create_deletedFiles_projectId_index.mjs similarity index 57% rename from services/web/migrations/20210310111225_create_deletedFiles_projectId_index.js rename to services/web/migrations/20210310111225_create_deletedFiles_projectId_index.mjs index 5c9b32d84f..543f794b09 100644 --- a/services/web/migrations/20210310111225_create_deletedFiles_projectId_index.js +++ b/services/web/migrations/20210310111225_create_deletedFiles_projectId_index.mjs @@ -1,6 +1,6 @@ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const indexes = [ { @@ -11,12 +11,18 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.deletedFiles, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await Helpers.dropIndexesFromCollection(db.deletedFiles, indexes) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20210407085118_token-expiry-with-ttl-index.js b/services/web/migrations/20210407085118_token-expiry-with-ttl-index.mjs similarity index 72% rename from services/web/migrations/20210407085118_token-expiry-with-ttl-index.js rename to services/web/migrations/20210407085118_token-expiry-with-ttl-index.mjs index 7a3d428194..02e6161347 100644 --- a/services/web/migrations/20210407085118_token-expiry-with-ttl-index.js +++ b/services/web/migrations/20210407085118_token-expiry-with-ttl-index.mjs @@ -1,6 +1,6 @@ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const indexes = { tokens: [ @@ -15,7 +15,7 @@ const indexes = { ], } -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Promise.all( @@ -25,7 +25,7 @@ exports.migrate = async client => { ) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await Promise.all( @@ -34,3 +34,9 @@ exports.rollback = async client => { ) ) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20210408123210_create_docs_project_id_deleted_deletedAt_index.js b/services/web/migrations/20210408123210_create_docs_project_id_deleted_deletedAt_index.mjs similarity index 60% rename from services/web/migrations/20210408123210_create_docs_project_id_deleted_deletedAt_index.js rename to services/web/migrations/20210408123210_create_docs_project_id_deleted_deletedAt_index.mjs index 9b4352a65b..6b290368ab 100644 --- a/services/web/migrations/20210408123210_create_docs_project_id_deleted_deletedAt_index.js +++ b/services/web/migrations/20210408123210_create_docs_project_id_deleted_deletedAt_index.mjs @@ -1,6 +1,6 @@ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const indexes = [ { @@ -13,12 +13,18 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.docs, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await Helpers.dropIndexesFromCollection(db.docs, indexes) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20210721081758_create_history_display_index.js b/services/web/migrations/20210721081758_create_history_display_index.mjs similarity index 62% rename from services/web/migrations/20210721081758_create_history_display_index.js rename to services/web/migrations/20210721081758_create_history_display_index.mjs index db83fb5388..0a04a8da6b 100644 --- a/services/web/migrations/20210721081758_create_history_display_index.js +++ b/services/web/migrations/20210721081758_create_history_display_index.mjs @@ -1,6 +1,6 @@ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -11,12 +11,18 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.projects, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await Helpers.dropIndexesFromCollection(db.projects, indexes) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20210726083523_convert_confirmedAt_strings_to_dates.js b/services/web/migrations/20210726083523_convert_confirmedAt_strings_to_dates.js deleted file mode 100644 index 2593562596..0000000000 --- a/services/web/migrations/20210726083523_convert_confirmedAt_strings_to_dates.js +++ /dev/null @@ -1,11 +0,0 @@ -const updateStringDates = require('../scripts/confirmed_at_to_dates.js') - -exports.tags = ['saas'] - -exports.migrate = async client => { - await updateStringDates() -} - -exports.rollback = async client => { - /* nothing to do */ -} diff --git a/services/web/migrations/20210726083523_convert_confirmedAt_strings_to_dates.mjs b/services/web/migrations/20210726083523_convert_confirmedAt_strings_to_dates.mjs new file mode 100644 index 0000000000..1b1b9a1b2e --- /dev/null +++ b/services/web/migrations/20210726083523_convert_confirmedAt_strings_to_dates.mjs @@ -0,0 +1,17 @@ +import updateStringDates from '../scripts/confirmed_at_to_dates.js' + +const tags = ['saas'] + +const migrate = async client => { + await updateStringDates() +} + +const rollback = async client => { + /* nothing to do */ +} + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20210726083523_convert_split_tests_assigned_at_strings_to_dates.js b/services/web/migrations/20210726083523_convert_split_tests_assigned_at_strings_to_dates.js deleted file mode 100644 index 4d34e1c204..0000000000 --- a/services/web/migrations/20210726083523_convert_split_tests_assigned_at_strings_to_dates.js +++ /dev/null @@ -1,11 +0,0 @@ -const updateStringDates = require('../scripts/split_tests_assigned_at_to_dates') - -exports.tags = ['saas'] - -exports.migrate = async client => { - await updateStringDates() -} - -exports.rollback = async client => { - /* nothing to do */ -} diff --git a/services/web/migrations/20210726083523_convert_split_tests_assigned_at_strings_to_dates.mjs b/services/web/migrations/20210726083523_convert_split_tests_assigned_at_strings_to_dates.mjs new file mode 100644 index 0000000000..1b1b9a1b2e --- /dev/null +++ b/services/web/migrations/20210726083523_convert_split_tests_assigned_at_strings_to_dates.mjs @@ -0,0 +1,17 @@ +import updateStringDates from '../scripts/confirmed_at_to_dates.js' + +const tags = ['saas'] + +const migrate = async client => { + await updateStringDates() +} + +const rollback = async client => { + /* nothing to do */ +} + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20210727123346_ce_sp_backfill_deleted_files.js b/services/web/migrations/20210727123346_ce_sp_backfill_deleted_files.js deleted file mode 100644 index fd2250be88..0000000000 --- a/services/web/migrations/20210727123346_ce_sp_backfill_deleted_files.js +++ /dev/null @@ -1,14 +0,0 @@ -const runScript = require('../scripts/back_fill_deleted_files.js') - -exports.tags = ['server-ce', 'server-pro', 'saas'] - -exports.migrate = async client => { - const options = { - performCleanup: true, - letUserDoubleCheckInputsFor: 10, - fixPartialInserts: true, - } - await runScript(options) -} - -exports.rollback = async client => {} diff --git a/services/web/migrations/20210727123346_ce_sp_backfill_deleted_files.mjs b/services/web/migrations/20210727123346_ce_sp_backfill_deleted_files.mjs new file mode 100644 index 0000000000..9b7b1de355 --- /dev/null +++ b/services/web/migrations/20210727123346_ce_sp_backfill_deleted_files.mjs @@ -0,0 +1,20 @@ +import runScript from '../scripts/back_fill_deleted_files.js' + +const tags = ['server-ce', 'server-pro', 'saas'] + +const migrate = async client => { + const options = { + performCleanup: true, + letUserDoubleCheckInputsFor: 10, + fixPartialInserts: true, + } + await runScript(options) +} + +const rollback = async client => {} + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20210727150530_ce_sp_backfill_deleted_docs.js b/services/web/migrations/20210727150530_ce_sp_backfill_deleted_docs.js deleted file mode 100644 index 79c007cf0d..0000000000 --- a/services/web/migrations/20210727150530_ce_sp_backfill_deleted_docs.js +++ /dev/null @@ -1,13 +0,0 @@ -const runScript = require('../scripts/back_fill_doc_name_for_deleted_docs.js') - -exports.tags = ['server-ce', 'server-pro', 'saas'] - -exports.migrate = async client => { - const options = { - performCleanup: true, - letUserDoubleCheckInputsFor: 10, - } - await runScript(options) -} - -exports.rollback = async client => {} diff --git a/services/web/migrations/20210727150530_ce_sp_backfill_deleted_docs.mjs b/services/web/migrations/20210727150530_ce_sp_backfill_deleted_docs.mjs new file mode 100644 index 0000000000..e43595aa34 --- /dev/null +++ b/services/web/migrations/20210727150530_ce_sp_backfill_deleted_docs.mjs @@ -0,0 +1,19 @@ +import runScript from '../scripts/back_fill_doc_name_for_deleted_docs.js' + +const tags = ['server-ce', 'server-pro', 'saas'] + +const migrate = async client => { + const options = { + performCleanup: true, + letUserDoubleCheckInputsFor: 10, + } + await runScript(options) +} + +const rollback = async client => {} + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20210728115327_ce_sp_backfill_dummy_doc_meta.js b/services/web/migrations/20210728115327_ce_sp_backfill_dummy_doc_meta.mjs similarity index 58% rename from services/web/migrations/20210728115327_ce_sp_backfill_dummy_doc_meta.js rename to services/web/migrations/20210728115327_ce_sp_backfill_dummy_doc_meta.mjs index 37e9664c4d..265e364514 100644 --- a/services/web/migrations/20210728115327_ce_sp_backfill_dummy_doc_meta.js +++ b/services/web/migrations/20210728115327_ce_sp_backfill_dummy_doc_meta.mjs @@ -1,8 +1,8 @@ -const runScript = require('../scripts/back_fill_dummy_doc_meta.js') +import runScript from '../scripts/back_fill_dummy_doc_meta.js' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] -exports.migrate = async client => { +const migrate = async client => { const { db } = client const [firstProject] = await db.projects .find() @@ -20,4 +20,10 @@ exports.migrate = async client => { await runScript(options) } -exports.rollback = async client => {} +const rollback = async client => {} + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20210924140139_splittests-name-index.js b/services/web/migrations/20210924140139_splittests-name-index.mjs similarity index 63% rename from services/web/migrations/20210924140139_splittests-name-index.js rename to services/web/migrations/20210924140139_splittests-name-index.mjs index 169576eb0c..e6cdd7cd32 100644 --- a/services/web/migrations/20210924140139_splittests-name-index.js +++ b/services/web/migrations/20210924140139_splittests-name-index.mjs @@ -1,7 +1,8 @@ -const Helpers = require('./lib/helpers') -const { getCollectionInternal } = require('../app/src/infrastructure/mongodb') +import Helpers from './lib/helpers.mjs' +import mongodb from '../app/src/infrastructure/mongodb.js' +const { getCollectionInternal } = mongodb -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -18,12 +19,18 @@ async function getCollection() { return await getCollectionInternal('splittests') } -exports.migrate = async client => { +const migrate = async client => { const collection = await getCollection() await Helpers.addIndexesToCollection(collection, indexes) } -exports.rollback = async client => { +const rollback = async client => { const collection = await getCollection() await Helpers.dropIndexesFromCollection(collection, indexes) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20220105123000_cleanup_unused_collections.js b/services/web/migrations/20220105123000_cleanup_unused_collections.mjs similarity index 76% rename from services/web/migrations/20220105123000_cleanup_unused_collections.js rename to services/web/migrations/20220105123000_cleanup_unused_collections.mjs index 9a249ec236..2012317c90 100644 --- a/services/web/migrations/20220105123000_cleanup_unused_collections.js +++ b/services/web/migrations/20220105123000_cleanup_unused_collections.mjs @@ -1,6 +1,6 @@ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const unusedCollections = [ 'collaberatorcount', @@ -18,12 +18,18 @@ const unusedCollections = [ 'usersEmailDomains', ] -exports.migrate = async () => { +const migrate = async () => { for (const name of unusedCollections) { await Helpers.dropCollection(name) } } -exports.rollback = async () => { +const rollback = async () => { // We lost the indexes. There is no way back. } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20220105130000_fix_saml_indexes.js b/services/web/migrations/20220105130000_fix_saml_indexes.js deleted file mode 100644 index cb5bfb5b5d..0000000000 --- a/services/web/migrations/20220105130000_fix_saml_indexes.js +++ /dev/null @@ -1,19 +0,0 @@ -const Helpers = require('./lib/helpers') -const { samlLogsIndexes } = require('./20191106102104_saml-log-indexes') -const { usersIndexes } = require('./20191107191318_saml-indentifiers-index') - -exports.tags = ['saas'] - -exports.migrate = async ({ db }) => { - // Fix-up the previous SAML migrations that were operating on collections with - // typos in their names. - await Helpers.addIndexesToCollection( - db.users, - usersIndexes.map(index => { - return Object.assign({}, index, { unique: true }) - }) - ) - await Helpers.addIndexesToCollection(db.samlLogs, samlLogsIndexes) -} - -exports.rollback = async () => {} diff --git a/services/web/migrations/20220105130000_fix_saml_indexes.mjs b/services/web/migrations/20220105130000_fix_saml_indexes.mjs new file mode 100644 index 0000000000..9f8e76a94c --- /dev/null +++ b/services/web/migrations/20220105130000_fix_saml_indexes.mjs @@ -0,0 +1,28 @@ +import Helpers from './lib/helpers.mjs' +import SamlLogsIndexesMigration from './20191106102104_saml-log-indexes.mjs' +import SamlIndentifiersIndexMigration from './20191107191318_saml-indentifiers-index.mjs' + +const { samlLogsIndexes } = SamlLogsIndexesMigration +const { usersIndexes } = SamlIndentifiersIndexMigration + +const tags = ['saas'] + +const migrate = async ({ db }) => { + // Fix-up the previous SAML migrations that were operating on collections with + // typos in their names. + await Helpers.addIndexesToCollection( + db.users, + usersIndexes.map(index => { + return Object.assign({}, index, { unique: true }) + }) + ) + await Helpers.addIndexesToCollection(db.samlLogs, samlLogsIndexes) +} + +const rollback = async () => {} + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20220222095146_split_tests_analytics_enabled.js b/services/web/migrations/20220222095146_split_tests_analytics_enabled.mjs similarity index 87% rename from services/web/migrations/20220222095146_split_tests_analytics_enabled.js rename to services/web/migrations/20220222095146_split_tests_analytics_enabled.mjs index 97aa614cb1..6444cd1ab8 100644 --- a/services/web/migrations/20220222095146_split_tests_analytics_enabled.js +++ b/services/web/migrations/20220222095146_split_tests_analytics_enabled.mjs @@ -1,6 +1,6 @@ -exports.tags = ['saas'] +const tags = ['saas'] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await db.splittests.updateMany( {}, @@ -28,7 +28,7 @@ exports.migrate = async client => { ) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await db.splittests.updateMany( {}, @@ -49,3 +49,9 @@ exports.rollback = async client => { } ) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20220811111800_create_dropboxEntities_index.js b/services/web/migrations/20220811111800_create_dropboxEntities_index.mjs similarity index 61% rename from services/web/migrations/20220811111800_create_dropboxEntities_index.js rename to services/web/migrations/20220811111800_create_dropboxEntities_index.mjs index 12b038100b..9c4e2b1138 100644 --- a/services/web/migrations/20220811111800_create_dropboxEntities_index.js +++ b/services/web/migrations/20220811111800_create_dropboxEntities_index.mjs @@ -1,6 +1,6 @@ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -11,12 +11,18 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.dropboxEntities, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await Helpers.dropIndexesFromCollection(db.dropboxEntities, indexes) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20220815105500_create_dropboxProjects_index.js b/services/web/migrations/20220815105500_create_dropboxProjects_index.mjs similarity index 64% rename from services/web/migrations/20220815105500_create_dropboxProjects_index.js rename to services/web/migrations/20220815105500_create_dropboxProjects_index.mjs index 7a9c134bde..7dace68383 100644 --- a/services/web/migrations/20220815105500_create_dropboxProjects_index.js +++ b/services/web/migrations/20220815105500_create_dropboxProjects_index.mjs @@ -1,6 +1,6 @@ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -13,12 +13,18 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.dropboxProjects, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await Helpers.dropIndexesFromCollection(db.dropboxProjects, indexes) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20220817120900_create_dropboxProjects_index.js b/services/web/migrations/20220817120900_create_dropboxProjects_index.mjs similarity index 64% rename from services/web/migrations/20220817120900_create_dropboxProjects_index.js rename to services/web/migrations/20220817120900_create_dropboxProjects_index.mjs index 9e246cac33..37a53b0514 100644 --- a/services/web/migrations/20220817120900_create_dropboxProjects_index.js +++ b/services/web/migrations/20220817120900_create_dropboxProjects_index.mjs @@ -1,6 +1,6 @@ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -13,12 +13,18 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.dropboxProjects, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await Helpers.dropIndexesFromCollection(db.dropboxProjects, indexes) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20220825160708_recreate_dropboxEntities.js b/services/web/migrations/20220825160708_recreate_dropboxEntities.mjs similarity index 82% rename from services/web/migrations/20220825160708_recreate_dropboxEntities.js rename to services/web/migrations/20220825160708_recreate_dropboxEntities.mjs index 628d11eb1c..216fef7b2a 100644 --- a/services/web/migrations/20220825160708_recreate_dropboxEntities.js +++ b/services/web/migrations/20220825160708_recreate_dropboxEntities.mjs @@ -1,6 +1,6 @@ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -18,7 +18,7 @@ const indexes = [ { key: { 'overleaf.userId': 1, 'dropbox.pathLower': 'hashed' } }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client // Forcibly drop the dropboxEntities collection. The new structure is // different and we don't want to keep the data with the old structure around. @@ -26,7 +26,13 @@ exports.migrate = async client => { await Helpers.addIndexesToCollection(db.dropboxEntities, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await Helpers.dropIndexesFromCollection(db.dropboxEntities, indexes) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20220826104236_disable_alpha_beta_program.js b/services/web/migrations/20220826104236_disable_alpha_beta_program.js deleted file mode 100644 index db8039f339..0000000000 --- a/services/web/migrations/20220826104236_disable_alpha_beta_program.js +++ /dev/null @@ -1,11 +0,0 @@ -exports.tags = ['server-ce', 'server-pro'] - -exports.migrate = async client => { - const { db } = client - await db.users.updateMany( - {}, - { $set: { alphaProgram: false, betaProgram: false } } - ) -} - -exports.rollback = async () => {} diff --git a/services/web/migrations/20220826104236_disable_alpha_beta_program.mjs b/services/web/migrations/20220826104236_disable_alpha_beta_program.mjs new file mode 100644 index 0000000000..8777d7708b --- /dev/null +++ b/services/web/migrations/20220826104236_disable_alpha_beta_program.mjs @@ -0,0 +1,17 @@ +const tags = ['server-ce', 'server-pro'] + +const migrate = async client => { + const { db } = client + await db.users.updateMany( + {}, + { $set: { alphaProgram: false, betaProgram: false } } + ) +} + +const rollback = async () => {} + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20220830140459_create_index_user_labsProgram_labsProgramGalileo.js b/services/web/migrations/20220830140459_create_index_user_labsProgram_labsProgramGalileo.mjs similarity index 67% rename from services/web/migrations/20220830140459_create_index_user_labsProgram_labsProgramGalileo.js rename to services/web/migrations/20220830140459_create_index_user_labsProgram_labsProgramGalileo.mjs index 715690ad07..590854de28 100644 --- a/services/web/migrations/20220830140459_create_index_user_labsProgram_labsProgramGalileo.js +++ b/services/web/migrations/20220830140459_create_index_user_labsProgram_labsProgramGalileo.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -15,12 +15,18 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.users, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await Helpers.dropIndexesFromCollection(db.users, indexes) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20220913105500_create_auditLog_indexes.js b/services/web/migrations/20220913105500_create_auditLog_indexes.mjs similarity index 72% rename from services/web/migrations/20220913105500_create_auditLog_indexes.js rename to services/web/migrations/20220913105500_create_auditLog_indexes.mjs index df1fb52554..89328533c8 100644 --- a/services/web/migrations/20220913105500_create_auditLog_indexes.js +++ b/services/web/migrations/20220913105500_create_auditLog_indexes.mjs @@ -1,6 +1,6 @@ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const indexes = [ { @@ -13,16 +13,22 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.projectAuditLogEntries, indexes) await Helpers.addIndexesToCollection(db.userAuditLogEntries, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await Promise.all([ Helpers.dropIndexesFromCollection(db.userAuditLogEntries, indexes), Helpers.dropIndexesFromCollection(db.projectAuditLogEntries, indexes), ]) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20220913125500_migrate_auditLog_to_collections.js b/services/web/migrations/20220913125500_migrate_auditLog_to_collections.js deleted file mode 100644 index 65f636755c..0000000000 --- a/services/web/migrations/20220913125500_migrate_auditLog_to_collections.js +++ /dev/null @@ -1,14 +0,0 @@ -const runScript = require('../scripts/migrate_audit_logs.js') - -exports.tags = ['server-ce', 'server-pro', 'saas'] - -exports.migrate = async () => { - const options = { - letUserDoubleCheckInputsFor: 10, - writeConcurrency: 5, - dryRun: false, - } - await runScript(options) -} - -exports.rollback = async () => {} diff --git a/services/web/migrations/20220913125500_migrate_auditLog_to_collections.mjs b/services/web/migrations/20220913125500_migrate_auditLog_to_collections.mjs new file mode 100644 index 0000000000..51f6bf85be --- /dev/null +++ b/services/web/migrations/20220913125500_migrate_auditLog_to_collections.mjs @@ -0,0 +1,20 @@ +import runScript from '../scripts/migrate_audit_logs.js' + +const tags = ['server-ce', 'server-pro', 'saas'] + +const migrate = async () => { + const options = { + letUserDoubleCheckInputsFor: 10, + writeConcurrency: 5, + dryRun: false, + } + await runScript(options) +} + +const rollback = async () => {} + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20220929193200_add_auditLog_indexes.js b/services/web/migrations/20220929193200_add_auditLog_indexes.mjs similarity index 74% rename from services/web/migrations/20220929193200_add_auditLog_indexes.js rename to services/web/migrations/20220929193200_add_auditLog_indexes.mjs index 16f892cc12..83d0e75c40 100644 --- a/services/web/migrations/20220929193200_add_auditLog_indexes.js +++ b/services/web/migrations/20220929193200_add_auditLog_indexes.mjs @@ -1,6 +1,6 @@ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const projectIndexes = [ { @@ -20,7 +20,7 @@ const userIndexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection( db.projectAuditLogEntries, @@ -29,7 +29,7 @@ exports.migrate = async client => { await Helpers.addIndexesToCollection(db.userAuditLogEntries, userIndexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await Promise.all([ Helpers.dropIndexesFromCollection( @@ -39,3 +39,9 @@ exports.rollback = async client => { Helpers.dropIndexesFromCollection(db.userAuditLogEntries, userIndexes), ]) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20221111111111_ce_sp_convert_archived_state.js b/services/web/migrations/20221111111111_ce_sp_convert_archived_state.js deleted file mode 100644 index d48d96e29c..0000000000 --- a/services/web/migrations/20221111111111_ce_sp_convert_archived_state.js +++ /dev/null @@ -1,9 +0,0 @@ -const runScript = require('../scripts/convert_archived_state') - -exports.tags = ['server-ce', 'server-pro'] - -exports.migrate = async () => { - await runScript('FIRST,SECOND') -} - -exports.rollback = async () => {} diff --git a/services/web/migrations/20221111111111_ce_sp_convert_archived_state.mjs b/services/web/migrations/20221111111111_ce_sp_convert_archived_state.mjs new file mode 100644 index 0000000000..b0cdf0e74b --- /dev/null +++ b/services/web/migrations/20221111111111_ce_sp_convert_archived_state.mjs @@ -0,0 +1,15 @@ +import runScript from '../scripts/convert_archived_state.js' + +const tags = ['server-ce', 'server-pro'] + +const migrate = async () => { + await runScript('FIRST,SECOND') +} + +const rollback = async () => {} + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20221122191857_project_history_chunks_indexes.js b/services/web/migrations/20221122191857_project_history_chunks_indexes.mjs similarity index 69% rename from services/web/migrations/20221122191857_project_history_chunks_indexes.js rename to services/web/migrations/20221122191857_project_history_chunks_indexes.mjs index d4528a0f51..53f744bfd8 100644 --- a/services/web/migrations/20221122191857_project_history_chunks_indexes.js +++ b/services/web/migrations/20221122191857_project_history_chunks_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const indexes = [ { @@ -18,10 +18,16 @@ const indexes = [ }, ] -exports.migrate = async ({ db }) => { +const migrate = async ({ db }) => { await Helpers.addIndexesToCollection(db.projectHistoryChunks, indexes) } -exports.rollback = async ({ db }) => { +const rollback = async ({ db }) => { await Helpers.dropIndexesFromCollection(db.projectHistoryChunks, indexes) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20230110140452_rename_recurly_cached_status.js b/services/web/migrations/20230110140452_rename_recurly_cached_status.mjs similarity index 86% rename from services/web/migrations/20230110140452_rename_recurly_cached_status.js rename to services/web/migrations/20230110140452_rename_recurly_cached_status.mjs index 81e90457ae..227555b4e3 100644 --- a/services/web/migrations/20230110140452_rename_recurly_cached_status.js +++ b/services/web/migrations/20230110140452_rename_recurly_cached_status.mjs @@ -1,10 +1,10 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] -exports.migrate = async client => { +const migrate = async client => { const { db } = client // 'recurly' -> 'recurlyStatus' await db.subscriptions.updateMany( @@ -28,7 +28,7 @@ exports.migrate = async client => { ) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client // 'recurlyStatus' -> 'recurly' await db.subscriptions.updateMany( @@ -51,3 +51,9 @@ exports.rollback = async client => { { $unset: { recurlyStatus: 1 } } ) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20230124092607_clear_old_2fa_setup.js b/services/web/migrations/20230124092607_clear_old_2fa_setup.mjs similarity index 66% rename from services/web/migrations/20230124092607_clear_old_2fa_setup.js rename to services/web/migrations/20230124092607_clear_old_2fa_setup.mjs index d72eeb12a5..f5e415953b 100644 --- a/services/web/migrations/20230124092607_clear_old_2fa_setup.js +++ b/services/web/migrations/20230124092607_clear_old_2fa_setup.mjs @@ -1,13 +1,14 @@ -const { batchedUpdate } = require('../scripts/helpers/batchedUpdate') +import BatchedUpdateScript from '../scripts/helpers/batchedUpdate.js' +const { batchedUpdate } = BatchedUpdateScript -exports.tags = ['saas'] +const tags = ['saas'] const batchedUpdateOptions = { VERBOSE_LOGGING: 'true', BATCH_SIZE: '1', } -exports.migrate = async () => { +const migrate = async () => { await batchedUpdate( 'users', { 'twoFactorAuthentication.secret': { $exists: true } }, @@ -18,7 +19,7 @@ exports.migrate = async () => { ) } -exports.rollback = async () => { +const rollback = async () => { await batchedUpdate( 'users', { 'twoFactorAuthentication.secretEncrypted': { $exists: true } }, @@ -28,3 +29,9 @@ exports.rollback = async () => { batchedUpdateOptions ) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20230207134844_group_invite_emails_to_lowercase.js b/services/web/migrations/20230207134844_group_invite_emails_to_lowercase.mjs similarity index 77% rename from services/web/migrations/20230207134844_group_invite_emails_to_lowercase.js rename to services/web/migrations/20230207134844_group_invite_emails_to_lowercase.mjs index 8779d2ad37..fdb2bc8e8d 100644 --- a/services/web/migrations/20230207134844_group_invite_emails_to_lowercase.js +++ b/services/web/migrations/20230207134844_group_invite_emails_to_lowercase.mjs @@ -1,10 +1,10 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] -exports.migrate = async client => { +const migrate = async client => { const { db } = client db.subscriptions.updateMany( { @@ -36,6 +36,12 @@ exports.migrate = async client => { ) } -exports.rollback = async client => { +const rollback = async client => { // There is no way back. } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20230217205311_fix_deleted_history_chunks_index.js b/services/web/migrations/20230217205311_fix_deleted_history_chunks_index.mjs similarity index 73% rename from services/web/migrations/20230217205311_fix_deleted_history_chunks_index.js rename to services/web/migrations/20230217205311_fix_deleted_history_chunks_index.mjs index f13eab5b53..fd232d774e 100644 --- a/services/web/migrations/20230217205311_fix_deleted_history_chunks_index.js +++ b/services/web/migrations/20230217205311_fix_deleted_history_chunks_index.mjs @@ -1,6 +1,6 @@ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const indexes = [ { @@ -15,10 +15,16 @@ const indexes = [ }, ] -exports.migrate = async ({ db }) => { +const migrate = async ({ db }) => { await Helpers.addIndexesToCollection(db.projectHistoryChunks, indexes) } -exports.rollback = async ({ db }) => { +const rollback = async ({ db }) => { await Helpers.dropIndexesFromCollection(db.projectHistoryChunks, indexes) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20230315170739_back_fill_doc_rev.js b/services/web/migrations/20230315170739_back_fill_doc_rev.js deleted file mode 100644 index 5b245dad50..0000000000 --- a/services/web/migrations/20230315170739_back_fill_doc_rev.js +++ /dev/null @@ -1,9 +0,0 @@ -const runScript = require('../scripts/back_fill_doc_rev') - -exports.tags = ['server-ce', 'server-pro'] - -exports.migrate = async () => { - await runScript(false) -} - -exports.rollback = async () => {} diff --git a/services/web/migrations/20230315170739_back_fill_doc_rev.mjs b/services/web/migrations/20230315170739_back_fill_doc_rev.mjs new file mode 100644 index 0000000000..0f87de12aa --- /dev/null +++ b/services/web/migrations/20230315170739_back_fill_doc_rev.mjs @@ -0,0 +1,15 @@ +import runScript from '../scripts/back_fill_doc_rev.js' + +const tags = ['server-ce', 'server-pro'] + +const migrate = async () => { + await runScript(false) +} + +const rollback = async () => {} + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20230405190240_oauth_refresh_tokens_index.js b/services/web/migrations/20230405190240_oauth_refresh_tokens_index.mjs similarity index 87% rename from services/web/migrations/20230405190240_oauth_refresh_tokens_index.js rename to services/web/migrations/20230405190240_oauth_refresh_tokens_index.mjs index b66da0c52a..56f66b5c8a 100644 --- a/services/web/migrations/20230405190240_oauth_refresh_tokens_index.js +++ b/services/web/migrations/20230405190240_oauth_refresh_tokens_index.mjs @@ -1,6 +1,6 @@ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const OLD_INDEX = { key: { refreshToken: 1 }, @@ -18,7 +18,7 @@ const TMP_INDEX = { name: 'refreshToken_tmp', } -exports.migrate = async client => { +const migrate = async client => { const { db } = client // Create a temporary index so that the refresh tokens are not left unindexed // while we drop the index and recreate it. @@ -32,7 +32,7 @@ exports.migrate = async client => { await Helpers.dropIndexesFromCollection(db.oauthAccessTokens, [TMP_INDEX]) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client // Create a temporary index so that the refresh tokens are not left unindexed // while we drop the index and recreate it. @@ -45,3 +45,9 @@ exports.rollback = async client => { // Drop the temporary index await Helpers.dropIndexesFromCollection(db.oauthAccessTokens, [TMP_INDEX]) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20230406125632_oauth_tokens_ttl.js b/services/web/migrations/20230406125632_oauth_tokens_ttl.mjs similarity index 77% rename from services/web/migrations/20230406125632_oauth_tokens_ttl.js rename to services/web/migrations/20230406125632_oauth_tokens_ttl.mjs index 64b1e423e7..e6e64f6fff 100644 --- a/services/web/migrations/20230406125632_oauth_tokens_ttl.js +++ b/services/web/migrations/20230406125632_oauth_tokens_ttl.mjs @@ -1,6 +1,6 @@ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const ACCESS_TOKENS_INDEX = { name: 'expiresAt_1', @@ -16,7 +16,7 @@ const AUTHORIZATION_CODES_INDEX = { expireAfterSeconds: 0, } -exports.migrate = async ({ db }) => { +const migrate = async ({ db }) => { await Helpers.addIndexesToCollection(db.oauthAccessTokens, [ ACCESS_TOKENS_INDEX, ]) @@ -25,7 +25,7 @@ exports.migrate = async ({ db }) => { ]) } -exports.rollback = async ({ db }) => { +const rollback = async ({ db }) => { await Helpers.dropIndexesFromCollection(db.oauthAccessTokens, [ ACCESS_TOKENS_INDEX, ]) @@ -33,3 +33,9 @@ exports.rollback = async ({ db }) => { AUTHORIZATION_CODES_INDEX, ]) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20230426095212_personal_oauth_tokens_user_index.js b/services/web/migrations/20230426095212_personal_oauth_tokens_user_index.mjs similarity index 60% rename from services/web/migrations/20230426095212_personal_oauth_tokens_user_index.js rename to services/web/migrations/20230426095212_personal_oauth_tokens_user_index.mjs index 68ecf045eb..67c7bb9265 100644 --- a/services/web/migrations/20230426095212_personal_oauth_tokens_user_index.js +++ b/services/web/migrations/20230426095212_personal_oauth_tokens_user_index.mjs @@ -1,6 +1,6 @@ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const indexes = [ { @@ -10,12 +10,18 @@ const indexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.oauthAccessTokens, indexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await Helpers.dropIndexesFromCollection(db.oauthAccessTokens, indexes) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20230428154643_history_chunks_garbage_collection_index.js b/services/web/migrations/20230428154643_history_chunks_garbage_collection_index.mjs similarity index 82% rename from services/web/migrations/20230428154643_history_chunks_garbage_collection_index.js rename to services/web/migrations/20230428154643_history_chunks_garbage_collection_index.mjs index aaf9b7a015..0fd1608f68 100644 --- a/services/web/migrations/20230428154643_history_chunks_garbage_collection_index.js +++ b/services/web/migrations/20230428154643_history_chunks_garbage_collection_index.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const oldIndexes = [ { @@ -45,14 +45,20 @@ const newIndexes = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.projectHistoryChunks, newIndexes) await Helpers.dropIndexesFromCollection(db.projectHistoryChunks, oldIndexes) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await Helpers.addIndexesToCollection(db.projectHistoryChunks, oldIndexes) await Helpers.dropIndexesFromCollection(db.projectHistoryChunks, newIndexes) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20230502180757_server_pro_oauth_indexes.js b/services/web/migrations/20230502180757_server_pro_oauth_indexes.mjs similarity index 84% rename from services/web/migrations/20230502180757_server_pro_oauth_indexes.js rename to services/web/migrations/20230502180757_server_pro_oauth_indexes.mjs index 797120d5bb..a3e052290e 100644 --- a/services/web/migrations/20230502180757_server_pro_oauth_indexes.js +++ b/services/web/migrations/20230502180757_server_pro_oauth_indexes.mjs @@ -1,6 +1,6 @@ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-pro'] +const tags = ['server-pro'] const OAUTH_APPLICATIONS_INDEX = { key: { id: 1 }, @@ -20,7 +20,7 @@ const OAUTH_AUTHORIZATION_CODES_INDEX = { name: 'authorizationCode_1', } -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.oauthApplications, [ OAUTH_APPLICATIONS_INDEX, @@ -33,7 +33,7 @@ exports.migrate = async client => { ]) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await Helpers.dropIndexesFromCollection(db.oauthApplications, [ OAUTH_APPLICATIONS_INDEX, @@ -45,3 +45,9 @@ exports.rollback = async client => { OAUTH_AUTHORIZATION_CODES_INDEX, ]) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20230512100122_ensure_history_migration.js b/services/web/migrations/20230512100122_ensure_history_migration.mjs similarity index 86% rename from services/web/migrations/20230512100122_ensure_history_migration.js rename to services/web/migrations/20230512100122_ensure_history_migration.mjs index 0a2778da51..79d7892692 100644 --- a/services/web/migrations/20230512100122_ensure_history_migration.js +++ b/services/web/migrations/20230512100122_ensure_history_migration.mjs @@ -1,9 +1,10 @@ -const { promisify } = require('util') +import util from 'util' +const { promisify } = util const sleep = promisify(setTimeout) -exports.tags = ['server-ce', 'server-pro'] +const tags = ['server-ce', 'server-pro'] -exports.migrate = async client => { +const migrate = async client => { const { db } = client const count = await db.projects.countDocuments({ 'overleaf.history.display': { $ne: true }, @@ -48,6 +49,12 @@ exports.migrate = async client => { } } -exports.rollback = async client => { +const rollback = async client => { // Not applicable } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20230616153016_user_features_updated_at_index.js b/services/web/migrations/20230616153016_user_features_updated_at_index.mjs similarity index 62% rename from services/web/migrations/20230616153016_user_features_updated_at_index.js rename to services/web/migrations/20230616153016_user_features_updated_at_index.mjs index f4ab80ea9d..3e8f904944 100644 --- a/services/web/migrations/20230616153016_user_features_updated_at_index.js +++ b/services/web/migrations/20230616153016_user_features_updated_at_index.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const index = { key: { @@ -11,12 +11,18 @@ const index = { name: 'featuresUpdatedAt_1', } -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.users, [index]) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await Helpers.dropIndexesFromCollection(db.users, [index]) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20230817081910_back_fill_gitBridge_feature_server_pro.js b/services/web/migrations/20230817081910_back_fill_gitBridge_feature_server_pro.js deleted file mode 100644 index 71e062da63..0000000000 --- a/services/web/migrations/20230817081910_back_fill_gitBridge_feature_server_pro.js +++ /dev/null @@ -1,11 +0,0 @@ -exports.tags = ['server-ce', 'server-pro'] - -exports.migrate = async () => { - // Run-time import as SaaS does not ship with the server-ce-scripts module - const runScript = require('../modules/server-ce-scripts/scripts/upgrade-user-features') - await runScript(false, { - gitBridge: 1, - }) -} - -exports.rollback = async () => {} diff --git a/services/web/migrations/20230817081910_back_fill_gitBridge_feature_server_pro.mjs b/services/web/migrations/20230817081910_back_fill_gitBridge_feature_server_pro.mjs new file mode 100644 index 0000000000..6e15c9fd28 --- /dev/null +++ b/services/web/migrations/20230817081910_back_fill_gitBridge_feature_server_pro.mjs @@ -0,0 +1,18 @@ +import runScript from '../modules/server-ce-scripts/scripts/upgrade-user-features.js' + +const tags = ['server-ce', 'server-pro'] + +const migrate = async () => { + // Run-time import as SaaS does not ship with the server-ce-scripts module + await runScript(false, { + gitBridge: 1, + }) +} + +const rollback = async () => {} + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20230928092537_backfill_subscriptions_managed_users_feature_flag.js b/services/web/migrations/20230928092537_backfill_subscriptions_managed_users_feature_flag.mjs similarity index 69% rename from services/web/migrations/20230928092537_backfill_subscriptions_managed_users_feature_flag.js rename to services/web/migrations/20230928092537_backfill_subscriptions_managed_users_feature_flag.mjs index ab343de9de..4d782bf0d0 100644 --- a/services/web/migrations/20230928092537_backfill_subscriptions_managed_users_feature_flag.js +++ b/services/web/migrations/20230928092537_backfill_subscriptions_managed_users_feature_flag.mjs @@ -1,6 +1,6 @@ -exports.tags = ['saas'] +const tags = ['saas'] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await db.subscriptions.updateMany( { 'features.managedUsers': { $ne: true } }, @@ -8,10 +8,16 @@ exports.migrate = async client => { ) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await db.subscriptions.updateMany( { 'features.managedUsers': { $eq: null } }, { $set: { 'features.managedUsers': false } } ) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20231016101457_drop_history_display_index.js b/services/web/migrations/20231016101457_drop_history_display_index.mjs similarity index 56% rename from services/web/migrations/20231016101457_drop_history_display_index.js rename to services/web/migrations/20231016101457_drop_history_display_index.mjs index 696f18d216..83b9e55153 100644 --- a/services/web/migrations/20231016101457_drop_history_display_index.js +++ b/services/web/migrations/20231016101457_drop_history_display_index.mjs @@ -1,6 +1,6 @@ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const indexes = [ { @@ -9,10 +9,16 @@ const indexes = [ }, ] -exports.migrate = async ({ db }) => { +const migrate = async ({ db }) => { await Helpers.dropIndexesFromCollection(db.projects, indexes) } -exports.rollback = async ({ db }) => { +const rollback = async ({ db }) => { await Helpers.addIndexesToCollection(db.projects, indexes) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20231025094810_sso_config_certificates_array.js b/services/web/migrations/20231025094810_sso_config_certificates_array.mjs similarity index 84% rename from services/web/migrations/20231025094810_sso_config_certificates_array.js rename to services/web/migrations/20231025094810_sso_config_certificates_array.mjs index c9ad073485..1ec19f481e 100644 --- a/services/web/migrations/20231025094810_sso_config_certificates_array.js +++ b/services/web/migrations/20231025094810_sso_config_certificates_array.mjs @@ -1,6 +1,6 @@ -exports.tags = ['saas'] +const tags = ['saas'] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await db.ssoConfigs.updateMany( { certificate: { $exists: true }, certificates: { $exists: false } }, @@ -21,7 +21,7 @@ exports.migrate = async client => { ) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await db.ssoConfigs.updateMany( { certificate: { $exists: false }, certificates: { $exists: true } }, @@ -33,3 +33,9 @@ exports.rollback = async client => { ] ) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20231030160030_managed_users_enabled.js b/services/web/migrations/20231030160030_managed_users_enabled.mjs similarity index 65% rename from services/web/migrations/20231030160030_managed_users_enabled.js rename to services/web/migrations/20231030160030_managed_users_enabled.mjs index e1a73bd058..772c9bfc44 100644 --- a/services/web/migrations/20231030160030_managed_users_enabled.js +++ b/services/web/migrations/20231030160030_managed_users_enabled.mjs @@ -1,10 +1,10 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await db.subscriptions.updateMany( { groupPolicy: { $exists: true } }, @@ -12,10 +12,16 @@ exports.migrate = async client => { ) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await db.subscriptions.updateMany( { groupPolicy: { $exists: true } }, { $unset: { managedUsersEnabled: '' } } ) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20231031164732_drop_redundant_indexes.js b/services/web/migrations/20231031164732_drop_redundant_indexes.mjs similarity index 78% rename from services/web/migrations/20231031164732_drop_redundant_indexes.js rename to services/web/migrations/20231031164732_drop_redundant_indexes.mjs index f3c57c42fd..c8a703f0cd 100644 --- a/services/web/migrations/20231031164732_drop_redundant_indexes.js +++ b/services/web/migrations/20231031164732_drop_redundant_indexes.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const DOCS_INDEXES = [ { @@ -26,14 +26,20 @@ const PROJECTS_INDEXES = [ }, ] -exports.migrate = async ({ db }) => { +const migrate = async ({ db }) => { await Helpers.dropIndexesFromCollection(db.docs, DOCS_INDEXES) await Helpers.dropIndexesFromCollection(db.tags, TAGS_INDEXES) await Helpers.dropIndexesFromCollection(db.projects, PROJECTS_INDEXES) } -exports.rollback = async ({ db }) => { +const rollback = async ({ db }) => { await Helpers.addIndexesToCollection(db.docs, DOCS_INDEXES) await Helpers.addIndexesToCollection(db.tags, TAGS_INDEXES) await Helpers.addIndexesToCollection(db.projects, PROJECTS_INDEXES) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20231101153447_partial_last_opened_index.js b/services/web/migrations/20231101153447_partial_last_opened_index.mjs similarity index 71% rename from services/web/migrations/20231101153447_partial_last_opened_index.js rename to services/web/migrations/20231101153447_partial_last_opened_index.mjs index 0b7a7ec45f..e49a2e2d62 100644 --- a/services/web/migrations/20231101153447_partial_last_opened_index.js +++ b/services/web/migrations/20231101153447_partial_last_opened_index.mjs @@ -1,6 +1,6 @@ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const OLD_INDEX = { name: 'active_1_lastOpened_1', @@ -13,14 +13,20 @@ const NEW_INDEX = { partialFilterExpression: { active: true }, } -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.projects, [NEW_INDEX]) await Helpers.dropIndexesFromCollection(db.projects, [OLD_INDEX]) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await Helpers.addIndexesToCollection(db.projects, [OLD_INDEX]) await Helpers.dropIndexesFromCollection(db.projects, [NEW_INDEX]) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20231101191643_drop_unused_indexes.js b/services/web/migrations/20231101191643_drop_unused_indexes.mjs similarity index 87% rename from services/web/migrations/20231101191643_drop_unused_indexes.js rename to services/web/migrations/20231101191643_drop_unused_indexes.mjs index 06e5ec7048..263b05f605 100644 --- a/services/web/migrations/20231101191643_drop_unused_indexes.js +++ b/services/web/migrations/20231101191643_drop_unused_indexes.mjs @@ -1,6 +1,6 @@ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const PROJECTS_INDEXES = [ { @@ -55,7 +55,7 @@ const USERS_INDEXES = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.dropIndexesFromCollection(db.projects, PROJECTS_INDEXES) await Helpers.dropIndexesFromCollection( @@ -65,9 +65,15 @@ exports.migrate = async client => { await Helpers.dropIndexesFromCollection(db.users, USERS_INDEXES) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await Helpers.addIndexesToCollection(db.projects, PROJECTS_INDEXES) await Helpers.addIndexesToCollection(db.docSnapshots, DOC_SNAPSHOTS_INDEXES) await Helpers.addIndexesToCollection(db.users, USERS_INDEXES) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20231101204352_drop_unused_saas_indexes.js b/services/web/migrations/20231101204352_drop_unused_saas_indexes.mjs similarity index 78% rename from services/web/migrations/20231101204352_drop_unused_saas_indexes.js rename to services/web/migrations/20231101204352_drop_unused_saas_indexes.mjs index abeffa0bb7..68516b5834 100644 --- a/services/web/migrations/20231101204352_drop_unused_saas_indexes.js +++ b/services/web/migrations/20231101204352_drop_unused_saas_indexes.mjs @@ -1,6 +1,6 @@ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const SUBSCRIPTIONS_INDEXES = [ { @@ -20,7 +20,7 @@ const USERS_INDEXES = [ }, ] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.dropIndexesFromCollection( db.subscriptions, @@ -29,8 +29,14 @@ exports.migrate = async client => { await Helpers.dropIndexesFromCollection(db.users, USERS_INDEXES) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await Helpers.addIndexesToCollection(db.subscriptions, SUBSCRIPTIONS_INDEXES) await Helpers.addIndexesToCollection(db.users, USERS_INDEXES) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20231105000000_move_doc_versions_from_docops_to_docs.js b/services/web/migrations/20231105000000_move_doc_versions_from_docops_to_docs.mjs similarity index 82% rename from services/web/migrations/20231105000000_move_doc_versions_from_docops_to_docs.js rename to services/web/migrations/20231105000000_move_doc_versions_from_docops_to_docs.mjs index b14183843a..f54eb2f3c6 100644 --- a/services/web/migrations/20231105000000_move_doc_versions_from_docops_to_docs.js +++ b/services/web/migrations/20231105000000_move_doc_versions_from_docops_to_docs.mjs @@ -1,11 +1,12 @@ -const { ObjectId, ReadPreference } = require('mongodb-legacy') +import mongodbLegacy from 'mongodb-legacy' +const { ObjectId, ReadPreference } = mongodbLegacy const BATCH_SIZE = parseInt(process.env.BATCH_SIZE || '1000', 10) const MIN_ID = process.env.MIN_ID -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] -exports.migrate = async ({ db, nativeDb }) => { +const migrate = async ({ db, nativeDb }) => { const docOps = nativeDb.collection('docOps') const filter = {} @@ -45,8 +46,14 @@ exports.migrate = async ({ db, nativeDb }) => { console.log(`DONE - ${docsProcessed} docs processed`) } -exports.rollback = async ({ db }) => { +const rollback = async ({ db }) => { // Nothing to do on rollback. We don't want to remove versions from the docs // collection because they might be more current than the ones in the docOps // collection. } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20231110192205_drop_docops_collection.js b/services/web/migrations/20231110192205_drop_docops_collection.js deleted file mode 100644 index 8d0ce24136..0000000000 --- a/services/web/migrations/20231110192205_drop_docops_collection.js +++ /dev/null @@ -1,11 +0,0 @@ -const { dropCollection } = require('./lib/helpers') - -exports.tags = ['server-ce', 'server-pro', 'saas'] - -exports.migrate = async () => { - await dropCollection('docOps') -} - -exports.rollback = async client => { - // there's no rollback: we can't recover the data -} diff --git a/services/web/migrations/20231110192205_drop_docops_collection.mjs b/services/web/migrations/20231110192205_drop_docops_collection.mjs new file mode 100644 index 0000000000..cd0f332a0d --- /dev/null +++ b/services/web/migrations/20231110192205_drop_docops_collection.mjs @@ -0,0 +1,18 @@ +import Helper from './lib/helpers.mjs' +const { dropCollection } = Helper + +const tags = ['server-ce', 'server-pro', 'saas'] + +const migrate = async () => { + await dropCollection('docOps') +} + +const rollback = async client => { + // there's no rollback: we can't recover the data +} + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20231113173237_tokens_user_id_index.js b/services/web/migrations/20231113173237_tokens_user_id_index.mjs similarity index 58% rename from services/web/migrations/20231113173237_tokens_user_id_index.js rename to services/web/migrations/20231113173237_tokens_user_id_index.mjs index c80b524380..9825bb6620 100644 --- a/services/web/migrations/20231113173237_tokens_user_id_index.js +++ b/services/web/migrations/20231113173237_tokens_user_id_index.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const index = { key: { @@ -11,12 +11,18 @@ const index = { name: 'data.user_id_1', } -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.tokens, [index]) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await Helpers.dropIndexesFromCollection(db.tokens, [index]) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20240115172206_oauth_issuer_index.js b/services/web/migrations/20240115172206_oauth_issuer_index.mjs similarity index 67% rename from services/web/migrations/20240115172206_oauth_issuer_index.js rename to services/web/migrations/20240115172206_oauth_issuer_index.mjs index 8a74ed52c9..74633fe866 100644 --- a/services/web/migrations/20240115172206_oauth_issuer_index.js +++ b/services/web/migrations/20240115172206_oauth_issuer_index.mjs @@ -1,6 +1,6 @@ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['saas'] +const tags = ['saas'] const index = { key: { @@ -14,12 +14,18 @@ const index = { }, } -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.oauthAccessTokens, [index]) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await Helpers.dropIndexesFromCollection(db.oauthAccessTokens, [index]) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20240220130452_remove_deleted_users_from_token_access_refs.js b/services/web/migrations/20240220130452_remove_deleted_users_from_token_access_refs.js deleted file mode 100644 index 646d1f7385..0000000000 --- a/services/web/migrations/20240220130452_remove_deleted_users_from_token_access_refs.js +++ /dev/null @@ -1,9 +0,0 @@ -const runScript = require('../scripts/remove_deleted_users_from_token_access_refs') - -exports.tags = ['server-ce', 'server-pro', 'saas'] - -exports.migrate = async () => { - await runScript(false) -} - -exports.rollback = async () => {} diff --git a/services/web/migrations/20240220130452_remove_deleted_users_from_token_access_refs.mjs b/services/web/migrations/20240220130452_remove_deleted_users_from_token_access_refs.mjs new file mode 100644 index 0000000000..1bdb1fe0bd --- /dev/null +++ b/services/web/migrations/20240220130452_remove_deleted_users_from_token_access_refs.mjs @@ -0,0 +1,15 @@ +import runScript from '../scripts/remove_deleted_users_from_token_access_refs.js' + +const tags = ['server-ce', 'server-pro', 'saas'] + +const migrate = async () => { + await runScript(false) +} + +const rollback = async () => {} + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20240524135408_add_token_hmac_project_invite_tokens.js b/services/web/migrations/20240524135408_add_token_hmac_project_invite_tokens.mjs similarity index 53% rename from services/web/migrations/20240524135408_add_token_hmac_project_invite_tokens.js rename to services/web/migrations/20240524135408_add_token_hmac_project_invite_tokens.mjs index 99396cf8a3..0eafecaf3b 100644 --- a/services/web/migrations/20240524135408_add_token_hmac_project_invite_tokens.js +++ b/services/web/migrations/20240524135408_add_token_hmac_project_invite_tokens.mjs @@ -1,9 +1,9 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') -const runScript = require('../scripts/backfill_project_invites_token_hmac') +import Helpers from './lib/helpers.mjs' +import runScript from '../scripts/backfill_project_invites_token_hmac.js' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] const index = { key: { @@ -12,13 +12,19 @@ const index = { name: 'tokenHmac_1', } -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.projectInvites, [index]) await runScript(false) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await Helpers.dropIndexesFromCollection(db.projectInvites, [index]) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20240531082910_remove_project_invite_tokens.js b/services/web/migrations/20240531082910_remove_project_invite_tokens.mjs similarity index 52% rename from services/web/migrations/20240531082910_remove_project_invite_tokens.js rename to services/web/migrations/20240531082910_remove_project_invite_tokens.mjs index e980816a6f..2bc34ac716 100644 --- a/services/web/migrations/20240531082910_remove_project_invite_tokens.js +++ b/services/web/migrations/20240531082910_remove_project_invite_tokens.mjs @@ -1,10 +1,10 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.assertDependency( '20240524135408_add_token_hmac_project_invite_tokens' @@ -12,4 +12,10 @@ exports.migrate = async client => { await db.projectInvites.updateMany({}, { $unset: { token: 1 } }) } -exports.rollback = async client => {} +const rollback = async client => {} + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20240618125145_cleanup_user_features_templates.js b/services/web/migrations/20240618125145_cleanup_user_features_templates.js deleted file mode 100644 index 728f3040dd..0000000000 --- a/services/web/migrations/20240618125145_cleanup_user_features_templates.js +++ /dev/null @@ -1,12 +0,0 @@ -const { batchedUpdate } = require('../scripts/helpers/batchedUpdate') -exports.tags = ['server-ce', 'server-pro', 'saas'] - -exports.migrate = async () => { - await batchedUpdate( - 'users', - { 'features.templates': { $exists: true } }, - { $unset: { 'features.templates': true } } - ) -} - -exports.rollback = async () => {} diff --git a/services/web/migrations/20240618125145_cleanup_user_features_templates.mjs b/services/web/migrations/20240618125145_cleanup_user_features_templates.mjs new file mode 100644 index 0000000000..245cecd42d --- /dev/null +++ b/services/web/migrations/20240618125145_cleanup_user_features_templates.mjs @@ -0,0 +1,20 @@ +import BatchedUpdateScript from '../scripts/helpers/batchedUpdate.js' + +const { batchedUpdate } = BatchedUpdateScript +const tags = ['server-ce', 'server-pro', 'saas'] + +const migrate = async () => { + await batchedUpdate( + 'users', + { 'features.templates': { $exists: true } }, + { $unset: { 'features.templates': true } } + ) +} + +const rollback = async () => {} + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20240625101055_add_ai_policy_to_group_policy.js b/services/web/migrations/20240625101055_add_ai_policy_to_group_policy.mjs similarity index 63% rename from services/web/migrations/20240625101055_add_ai_policy_to_group_policy.js rename to services/web/migrations/20240625101055_add_ai_policy_to_group_policy.mjs index a9027cfd20..bb3d93666c 100644 --- a/services/web/migrations/20240625101055_add_ai_policy_to_group_policy.js +++ b/services/web/migrations/20240625101055_add_ai_policy_to_group_policy.mjs @@ -1,6 +1,6 @@ -exports.tags = ['saas'] +const tags = ['saas'] -exports.migrate = async client => { +const migrate = async client => { const { db } = client await db.grouppolicies.updateMany( {}, @@ -8,10 +8,16 @@ exports.migrate = async client => { ) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await db.grouppolicies.updateMany( {}, { $unset: { userCannotUseAIFeatures: '' } } ) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/202407131109055_admin_reversed_hostname.js b/services/web/migrations/202407131109055_admin_reversed_hostname.mjs similarity index 88% rename from services/web/migrations/202407131109055_admin_reversed_hostname.js rename to services/web/migrations/202407131109055_admin_reversed_hostname.mjs index d313224c4c..ad1adaa9b9 100644 --- a/services/web/migrations/202407131109055_admin_reversed_hostname.js +++ b/services/web/migrations/202407131109055_admin_reversed_hostname.mjs @@ -1,6 +1,6 @@ -exports.tags = ['server-ce', 'server-pro'] +const tags = ['server-ce', 'server-pro'] -exports.migrate = async client => { +const migrate = async client => { const { db } = client const adminsWithEmails = await db.users @@ -57,4 +57,10 @@ exports.migrate = async client => { } } -exports.rollback = async () => {} +const rollback = async () => {} + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/20240730155209_create_project_imageName_index.js b/services/web/migrations/20240730155209_create_project_imageName_index.mjs similarity index 55% rename from services/web/migrations/20240730155209_create_project_imageName_index.js rename to services/web/migrations/20240730155209_create_project_imageName_index.mjs index 71e3945c48..72e1f46df1 100644 --- a/services/web/migrations/20240730155209_create_project_imageName_index.js +++ b/services/web/migrations/20240730155209_create_project_imageName_index.mjs @@ -1,18 +1,24 @@ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro'] +const tags = ['server-ce', 'server-pro'] const index = { key: { imageName: 1 }, name: 'imageName_1', } -exports.migrate = async client => { +const migrate = async client => { const { db } = client await Helpers.addIndexesToCollection(db.projects, [index]) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client await Helpers.dropIndexesFromCollection(db.projects, [index]) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/migrations/lib/adapter.js b/services/web/migrations/lib/adapter.mjs similarity index 72% rename from services/web/migrations/lib/adapter.js rename to services/web/migrations/lib/adapter.mjs index a3c8a5cbd1..a7628f7e8c 100644 --- a/services/web/migrations/lib/adapter.js +++ b/services/web/migrations/lib/adapter.mjs @@ -1,4 +1,12 @@ -const Path = require('path') +import Path from 'path' +import mongodb from '../../app/src/infrastructure/mongodb.js' +import Mongoose from '../../app/src/infrastructure/Mongoose.js' +import { fileURLToPath } from 'url' + +const __filename = fileURLToPath(import.meta.url) +const __dirname = Path.dirname(__filename) +const { db, waitForDb } = mongodb +const { getNativeDb } = Mongoose class Adapter { constructor(params) { @@ -14,12 +22,10 @@ class Adapter { } getTemplatePath() { - return Path.resolve(__dirname, 'template.js') + return Path.resolve(__dirname, 'template.mjs') } async connect() { - const { waitForDb, db } = require('../../app/src/infrastructure/mongodb') - const { getNativeDb } = require('../../app/src/infrastructure/Mongoose') await waitForDb() const nativeDb = await getNativeDb() return { db, nativeDb } @@ -53,4 +59,4 @@ class Adapter { } } -module.exports = Adapter +export default Adapter diff --git a/services/web/migrations/lib/helpers.js b/services/web/migrations/lib/helpers.mjs similarity index 90% rename from services/web/migrations/lib/helpers.js rename to services/web/migrations/lib/helpers.mjs index dbe76579e5..0176e0c0b8 100644 --- a/services/web/migrations/lib/helpers.js +++ b/services/web/migrations/lib/helpers.mjs @@ -1,11 +1,7 @@ // @ts-check -const { - db, - getCollectionNames, - getCollectionInternal, - waitForDb, -} = require('../../app/src/infrastructure/mongodb') +import mongodb from '../../app/src/infrastructure/mongodb.js' +const { db, getCollectionNames, getCollectionInternal, waitForDb } = mongodb async function addIndexesToCollection(collection, indexes) { return Promise.all( @@ -60,7 +56,7 @@ async function assertDependency(migrationName) { } } -module.exports = { +export default { addIndexesToCollection, dropIndexesFromCollection, dropCollection, diff --git a/services/web/migrations/lib/template.js b/services/web/migrations/lib/template.mjs similarity index 67% rename from services/web/migrations/lib/template.js rename to services/web/migrations/lib/template.mjs index 1c2e3c39f1..742df1d9e0 100644 --- a/services/web/migrations/lib/template.js +++ b/services/web/migrations/lib/template.mjs @@ -1,10 +1,10 @@ /* eslint-disable no-unused-vars */ -const Helpers = require('./lib/helpers') +import Helpers from './lib/helpers.mjs' -exports.tags = ['server-ce', 'server-pro', 'saas'] +const tags = ['server-ce', 'server-pro', 'saas'] -exports.migrate = async client => { +const migrate = async client => { const { db } = client // Are there migrations that need to run before this migration? // Use the following helper to enforce the dependency: @@ -14,7 +14,13 @@ exports.migrate = async client => { // await Helpers.addIndexesToCollection(db.wombats, [{ name: 1 }]) } -exports.rollback = async client => { +const rollback = async client => { const { db } = client // await Helpers.dropIndexesFromCollection(db.wombats, [{ name: 1 }]) } + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/package.json b/services/web/package.json index 6d4ac29db1..0c433b49b2 100644 --- a/services/web/package.json +++ b/services/web/package.json @@ -31,7 +31,7 @@ "type-check": "tsc --noEmit", "type-check:backend": "tsc -p tsconfig.backend.json --noEmit", "extract-translations": "i18next-scanner", - "migrations": "MONGO_SOCKET_TIMEOUT=0 east", + "migrations": "MONGO_SOCKET_TIMEOUT=0 east --es-modules", "convert-themes": "node frontend/js/features/source-editor/themes/scripts/convert.js", "cypress:open-ct": "OVERLEAF_CONFIG=$PWD/config/settings.webpack.js cypress open --component", "cypress:run-ct": "OVERLEAF_CONFIG=$PWD/config/settings.webpack.js cypress run --component --browser chrome", diff --git a/services/web/scripts/confirmed_at_to_dates.js b/services/web/scripts/confirmed_at_to_dates.js index 1c63951047..c9fcaff907 100644 --- a/services/web/scripts/confirmed_at_to_dates.js +++ b/services/web/scripts/confirmed_at_to_dates.js @@ -40,7 +40,7 @@ async function updateStringDates() { console.log(`Updated ${count} confirmedAt strings to dates!`) } -if (!module.parent) { +if (require.main === module) { updateStringDates() .then(() => { process.exit(0) diff --git a/services/web/scripts/example/script_for_migration.js b/services/web/scripts/example/script_for_migration.js index 45ea96fd02..5ac3f826cb 100644 --- a/services/web/scripts/example/script_for_migration.js +++ b/services/web/scripts/example/script_for_migration.js @@ -15,8 +15,7 @@ const runScript = async () => { console.log(`Hello ${name}!`) } -if (!module.parent) { - // we are in the root module, which means that we're running as a script +if (require.main === module) { runScript() .then(() => process.exit()) .catch(err => { diff --git a/services/web/scripts/mark_migration.js b/services/web/scripts/mark_migration.mjs similarity index 75% rename from services/web/scripts/mark_migration.js rename to services/web/scripts/mark_migration.mjs index dec6d71b4f..6223d607a0 100644 --- a/services/web/scripts/mark_migration.js +++ b/services/web/scripts/mark_migration.mjs @@ -1,6 +1,9 @@ -const Adapter = require('../migrations/lib/adapter') -const fs = require('fs').promises -const path = require('path') +import Adapter from '../migrations/lib/adapter.mjs' +import { promises as fs } from 'fs' +import { join, dirname } from 'path' +import { fileURLToPath } from 'url' + +const __dirname = dirname(fileURLToPath(import.meta.url)) async function main(args) { if ( @@ -11,7 +14,7 @@ async function main(args) { args.includes('-h') ) { console.log('') - console.log('usage: node ./scripts/mark_migration.js migration state') + console.log('usage: node ./scripts/mark_migration.mjs migration state') console.log('') console.log(' migration: name of migration file') console.log(' state: executed | unexecuted') @@ -29,7 +32,7 @@ async function main(args) { } try { - await fs.access(path.join(__dirname, '../migrations', `${migration}.js`)) + await fs.access(join(__dirname, '../migrations', `${migration}.mjs`)) } catch (err) { throw new Error( `Error: migration ${migration} does not exist on disk: ${err}` @@ -54,7 +57,7 @@ async function main(args) { console.log('Done') } -if (require.main === module) { +if (fileURLToPath(import.meta.url) === process.argv[1]) { const args = process.argv.slice(2) main(args) .then(() => {