diff --git a/package.json b/package.json index 2e7a7b0..65d4adc 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ "clean": "gulp clean", "test:fe": "gulp protractor", "lint": "gulp lint", - "heroku-postbuild": "gulp build" + "heroku-postbuild": "gulp build", + "create-tables": "CREATE_DB=true node scripts/create-update-tables.js" }, "dependencies": { "angular": "~1.7.9", diff --git a/scripts/create-update-tables.js b/scripts/create-update-tables.js new file mode 100644 index 0000000..10b8021 --- /dev/null +++ b/scripts/create-update-tables.js @@ -0,0 +1 @@ +require('../src/models'); \ No newline at end of file diff --git a/src/models/index.js b/src/models/index.js index 38fa4ea..96811e2 100644 --- a/src/models/index.js +++ b/src/models/index.js @@ -22,10 +22,17 @@ if (config.DYNAMODB.IS_LOCAL === 'true') { } dynamoose.setDefaults({ - create: true, - update: true, + create: false, + update: false, }); +if (process.env.CREATE_DB) { + dynamoose.setDefaults({ + create: true, + update: true, + }); +} + const models = {}; // Bootstrap models