enGMzizo / copy-dynamodb-table

Copy Dynamodb table to another in the same or different zone , It is 100% safe. Speed depends on your destination table user-defined write provisioned throughput
130 stars 38 forks source link

Copy only schema #27

Closed defaultbr closed 4 years ago

defaultbr commented 4 years ago

Hello, is there any flag to pass to not copy the data, only the schema?

My use case:

My environments are in different accounts, so i have a account for dev, another for uat and other for prod.

So my first situation is to keep synced the schema from dev to prod (at least for the first creation, for migration i should think in another job)

Than after that, i will create a cron job to sync data down, bring data from prod to uat and than to dev

if your lib can replicate only the schema, i can use it for both cases.

Today im using .json schema template and calling aws cli to create the table, it works, but i'm looking for a more robust or better way

enGMzizo commented 4 years ago

Yes , I added this feature to copy schema only

var copy = require('copy-dynamodb-table').copy

copy({
    source: {
      tableName: 'source_table_name', 
    },
    destination: {
      tableName: 'destination_table_name', 
    },
    log: true, 
    create : true ,
    schemaOnly : true // copy schema only  < ------- HERE
  },
  function (err, result) {
    if (err) {
      console.log(err)
    }
    console.log(result)
  })
defaultbr commented 4 years ago

AWESOME!

Will try, thank you so much!