Should I store db/schema in my git?

#database, #dev, #git, #ruby

tl;dr

No.

Why should I store in git a file that is generated based on other files (db/migrate)?

Why should I store in git a file that changes based on one’s machine?


Let’s get some features of a db/schema.rb:

  1. It is generated based on other files, i. e., db/migrate;
  2. It is generated depending on your database, in production, it can generate one different file in the development machine of each developer.

Why do developers not store binary file? Let’s forget for one moment that it is not a text file.

Developers do not store binary files in git because it is a file generated based on other files, if you have the same source ideally it will generate the same binary over and over.

Why should we store a file that is generated based on other files when we have the source?

Answer that question to choose to store or not a db/schema.rb.

For the second question let’s use the same analogy: binary 😂.

Ok, let’s forget for one moment that a binary is generated based on other files.

But, the binary depends on your architecture, if you have a 32 bits machine it will of one way and if you have a 64 bits machine it will be of another one.

Why should we store a file that changes based on one’s machine?

I don’t store db/schema.rb in git, and always that someone asks me I say no.

If you store db/schema.rb comment below 😉.