How does Rails migration enforce relationships?

At startup:

rake db:migrate

only files that are in db / migrate / right are processed?

Well, since application / models define relationships such as one-to-one, one-to-many, and many-to-many relationships, how does Rails apply such relationships? After migrating and viewing the generated database schema, I do not see foreign key constraints. So it baffles me how it all works.

+3
source share
3 answers

Quite simple.

This is due to the need to support multiple databases. Some, like sqlite, do not support foreign keys.

, SQL .

+6

, Rails SQL, . , , .

, , DDL, Rails , - , ( , , ). , ( , ). . Enterprise Rails Dan Chak; , .

+2
+1
source

Source: https://habr.com/ru/post/1702883/


All Articles