Yesod app on keter with read-only access to DB

93 views Asked by At

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?

1

There are 1 answers

3
Sibi On BEST ANSWER

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.