0

Some of our Migrations take a considerable time to perform. So I am looking for a way to implement some kind of event or callback to notify the user interface that it should admonish the user to patience. I can write a custom event of course, but where do I place the handler for it?

Any pointer to some resources how to deal with this is very much appreciated!

Dabblernl
  • 15,831
  • 18
  • 96
  • 148
  • What I think I didn't realize is whether you manually run migrations at a certain time you decide, or you have lots of databases, and you need an automation to block the user. If the second option is correct - then my answer should help. Just a trivial flag for each db and you are set. – ilans Jan 27 '15 at 23:05

1 Answers1

0

Why don't you just put a flag on the database once the migrations start and unflag when process ends? That flag can easily be read in order to notify the user interface. Keep it simple...

Here are some ideas when to raise the flag:

  • The "event" that can be used is the InitializeDatabase function, if you are using a custom initializer.
  • If you are using a DbMigrator like I do, in order to manually performing migrations, you can just flag the database before initialization. You can see here (my answer is down there) how to use DbMigrator.
  • Another option is the Up function of the first migration (when using Automatic Migrations that might work - but it's a bit more tricky).
Community
  • 1
  • 1
ilans
  • 2,537
  • 1
  • 28
  • 29
  • I do not understand what you mean by a 'Flag': is it some kind of global property or an event? How do I check if InitializeDatabase actually calls any 'Up' methods? – Dabblernl Jan 27 '15 at 22:15
  • @Dabblernl - by `flag` I mean for a trivial boolean field in the database.. just put 0/1 in some field. Put 1 when the migrations start and read this from the UI to know whether the migrations had started. – ilans Jan 27 '15 at 22:49
  • @Dabblernl - Best would be to use a DbMigrator - you create it and than check if there are migrations using `GetPendingMigrations.Count` - if it's > 0 than you set the `flag` in the database. It's two lines of code. – ilans Jan 27 '15 at 23:01