Skip to content

Latest commit

 

History

History
105 lines (86 loc) · 2.37 KB

MIGRATION.md

File metadata and controls

105 lines (86 loc) · 2.37 KB

Migration to 11.102.0

prototypeUrl renamed to prototypeName

db.repositories.updateMany({}, { $rename: { "prototypeUrl": "prototypeName" } });

Migration to 11.97.0

ServiceType data model FrontendService -> frontend, BackendService -> backend

db.repositories.updateMany(
  { "serviceType": "BackendService" },
  { $set: { "serviceType": "backend" } }
);

db.repositories.updateMany(
  { "serviceType": "FrontendService" },
  { $set: { "serviceType": "frontend" } }
);

Tag data model AdminFrontend -> admin, Stub -> stub, Api -> api

db.repositories.updateMany(
  { "tags": "Stub" },
  { $set: { "tags.$[element]": "stub" } },
  { arrayFilters: [{ "element": "Stub" }] }
);

db.repositories.updateMany(
  { "tags": "AdminFrontend" },
  { $set: { "tags.$[element]": "admin" } },
  { arrayFilters: [{ "element": "AdminFrontend" }] }
);

db.repositories.updateMany(
  { "tags": "Api" },
  { $set: { "tags.$[element]": "api" } },
  { arrayFilters: [{ "element": "Api" }] }
);

Migration to 11.23.0

Data model changes from teams with repos, to repos with teams.

db.getCollection('teamsAndRepositories').aggregate([
     {$unwind: "$repositories"}
    ,{$group: {
        _id: "$repositories.name", 
        repositories: {$max: "$repositories"},
        teams: {$addToSet: "$teamName"},
        }
     }
    ,{$addFields: {"repositories.teamNames":"$teams" }}
    ,{$replaceRoot: {newRoot: "$repositories"} }
    ,{$addFields: {"isArchived": "$archived"}}
    ,{$project: {archived: 0}}
    ,{$out: "repositories"}
])

Migration to 11.0.0

db.getCollection('updateTime').drop()

Use Date rather than Long

db.getCollection('teamsAndRepositories').renameCollection('teamsAndRepositories-bak')
db.getCollection('teamsAndRepositories-bak').aggregate([
  {
    $addFields: {
      repositories: {
        $map: {
          input: '$repositories',
          as: 'repository',
          in: {
            $mergeObjects: [
              "$$repository",
              {
                createdDate: { $toDate: "$$repository.createdDate" },
                lastActiveDate: { $toDate: "$$repository.lastActiveDate" }
              }
            ]
          }
        }
      },
      updateDate: { $toDate: "$updateDate"},
    }
  },
  { $out: "teamsAndRepositories" }
]);