asked 117k views
4 votes
Who writes schema.rb and what is the golden rule?

asked
User Seydhe
by
7.7k points

1 Answer

0 votes

Final answer:

The schema.rb file is created by Ruby on Rails' migration system and reflects the current database structure.

It should not be edited manually—a golden rule in Rails development—to ensure consistency with the database.

Step-by-step explanation:

Ruby on Rails is a server-side web application framework written in Ruby under the MIT License. The file schema.rb is generated and maintained by the migration system of the ROR framework. It is essentially a snapshot of the current structure of the database and is updated anytime a migration is run that changes the database.

The process is automated, meaning developers do not write this file by hand. As migrations are applied (to add, remove, or change the structure of database tables), Rails updates the schema.rb to reflect the changes. The golden rule regarding schema.rb is that it should not be edited manually.

Instead, changes to the database should be made through migrations, which ensure that the schema file will be in sync with the database itself.

answered
User Yasei No Umi
by
8.5k points

No related questions found