0

I'm having this doubt much time ago, and I have always end up leaving SQL scripts outside the version control (I always try to encapsulate code in database as much as I can).

But I really find interesting to have a version control of both app code and database scripts; having also snapshots of the database situation (just DDL and stored procedures) in each commit would be pretty useful.

Would you have app code and SQL scripts in different branches (and having to cherry-pick, merge, whatever, so many times)?

Do you even think it's a good idea?

1
  • Use a schema migrations library. Store the migrations however your library suggests; probably in a directory in the same branch as your code. Commented Aug 19, 2015 at 16:00

1 Answer 1

1

Usually, having database-related files that e.g. construct the database schema or provide migration routines inside the application repository is perfectly fine. After all, your application needs the database, and the repository should provide everything that is necessary to set everything up. So having scripts there that construct the database, and even import some base data that is required is perfectly fine.

It would even be good to include scripts that provide test data in order to run your tests (often referred to as fixtures).

The only thing that I would avoid is having production data inside the repository. But for everything else that is required for the application to run: Just include it in the repository.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.