1.2.0 • Published 2 years ago
@bgcbrasil/rds-operations v1.2.0
@bgcbrasil/rds-operations
What is this repository for?
- Realize migrations and seeds in SQL Databases
How to use it
- First, you must create the following file:
// Path 'config/rdsConfig.js'
const { env } = require("minimist")(process.argv.slice(2));
AWS.config.region = "us-east-1";
AWS.config.credentials = new AWS.SharedIniFileCredentials({
profile: `${env}-bgc`,
});
const ssm = new AWS.SSM({ region: "eu-north-1" });
const rds = new AWS.RDS({ region: "eu-north-1" });
const sts = new AWS.STS();
/** @typedef {import('sequelize').Sequelize} sequelize */
/** @typedef {import('sequelize').Transaction} transaction */
module.exports = async function () {
const dbPassword = await getPassword(); // returns the password of you instance
const { database, username, host } = await getDatabaseOptions(); // returns infos about your db instance
const dialect = "postgres";
const pool = {
max: 60,
min: 0,
acquire: 120000,
idle: 1000,
evict: 500,
};
return {
username,
database,
dialect,
pool,
password: dbPassword,
host,
globalReplacements: await loadGlobalReplacements(), // function responsable to return variables to be replaced in migrations or seeds
};
};
- You should be able to run the CLI with:
npx -p @bgcbrasil/rds-operations <command> --env <'dev'|'staging'|'production'>
Command | Description | Required Params |
---|---|---|
deploy | Run all seeds and migrations | env |
migrate | Run all migrations | env |
seed | Run all seeds | env |
migrate-undo | Undo the last migration | env |
migrate-undo-all | Undo all the migrations (!) | env |
create-user | Creates a new user | env, username, password, roleName |
delete-user | Deletes a new user | env, username |
create-role | Creates a new role | env, roleName, accessType, database |
Param | Description | Enum |
---|---|---|
accessType | Access type | 'viewer', 'writer', 'all' |
env | Environment | 'dev', 'staging', 'production' |
username | Name of the user | a string |
password | Users password | a string |
roleName | Role's name | a string |
database | Database's name | a string |
1.2.0
2 years ago
1.2.0-beta.1
2 years ago
1.2.0-beta.2
2 years ago
1.1.0
2 years ago
1.1.0-dev.3
2 years ago
1.1.0-dev.4
2 years ago
1.1.0-beta.1
2 years ago
1.1.0-dev.2
2 years ago
1.1.0-dev.1
2 years ago
1.0.1
2 years ago
1.0.0-dev.5
2 years ago
1.0.0
2 years ago
1.0.0-dev.4
2 years ago
1.0.0-dev.3
2 years ago
1.0.0-dev.2
2 years ago
1.0.0-dev.1
2 years ago