How to create migration files?

I would like to create a new table (to store the graph for vote delegation). Should I create a migration file similar to db/migrate/20120311170118_create_users.rb manually ? Or is it enough to update the == Schema Information at the end of the model file ? I naively tried that and run rake db:migrate but it did not work :wink:

1 Like

No, you need to create migrate file and run it with db:migrate (see ActiveRecord docs )

2 Likes

Note that if you are developing a plugin, discourse provides a PluginStore to help you avoid migrations, since undoing then when the plugin gets uinstalled is a open problem.

5 Likes

Thanks, I’m glad I did not miss something :slight_smile:

cool. Is there a plugin I could read to see how it’s used ? I found something on rubydoc.

Canned replies is recent and does it very clearly:

https://github.com/discourse/discourse-canned-replies/blob/master/plugin.rb

3 Likes

OK, thanks… I see …