Jesse Schutt
← All writing

Tagged

Database

Renaming a Column with a Foreign Key in Laravel

This database originally used "customer_id" as the column name for the owner of each row, however the actual model being referenced was a "User". Here's how I changed the name of the column (which happened to have a foreign key on it) via Laravel migration:

For When Things Get Gnarly in Eloquent

Jonathan Reinink has written some excellent content around Eloquent and this article is one that I reference frequently. Jonathan walks us through handling sticky situations when we need to get a single record back from a relationship without causing N+1 issues.

Dynamic Relationships in Laravel using Subqueries

Importing a PG Dump from the Command Line

Similar to the time formats I wrote about here, I can not seem to remember the syntax for importing a PostgreSQL dump file into a database from the command line! Fortunately the…