1.2.0 • Published 2 years ago

@bgcbrasil/rds-operations v1.2.0

Weekly downloads
-
License
ISC
Repository
bitbucket
Last release
2 years ago

@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'>
CommandDescriptionRequired Params
deployRun all seeds and migrationsenv
migrateRun all migrationsenv
seedRun all seedsenv
migrate-undoUndo the last migrationenv
migrate-undo-allUndo all the migrations (!)env
create-userCreates a new userenv, username, password, roleName
delete-userDeletes a new userenv, username
create-roleCreates a new roleenv, roleName, accessType, database
ParamDescriptionEnum
accessTypeAccess type'viewer', 'writer', 'all'
envEnvironment'dev', 'staging', 'production'
usernameName of the usera string
passwordUsers passworda string
roleNameRole's namea string
databaseDatabase's namea 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