Jakob Ackermann 6691c5dc05 [monorepo] enable mongo notablescan for all services but web (#29497) 9 месяцев назад
..
config 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
lib 0036ad5f31 Remove docHistory collection from db helper 9 месяцев назад
scripts 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
.eastrc 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
.jenkinsIncludeFile 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190720165251_create_migrations.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145001_create_contacts_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145002_create_deletedProjects_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145003_create_deletedSubscriptions_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145004_create_docHistoryIndex_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145005_create_docHistory_indexes.mjs e8c829deab Clean up direct usages of db.docHistory 9 месяцев назад
20190912145006_create_docOps_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145007_create_docSnapshots_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145008_create_docs_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145009_create_githubSyncEntityVersions_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145010_create_githubSyncProjectStates_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145011_create_githubSyncUserCredentials_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145012_create_institutions_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145013_create_messages_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145014_create_notifications_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145015_create_oauthAccessTokens_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145016_create_oauthApplications_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145017_create_oauthAuthorizationCodes_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145018_create_projectHistoryFailures_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145019_create_projectHistoryLabels_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145020_create_projectHistoryMetaData_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145021_create_projectHistorySyncState_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145022_create_projectImportFailures_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145023_create_projectInvites_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145024_create_projects_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145025_create_publishers_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145026_create_rooms_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145027_create_spellingPreferences_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145028_create_subscriptions_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145029_create_tags_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145030_create_templates_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145031_create_tokens_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145032_create_users_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20190912145033_create_userstubs_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20191106102104_saml-log-indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20191107191318_saml-indentifiers-index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20200110183327_brandVarationIdIndex.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20200120163346_atlas_recommended_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20200210084301_remove-duplicate-deleted-things.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20200210121103_uniqueify-deletedthings-indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20200302143624_users_affiliationUnchecked_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20200522145727_dropProjectImportFailures.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20200522145741_dropProjectImportBatchRecords.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20200608213302_saml-cache-indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20200729120824_update_subscriptions_manager_ids_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20201106094956_active-projects-index-with-id.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20210310111225_create_deletedFiles_projectId_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20210407085118_token-expiry-with-ttl-index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20210408123210_create_docs_project_id_deleted_deletedAt_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20210721081758_create_history_display_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20210726083523_convert_confirmedAt_strings_to_dates.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20210726083523_convert_split_tests_assigned_at_strings_to_dates.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20210727123346_ce_sp_backfill_deleted_files.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20210727150530_ce_sp_backfill_deleted_docs.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20210728115327_ce_sp_backfill_dummy_doc_meta.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20210924140139_splittests-name-index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20220105123000_cleanup_unused_collections.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20220105130000_fix_saml_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20220222095146_split_tests_analytics_enabled.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20220811111800_create_dropboxEntities_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20220815105500_create_dropboxProjects_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20220817120900_create_dropboxProjects_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20220825160708_recreate_dropboxEntities.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20220826104236_disable_alpha_beta_program.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20220830140459_create_index_user_labsProgram_labsProgramGalileo.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20220913105500_create_auditLog_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20220913125500_migrate_auditLog_to_collections.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20220929193200_add_auditLog_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20221111111111_ce_sp_convert_archived_state.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20221122191857_project_history_chunks_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20230110140452_rename_recurly_cached_status.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20230124092607_clear_old_2fa_setup.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20230207134844_group_invite_emails_to_lowercase.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20230217205311_fix_deleted_history_chunks_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20230315170739_back_fill_doc_rev.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20230405190240_oauth_refresh_tokens_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20230406125632_oauth_tokens_ttl.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20230426095212_personal_oauth_tokens_user_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20230428154643_history_chunks_garbage_collection_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20230502180757_server_pro_oauth_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20230512100122_ensure_history_migration.mjs 6691c5dc05 [monorepo] enable mongo notablescan for all services but web (#29497) 9 месяцев назад
20230616153016_user_features_updated_at_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20230817081910_back_fill_gitBridge_feature_server_pro.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20230928092537_backfill_subscriptions_managed_users_feature_flag.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20231016101457_drop_history_display_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20231025094810_sso_config_certificates_array.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20231030160030_managed_users_enabled.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20231031164732_drop_redundant_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20231101153447_partial_last_opened_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20231101191643_drop_unused_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20231101204352_drop_unused_saas_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20231105000000_move_doc_versions_from_docops_to_docs.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20231110192205_drop_docops_collection.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20231113173237_tokens_user_id_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20240115172206_oauth_issuer_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20240220130452_remove_deleted_users_from_token_access_refs.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20240524135408_add_token_hmac_project_invite_tokens.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20240531082910_remove_project_invite_tokens.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20240618125145_cleanup_user_features_templates.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20240625101055_add_ai_policy_to_group_policy.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20240713110905_emails_reversed_hostname.mjs 6691c5dc05 [monorepo] enable mongo notablescan for all services but web (#29497) 9 месяцев назад
20240730155209_create_project_imageName_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20240923131936_create_user_last_active_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20241002180623_drop_unused_collections.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20241111133330_remove_null_managed_users_sso_from_subscriptions.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20241204103349_create_reviewer_refs_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250115110745_oauth_user_id_index_no_partial.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250116090000_onboardingDataCollection_updatedAt_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250116090001_deletedUsers_non_expired_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250121114712_add_chat_policy_to_group_policy.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250126195914_update_deleterData.deletedAt_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250130104049_create_dropboxEntities_userId_projectId_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250203164153_create_project_pendingChangeAt_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250205145327_drop_rooms_projectId_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250206103037_create_rooms_projectId_threadId_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250212144722_clear_history_metadata.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250307120446_create_project_lastBackedUpVersion_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250318144744_add_subscription_and_deleted_subscription_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250319110212_update_saml_logs_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250320161029_update_inactive_project_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250321092555_add_deleted_to_project_id_in_s3_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250321094339_update_saml_identifiers_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250321112055_create_deletedUsers_email_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250321135735_add_email_to_emails_reversed_hostname_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250321160345_add_type_to_pat_user_id_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250331120946_add_email_to_teamInvites_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250403133427_create_index_for_script_logs.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250409155536_group_audit_log_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250411200550_active_chunk_index_update.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250519101127_drop_deletedFiles.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250519101128_binary_files_migration_check.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250528141310_drop_projectHistoryMetaData_collection.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250604112908_add_dropbox_policy_to_group_policy.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250620152657_ensure_collaborator_arrays.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250702203054_recurly_subscription_id_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250728103841_group_audit_log_expire_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250827155732_optimise_lastBackedUpVersion_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250828095305_create_subscription_v1_id_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250828100935_drop_old_lastBackedUpVersion_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250912102601_add_timestamp_to_projectAuditLogEntries_index.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20250922141050_project_history_sizes_indexes.mjs 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
20251010082205_add_unique_constraint_subscription_v1_id.mjs a33d799ee4 Merge pull request #29002 from overleaf/ii-domain-capture-v1-field 9 месяцев назад
20251016092030_user_audit_log_managed_group_index.mjs a4d9d5789a [web] Add User logs to Group Audit Logs view (#29480) 9 месяцев назад
20251016112728_create_emailNotifications_collection.mjs 387ef81a31 Add migration script for creating emailNotifications collection (#28972) 9 месяцев назад
20251023094210_change_emailtNotifications_index_from_scheduledAt_to_recipient_id.mjs 42a80a1ca3 feat: moving to grouping by primarily recipient, then by project 9 месяцев назад
20251023115700_drop_docHistory_collection.mjs 766a7c6a37 Add migration to remove docHistory collection 9 месяцев назад
Jenkinsfile 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
README.md 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
package.json 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад
tsconfig.json 729e0f5ac9 move migrations to shared location (#28306) 10 месяцев назад

README.md

Migrations

Migrations for the app environment live in this folder, and use the East migration framework.

We have a npm script which wraps east: npm run migrations -- ...

For example:

npm run migrations -- list -t 'server-ce'

For SAAS, use the rake tasks for staging/production

rake deploy:migrations:list[staging]

Environments and Tags

Overleaf is deployed in three different environments:

  • server-ce: community edition installations (the base system)
  • server-pro: server pro installations
  • saas: the production overleaf site

All migrations are tagged with the environments they should run in. For example, a migration that should run in every environment would be tagged with ['server-ce', 'server-pro', 'saas'].

When invoking east, we specify the relevant tags with the -t or --tags flag. Our adapter will refuse to run if this flag is not set.

Creating new migrations

To create a new migration, run:

npm run migrations -- create <migration name>

This command will create a new migration file in the migrations folder, based on a template. The template provides migrate and rollback methods, which are run by the east binary when running the migrations. rollback should undo the changes made in migrate.

Running scripts as a migration

To run a script in a migration file, look at migrations/20190730093801_script_example.js, which runs the script scripts/example/script_for_migration.mjs. This uses a method where the script can be run standalone via node, or through the migrations' mechanism.

Running migrations

To run all migrations in a server-ce environment:

npm run migrations -- migrate -t 'server-ce'
# Note: They are run by default on container start.

To run all migrations in a SAAS environment use the rake task:

# list first and check that only your newly added migration is shown. If not, ask in the dev channel for help.
rake deploy:migrations:list[staging]
# After confirming the listing, run the migrations
rake deploy:migrations[staging]

To run all migrations in the dev-env:

make services/web/migrate
# Note: "make install" will pick them up as well

The -t flag also works with other east commands like rollback, and list.

For other options, or for information on how to roll migrations back, take a look at the East documentation.

Tips

Try to use Mongo directly via the db object instead of using Mongoose models. Migrations will need to run in the future, and model files can change. It's unwise to make the migrations depend on code which might change.

Note: Running east rollback without any arguments rolls back all migrations, which you may well not want.