Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> They are terrible in that removing obsolete columns requires a drop and recreation, which can become a nightmare when you build views on views.

This is a problem with the `alter` abilities, but in fact the lack of using `views` is a problem.

`views` is how you abstract the database. Also, combined with `instead of` triggers become amazing to simplify the other triggers.

Nothing more awesome than flatten your db so external code barely ever do joins themselves.

My trick to solve the problem of migrations is that I put all the `views, functions, etc` in their own section of a `sql` file:

-- DEPS --

-- VIEWS

-- FUNCTIONS

-- TRIGGERS

And then I have a special `DROP ALL VIEWS, CREATE ALL VIEWS` comment in my migrations that do that. It remove the problem greatly!



So an intrinsic problem with flattening the database is that a lot of applications actually do want to work on a tree of information (that's what the json query part is all about)

Dropping a view can work, but not when the system is under load (found that out the hard way.) I'm not saying its the worst possible situation, just a greater burden than you would expect going into it.

Can you elaborate on `instead of` triggers? How do you make use of those?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: