topcoderinc / va-online-memorial-data-models

0 stars 2 forks source link

Add salute and share counts for frontend Challenge 6 #1

Closed ramillim closed 6 years ago

ramillim commented 6 years ago

Adds the following columns to the post model types (Badge, Photo, Story, Testimonial).:

This is conducted through a database migration, so I had to add a config/config.json file to be able to run migrations with the CLI tool. The database configuration for production is not functional. This is for the purposes of running the sequelize cli tool because the other database config uses environment variables located here: https://github.com/topcoderinc/va-online-memorial-data-models/blob/master/config/custom-environment-variables.json

I'm not certain how migrations are being run in production (this may actually be the first migration), but it looks like previously it is using a forced sequelize.sync that runs a migration if the model files change. I think this is fine for generating a dev/test schema, but probably not something you want to have happen in production: https://github.com/topcoderinc/va-online-memorial-data-models/blob/master/index.js#L103 I suspect this only gets run when the init-data.js file is called in the rest API project: https://github.com/topcoderinc/va-online-memorial-rest-api/blob/master/init-data.js#L20

Bumped the version in package.json from 0.0.1 to 0.0.2 to reflect schema changes (maybe it should be version 0.1, but I don't know what the project's conventions are).

Running Migrations

node_modules/.bin/sequelize db:migrate

For migration instructions, see: http://docs.sequelizejs.com/manual/tutorial/migrations.html

Limitation

The migration doesn't take into account previous salutes that may already exist in the PostSalutes table. It simply initializes the columns at 0.