adacosta/mongoid_rails_migrations

Empty Migration

Closed this issue · 2 comments

mmcc commented

Hello,

First of all, found this after quite a bit of frustration, so thank you so much. I seem to be having some trouble though, and it's sure I'm misunderstanding. In the end, the answer to this question doesn't really matter as it's a simple manual fix regardless.

I run: rails generate mongoid:migration add_birthday_to_users birthday:date

It creates the migration no problem, but it's empty.

class AddBirthdayToUsers < Mongoid::Migration
def self.up
end

def self.down
end
end

Is this how it's designed? Does this simply create the migration skeleton? I've already done the manual work necessary, I'm just asking for future reference to make sure I'm not missing something. Thanks again!

Hi sh1ps,

The generator only creates a basic migration file. Because mongo is schemaless by design, there aren't columns to create as you would expect with relational databases. You have to specify behavior for your migrations in the up/down class methods.

mmcc commented

Ok that's what I thought might be the case. I'm really new to MongoDB so I've got a template app running with it to learn and it's pretty obvious I've got a ways to go. Thanks for your help and a great resource!