20260609120000_create_librarySyncStates_collection.mjs 704 B

12345678910111213141516171819202122232425262728
  1. import Helpers from './lib/helpers.mjs'
  2. import { getCollectionInternal } from './lib/mongodb.mjs'
  3. const tags = ['saas']
  4. const indexes = [
  5. {
  6. key: { userId: 1, provider: 1, libraryType: 1, libraryId: 1 },
  7. name: 'userId_1_provider_1_libraryType_1_libraryId_1',
  8. unique: true,
  9. },
  10. ]
  11. const migrate = async () => {
  12. const librarySyncStates = await getCollectionInternal('librarySyncStates')
  13. await Helpers.addIndexesToCollection(librarySyncStates, indexes)
  14. }
  15. const rollback = async () => {
  16. const librarySyncStates = await getCollectionInternal('librarySyncStates')
  17. await Helpers.dropIndexesFromCollection(librarySyncStates, indexes)
  18. }
  19. export default {
  20. tags,
  21. migrate,
  22. rollback,
  23. }