{"size": 671, "ext": "js", "max_stars_repo_path": "database/dynamodb/migrate.js", "max_stars_repo_name": "dwiajik/btcid-bot", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "database/dynamodb/migrate.js", "max_issues_repo_name": "dwiajik/btcid-bot", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "database/dynamodb/migrate.js", "max_forks_repo_name": "dwiajik/btcid-bot", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.84, "max_line_length": 91, "alphanum_fraction": 0.6661698957}
const AWS = require("aws-sdk");
const fs = require("fs");

const migrationDir = `${__dirname}/tables`;

const tables = fs.readdirSync(migrationDir)
  .map(file => JSON.parse(fs.readFileSync(`${migrationDir}/${file}`, 'utf8')));

AWS.config.update({
  region: process.env.AWS_REGION,
  endpoint: process.env.DYNAMODB_HOST,
});

const dynamodb = new AWS.DynamoDB();

tables.forEach(params => {
  dynamodb.createTable(params, function(err, data) {
    if (err) {
      console.error("Unable to create table. Error JSON:", JSON.stringify(err, null, 2));
    } else {
      console.log("Created table. Table description JSON:", JSON.stringify(data, null, 2));
    }
  });
});
