-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
107 additions
and
43 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
src/server/database/migrations/20170821152300-providerTeamIdsToTeamIdjs.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
exports.up = async (r) => { | ||
const tables = [ | ||
r.table('Provider').replace((row) => { | ||
return row | ||
.merge({ | ||
teamId: row('teamIds')(0).default(null), | ||
isActive: row('teamIds').count().ne(0) | ||
}) | ||
.without('teamIds'); | ||
}) | ||
]; | ||
try { | ||
await Promise.all(tables); | ||
} catch (e) { | ||
console.log('Exception during Promise.all(tables)'); | ||
} | ||
const indices = [ | ||
r.table('Provider').indexDrop('teamIds'), | ||
r.table('Provider').indexCreate('teamId') | ||
]; | ||
try { | ||
await Promise.all(indices); | ||
} catch (e) { | ||
console.log('Exception during Promise.all(indices)'); | ||
} | ||
}; | ||
|
||
exports.down = async (r) => { | ||
const tables = [ | ||
r.tableDrop('Provider').replace((row) => { | ||
return row | ||
.merge({ | ||
teamIds: r.branch( | ||
row('teamId'), | ||
[row('teamId')], | ||
[] | ||
) | ||
}) | ||
.without('teamId', 'isActive'); | ||
}) | ||
]; | ||
try { | ||
await Promise.all(tables); | ||
} catch (e) { | ||
console.log('Exception during Promise.all(tables)'); | ||
} | ||
const indices = [ | ||
r.table('Provider').indexCreate('teamIds', {multi: true}), | ||
r.table('Provider').indexDrop('teamId') | ||
]; | ||
try { | ||
await Promise.all(indices); | ||
} catch (e) { | ||
console.log('Exception during Promise.all(indices)'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters