overleaf/services/web/migrations
Jakob Ackermann 55c1f852d6 Merge pull request #9447 from overleaf/jpa-dropbox-refresh-project-folder-names
[third-party-datastore] keep dropbox folder names up-to-date

GitOrigin-RevId: d82a6cb7b10ee2c81c5769d02896f65a347bbf67
2022-08-31 08:03:40 +00:00
..
lib Merge pull request #8542 from overleaf/jlm-drop-index-if-exists 2022-07-01 08:04:12 +00:00
20190720165251_create_migrations.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190730093801_script_example.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145001_create_contacts_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145002_create_deletedProjects_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145003_create_deletedSubscriptions_indexes.js Merge pull request #4806 from overleaf/jk-un-tag-migration 2021-08-20 08:03:31 +00:00
20190912145004_create_docHistoryIndex_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145005_create_docHistory_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145006_create_docOps_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145007_create_docSnapshots_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145008_create_docs_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145009_create_githubSyncEntityVersions_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145010_create_githubSyncProjectStates_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145011_create_githubSyncUserCredentials_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145012_create_institutions_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145013_create_messages_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145014_create_notifications_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145015_create_oauthAccessTokens_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145016_create_oauthApplications_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145017_create_oauthAuthorizationCodes_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145018_create_projectHistoryFailures_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145019_create_projectHistoryLabels_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145020_create_projectHistoryMetaData_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145021_create_projectHistorySyncState_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145022_create_projectImportFailures_indexes.js Merge pull request #6247 from overleaf/jpa-cleanup-mongo 2022-01-11 09:03:34 +00:00
20190912145023_create_projectInvites_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145024_create_projects_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145025_create_publishers_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145026_create_rooms_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145027_create_spellingPreferences_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145028_create_subscriptions_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145029_create_tags_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145030_create_templates_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145031_create_tokens_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20190912145032_create_users_indexes.js [web] Upgrade Prettier to match version in monorepo root (#6231) 2022-01-11 09:03:23 +00:00
20190912145033_create_userstubs_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20191106102104_saml-log-indexes.js Merge pull request #6247 from overleaf/jpa-cleanup-mongo 2022-01-11 09:03:34 +00:00
20191107191318_saml-indentifiers-index.js Merge pull request #6247 from overleaf/jpa-cleanup-mongo 2022-01-11 09:03:34 +00:00
20200110183327_brandVarationIdIndex.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20200120163346_atlas_recommended_indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20200210084301_remove-duplicate-deleted-things.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20200210121103_uniqueify-deletedthings-indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20200302143624_users_affiliationUnchecked_index.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20200522145727_dropProjectImportFailures.js Merge pull request #6247 from overleaf/jpa-cleanup-mongo 2022-01-11 09:03:34 +00:00
20200522145741_dropProjectImportBatchRecords.js Merge pull request #6247 from overleaf/jpa-cleanup-mongo 2022-01-11 09:03:34 +00:00
20200608213302_saml-cache-indexes.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20200729120824_update_subscriptions_manager_ids_index.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20201106094956_active-projects-index-with-id.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20210310111225_create_deletedFiles_projectId_index.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20210407085118_token-expiry-with-ttl-index.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20210408123210_create_docs_project_id_deleted_deletedAt_index.js Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00
20210721081758_create_history_display_index.js Create migration to add history display state index (#4335) 2021-07-28 02:06:20 +00:00
20210726083523_convert_confirmedAt_strings_to_dates.js Merge pull request #4350 from overleaf/ns-migration-tags 2021-08-04 02:05:43 +00:00
20210726083523_convert_split_tests_assigned_at_strings_to_dates.js Merge pull request #5364 from overleaf/ta-split-test-assignment-date-backfill 2021-10-22 08:04:49 +00:00
20210727123346_ce_sp_backfill_deleted_files.js Merge pull request #4352 from overleaf/sk-add-ce-sp-migration-deleted-files 2021-08-04 11:13:55 +00:00
20210727150530_ce_sp_backfill_deleted_docs.js Merge pull request #4352 from overleaf/sk-add-ce-sp-migration-deleted-files 2021-08-04 11:13:55 +00:00
20210728115327_ce_sp_backfill_dummy_doc_meta.js Merge pull request #4352 from overleaf/sk-add-ce-sp-migration-deleted-files 2021-08-04 11:13:55 +00:00
20210924140139_splittests-name-index.js Merge pull request #6247 from overleaf/jpa-cleanup-mongo 2022-01-11 09:03:34 +00:00
20220105123000_cleanup_unused_collections.js Merge pull request #6247 from overleaf/jpa-cleanup-mongo 2022-01-11 09:03:34 +00:00
20220105130000_fix_saml_indexes.js Merge pull request #6297 from overleaf/jpa-fix-index 2022-01-11 09:03:37 +00:00
20220222095146_split_tests_analytics_enabled.js Merge pull request #6785 from overleaf/em-split-tests-analytics-enabled 2022-03-01 09:04:15 +00:00
20220811111800_create_dropboxEntities_index.js Merge pull request #9212 from overleaf/jpa-record-dropbox-file-id 2022-08-12 08:06:04 +00:00
20220815105500_create_dropboxProjects_index.js Merge pull request #9291 from overleaf/jpa-dropbox-project-id 2022-08-18 08:03:38 +00:00
20220817120900_create_dropboxProjects_index.js Merge pull request #9447 from overleaf/jpa-dropbox-refresh-project-folder-names 2022-08-31 08:03:40 +00:00
README.md Merge pull request #4303 from overleaf/sk-tag-saas-migrations 2021-07-28 02:05:49 +00:00

Migrations

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

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

For example:

npm run migrations -- list -t 'saas'

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.js. 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'

To run all migrations in a saas environment:

npm run migrations -- migrate -t 'saas'

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.