andrewroth initially wondered if it’s possible to run migrations without also running seeds in Discourse, as he noticed seeds were being executed during migrations. After further examination, andrewroth discovered that the seed files in Discourse are designed to only install necessary data and check site configurations before inserting data. andrewroth mentioned concern about the staff category being recreated, but riking clarified that seeds will only reset security settings of the staff category if it still exists and won’t recreate it if it’s been deleted.
Is there a way to run migrations without getting the seeds also run? Actually, I suppose I should check – is that normal behavior? As it is what I’m seeing. In any case I’ve tried rake -T seed/seeds/migrate to see if there are any tasks already defined and I don’t see any.. and also tried googling it a bit but I haven’t seen anything.
To answer my own question.. after some more examination, it seems this is done in lib/tasks/db.rake. Usually I think of seeds as run when you first install your application and never again, because you might customize the data and the seeds would put back stuff you modified or deleted. However, it seems from what I’m seeing in the code that discourse includes seed files that are smart enough to check 1) only install data that discourse absolutely needs (such as a “system” user) or 2) checks your site config before inserting data so that if you don’t want something, it won’t come back inadvertently. Just for the benefit of anyone else wondering about this, a more experienced dev can correct me if I’m not accurate here.
I thought the staff category which we had removed was going to come back when I saw the output of migrate (which runs seeds), but I didn’t actually check. So in actual fact, nothing.
The seeds will reset the security settings of the staff category, but only if it still exists.
If it detects that it had created the category in the past, but it’s not there anymore, it won’t recreate it (ever).