sails-dynamodb icon indicating copy to clipboard operation
sails-dynamodb copied to clipboard

Automatically create tables

Open jkeczan opened this issue 9 years ago • 13 comments

When adding new models that connect to dynamo db, the adapter does not automatically create the table if it does not already exist. Is this by design? Should we make a specific call to create the table? We do not want to have to create the table manually each time. We also realize it does not lazy load the table either (we tried creating a new object but this also failed to create the table). If we create the table manually, everything else seems to work as expected. No errors are thrown.

jkeczan avatar Aug 28 '15 15:08 jkeczan

We are also getting the following error when calling SomeModel.create():

/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/error/WLError.js:30
  this.rawStack = (this._e.stack.replace(/^Error(\r|\n)*(\r|\n)*/, ''));
TypeError: Cannot read property 'replace' of undefined
    at new WLError (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/error/WLError.js:30:33)

jkeczan avatar Aug 28 '15 15:08 jkeczan

This adapter currently does not create tables. It would take a little bit of effort to support this, but it's totally in the realm of possibility! I'm making this issue a feature request.

devinivy avatar Oct 14 '15 13:10 devinivy

+1 for this feature

mlconnor avatar Nov 11 '15 21:11 mlconnor

+1

bohdanrutylo avatar Dec 28 '15 12:12 bohdanrutylo

has anyone added this functionality?

muditjuneja avatar Jan 05 '16 19:01 muditjuneja

Nope! Still on the table.

devinivy avatar Jan 05 '16 19:01 devinivy

Can guide me?

muditjuneja avatar Jan 05 '16 19:01 muditjuneja

Can I use this one : https://github.com/TakenPilot/sails-dynamodb ??

muditjuneja avatar Jan 05 '16 19:01 muditjuneja

That library does appear to create tables here, though I'd estimate this library is otherwise more mature. Maybe we can learn from their approach.

devinivy avatar Jan 05 '16 19:01 devinivy

+1

carlospliego avatar Oct 19 '16 23:10 carlospliego

+1

redhat-raptor avatar Feb 22 '17 09:02 redhat-raptor

I'm happy to work on this. If someone can answer my issue #37 about using a local instance.

liftyourgame avatar Mar 04 '17 01:03 liftyourgame

@liftyourgame , I commented on #37 about using dynamodb local. For others, see this link: https://aws.amazon.com/blogs/aws/dynamodb-local-for-desktop-development, I actually found it to not be troublesome to just make the database tables myself. There are some quirks with dynamo around indexes and I think making these choices explicit when setting up the table is right. That said, if implemented well, this could be a great feature. It takes a while to add an index to an existing table and that could be annoying.

ferrants avatar Mar 04 '17 06:03 ferrants