1

I have couple yesod apps deployed using keter with PostgreSQL. The thing I really like about them is the automatic DB migration that happens on deployment.

But, now I have faced a small problem: I set up DB replica on another virtual machine; the second DB is slave and thus read-only. When I start keter with my apps deployed, the apps cannot start because they cannot successfully execute migration script. There are dummy changes only, no real change of table, but the app fails to start with "cannot execute ALTER TABLE in a read-only transaction".

Is it possible to temporarily disable migration scripts at startup via keter or app configs or ENV variables?

artem
  • 363
  • 1
  • 9

1 Answers1

0

Is it possible to temporarily disable migration scripts at startup via keter or app configs or ENV variables?

Yes, it's possible. The simplest way to do is using environment variables in my opinion. If you are using yesod's scaffolding site, then you have to make the changes in the makeFoundation function which runs the migration. Note the the function named runMigration is used to perform it. You need to add a appropriate conditional to make it work.

Sibi
  • 47,472
  • 16
  • 95
  • 163
  • Thanks, but I meant to do it without modifying the code of the app. – artem Nov 13 '18 at 09:05
  • @artem I don't see any way of doing it without modifying the code. One hypothetical thing I can image is to see if postgres provides any query for checking if it's in read only mode. You can then use that information in the `runMigration` function to not run any migration. But for that to work, you have to patch `persistent` library and modify some code! – Sibi Nov 13 '18 at 15:52
  • Yep, so I take this as an answer "not possible" – artem Nov 14 '18 at 10:41