question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Schema: Add foreign key constraints

See original GitHub issue

should be in a format like

table.foreign('user_id').references('id').on('users')

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
josephmancusocommented, Mar 2, 2020

primary keys and foreign keys are never negative so it makes sense to make the columns unsigned.

1reaction
josephmancusocommented, Mar 2, 2020

For others following, with numbers you technically use the first bit to check if the number is negative or positive. When you make it unsigned you tell the database to use the left bit to make the number bigger. In this case you lose the ability to make the column have a negative value but you gain the ability to make the number larger (since now you have an extra bit to work with)

Read more comments on GitHub >

github_iconTop Results From Across the Web

SQL FOREIGN KEY Constraint - W3Schools
The FOREIGN KEY constraint prevents invalid data from being inserted into the foreign key column, because it has to be one of the...
Read more >
Foreign Key Constraint | CockroachDB Docs
The `FOREIGN KEY` constraint specifies a column can contain only values exactly matching existing values from the column it references.
Read more >
Create Foreign Key Relationships - SQL Server | Microsoft Learn
A FOREIGN KEY constraint specified at the column level can list only one reference column. This column must have the same data type...
Read more >
How to Create a Table with a Foreign Key in SQL
To create a new table containing a foreign key column that references another table, use the keyword FOREIGN KEY REFERENCES at the end...
Read more >
Database Schema Structure - DbSchema
A foreign key is a column or group of columns in a table that acts as a constraint. The foreign key enforces that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found