-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from maick05/development
Development
- Loading branch information
Showing
82 changed files
with
2,027 additions
and
386 deletions.
There are no files selected for viewing
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 @@ | ||
MIGRATE_dbConnectionUri= |
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 |
---|---|---|
@@ -1,21 +1,22 @@ | ||
# name: e2e | ||
# on: | ||
# push: | ||
# branches: | ||
# - main | ||
# - development | ||
# jobs: | ||
# e2eTests: | ||
# name: e2e-Tests | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - uses: actions/checkout@v2 | ||
# with: | ||
# fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | ||
# - name: install | ||
# run: npm install | ||
# - name: e2e test | ||
# run: npm run test:e2e | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | ||
name: e2e | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
jobs: | ||
e2eTests: | ||
name: e2e-Tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | ||
- name: install | ||
run: npm install | ||
- name: e2e test | ||
run: npm run test:e2e | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,4 +39,8 @@ node_modules | |
# Sonar | ||
.scannerwork/.sonar_lock | ||
.scannerwork/report-task.txt | ||
*.ucfg | ||
*.ucfg | ||
|
||
# Env | ||
.env | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"migrations-dir": "./src/config/database/migrations" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
require(`../../../dist/microservice/adapter/helper/extensions/string.extension.js`); | ||
const config = require('../../../dist/config/configuration.js').default(); | ||
|
||
module.exports = async function (collectionName, schemaName = null) { | ||
schemaName = schemaName ? schemaName : collectionName; | ||
const mongoose = require('mongoose'); | ||
const schemaCollection = require(`../../../dist/microservice/domain/schemas/${schemaName}.schema`); | ||
const modelSchema = schemaCollection[`${schemaName.capitalize()}Schema`]; | ||
await mongoose.connect(config.database.mongodb.connection, { | ||
useNewUrlParser: true, | ||
useUnifiedTopology: true | ||
}); | ||
return mongoose.model(collectionName, modelSchema); | ||
}; |
60 changes: 60 additions & 0 deletions
60
src/config/database/migrations/1655748067450-add_alias_prop.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,60 @@ | ||
/* eslint-disable prettier/prettier */ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
const mongoose = require('mongoose'); | ||
|
||
const startConnection = require('../migration-connection-factory.js'); | ||
|
||
const model = startConnection('countries', 'country'); | ||
|
||
/** | ||
* Make any changes you need to make to the database here | ||
*/ | ||
async function up() { | ||
const res = (await model).aggregate([ | ||
{ | ||
$project: { | ||
alias: { $objectToArray: '$translations' }, | ||
iso2: '$iso2', | ||
iso3: '$iso3', | ||
name: '$name' | ||
} | ||
} | ||
]); | ||
|
||
for await (const item of res) { | ||
const arrAlias = await item.alias.map((obj) => obj.v); | ||
arrAlias.push(item.name); | ||
arrAlias.push(item.iso2); | ||
arrAlias.push(item.iso3); | ||
await ( | ||
await model | ||
) | ||
.findByIdAndUpdate(item._id, { | ||
$set: { | ||
alias: arrAlias | ||
} | ||
}) | ||
.exec(); | ||
} | ||
} | ||
|
||
/** | ||
* Make any changes that UNDO the up function side effects here (if possible) | ||
*/ | ||
async function down() { | ||
await ( | ||
await model | ||
) | ||
.updateMany( | ||
{}, | ||
{ | ||
$set: { | ||
alias: [] | ||
} | ||
} | ||
) | ||
.exec(); | ||
mongoose.connection.close(); | ||
} | ||
|
||
module.exports = { up, down }; |
73 changes: 73 additions & 0 deletions
73
src/config/database/migrations/1655914826752-rename_country_props.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,73 @@ | ||
/* eslint-disable prettier/prettier */ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
const mongoose = require('mongoose'); | ||
|
||
const startConnection = require('../migration-connection-factory.js'); | ||
|
||
const model = startConnection('countries', 'country'); | ||
|
||
/** | ||
* Make any changes you need to make to the database here | ||
*/ | ||
async function up() { | ||
try { | ||
await ( | ||
await model | ||
) | ||
.updateMany( | ||
{}, | ||
{ | ||
$rename: { | ||
numeric_code: 'numericCode', | ||
phone_code: 'phoneCode', | ||
currency_name: 'currencyName', | ||
currency_symbol: 'currencySymbol' | ||
} | ||
}, | ||
{ | ||
// Strict allows to update keys that do not exist anymore in the schema | ||
strict: false | ||
} | ||
) | ||
.exec(); | ||
mongoose.connection.close(); | ||
} catch (err) { | ||
console.log('err --> '); | ||
console.log(err); | ||
mongoose.connection.close(); | ||
} | ||
} | ||
|
||
/** | ||
* Make any changes that UNDO the up function side effects here (if possible) | ||
*/ | ||
async function down() { | ||
try { | ||
await ( | ||
await model | ||
) | ||
.updateMany( | ||
{}, | ||
{ | ||
$rename: { | ||
numericCode: 'numeric_code', | ||
phoneCode: 'phone_code', | ||
currencyName: 'currency_name', | ||
currencySymbol: 'currency_symbol' | ||
} | ||
}, | ||
{ | ||
// Strict allows to update keys that do not exist anymore in the schema | ||
strict: false | ||
} | ||
) | ||
.exec(); | ||
mongoose.connection.close(); | ||
} catch (err) { | ||
console.log('err --> '); | ||
console.log(err); | ||
mongoose.connection.close(); | ||
} | ||
} | ||
|
||
module.exports = { up, down }; |
73 changes: 73 additions & 0 deletions
73
src/config/database/migrations/1655917316641-rename_state_props.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,73 @@ | ||
/* eslint-disable prettier/prettier */ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
const mongoose = require('mongoose'); | ||
|
||
const startConnection = require('../migration-connection-factory.js'); | ||
|
||
const model = startConnection('state'); | ||
|
||
/** | ||
* Make any changes you need to make to the database here | ||
*/ | ||
async function up() { | ||
try { | ||
await ( | ||
await model | ||
) | ||
.updateMany( | ||
{}, | ||
{ | ||
$rename: { | ||
state_code: 'stateCode', | ||
country_id: 'countryId', | ||
country_name: 'countryName', | ||
country_code: 'countryCode' | ||
} | ||
}, | ||
{ | ||
// Strict allows to update keys that do not exist anymore in the schema | ||
strict: false | ||
} | ||
) | ||
.exec(); | ||
mongoose.connection.close(); | ||
} catch (err) { | ||
console.log('err --> '); | ||
mongoose.connection.close(); | ||
throw err; | ||
} | ||
} | ||
|
||
/** | ||
* Make any changes that UNDO the up function side effects here (if possible) | ||
*/ | ||
async function down() { | ||
try { | ||
await ( | ||
await model | ||
) | ||
.updateMany( | ||
{}, | ||
{ | ||
$rename: { | ||
stateCode: 'state_code', | ||
countryId: 'country_id', | ||
countryName: 'country_name', | ||
countryCode: 'country_code' | ||
} | ||
}, | ||
{ | ||
// Strict allows to update keys that do not exist anymore in the schema | ||
strict: false | ||
} | ||
) | ||
.exec(); | ||
mongoose.connection.close(); | ||
} catch (err) { | ||
console.log('err --> '); | ||
mongoose.connection.close(); | ||
throw err; | ||
} | ||
} | ||
|
||
module.exports = { up, down }; |
Oops, something went wrong.