I have a file that will generate some collections and seed them for my application to work when I am developing. This currently runs as server-side code every time the application starts/restarts, but I only want it to run when I start the application for the first time in my development environment, prior to coding, so that I know that the DB has all the structure in place. How best to do this?
Example:
import Fixtures from '../imports/startup/server/fixtures.js';
Meteor.startup(function () {
var Fixture = new Fixtures;
Fixture.loadBaseData();
});
Are you basically trying to run migrations? Basically, create a collection and write to it when you run the migration. Before you run the migration however, you check if there is a record in it. If there is, don’t run; otherwise, run and add the record.
There are a few migration packages on atmosphere you can look into as well.
So, bascially, I want to ensure that collections and records are in place (in my development environment), so that when am developing the application further (and testing as I go along), I have the correct data in Mongo for the application to work as expected.
Migrations sounds like the sort of thing I need to use. What would be ideal though is for the Migrations to run automatically, in the dev environment only and only run them once when I start the Meteor app for the first time, i.e. not get continually run each time I update the code.