Adding model and table with plugin


#1

I’ve understood how a plugin should add tables in the db by creating a db/migrate/timestamp_table_name.rb file. Will this also create an ActiveRecord class or should I create one on my own? And how is that installed if I would put it in plugin/models/model_name.rb? Is this the way to go and will db:migrate take care of installing the model also?

Thanx for any help.


(Régis Hanol) #2

May I ask why do you need a new table? Adding migrations in a plugin is usually a bad idea (what happens when someone uninstalls the plugin?). To mitigate these issues, we’ve added support for custom fields on the user/post/topic models and even added a generic PluginStoreRow that you can use to store any kind of data. It should cover most of the use case that requires storing info in the database :wink:


PluginStore might not always be preferred
#3

Hmm, yeah I guess it can be implemented that way. Thanx


(Régis Hanol) #4