For a work project I had to update some values (a lock field for example) w/o updating these magic columns.After doing some research on the interwebs there are several solutions: This was the first and easiest one.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.I found this SO article: Seems like maybe the default behavior changed, and if I recreated my development database from migrations, then the file wants to change by having "not null" removed. So what's happened is that maybe the behavior t.timestamps changed, and I rebuilt the DB from the migrations.I suppose it might be worth downloading my production DB and running annotate against that and seeing if the "not null" changes in the model annotations.The regular update_attribute method in Base is replaced with this when the validations module is mixed in, which it is by default.Also note that Validation Use update_attribute to skip validations.
Also writing the code in one file may lead to the mess. This post tells about these disadvantages and how to get rid of the issue with the and don’t touch the old migrations.It will be broken because at those moment we won’t have without the namespace. To be honest this solution doesn’t have disadvantages except a few. And as a result requires more time to write the code.Besides of this Rails developers don’t prefer to write raw SQL because if you want to migrate through Postgre SQL to My SQL for example you may have to fix much raw SQL code.Check out official documentation to get examples how to write raw SQL in migrations.