Consider an example of one of the lines in the migration file; we can see that the table object is used in a chain of methods. The following line of the migration file sets up the state attributes in the location eloquent attribute in the locations
table:
$table->smallInteger('state_id')->unsigned()->index('state_id');
Often, it is necessary to create or import a list of finite items that usually remain constant, such as cities, states, countries, and similar items. Let's call these list tables or lookup tables. In these tables, the ID should usually be positive. These lists may grow, but they usually will not have any data that is deleted or updated. The smallInteger
type is used to keep the table small and also represent a value that belongs to a finite list, something that will not grow naturally. The next method, unsigned
, states that the limit will be 65535. This value should be enough to represent most of the states, provinces, or similar types of...