How should you build your database from source control?

后端 未结 11 1498
我寻月下人不归
我寻月下人不归 2020-11-30 15:48

There has been some discussion on the SO community wiki about whether database objects should be version controlled. However, I haven\'t seen much discussion about t

11条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-30 16:35

    I treat the SQL as source-code when possible

    If I can write it in standard's compliant SQL then it generally goes in a file in my source control. The file will define as much as possible such as SPs, Table CREATE statements.

    I also include dummy data for testing in source control:

    1. proj/sql/setup_db.sql
    2. proj/sql/dummy_data.sql
    3. proj/sql/mssql_specific.sql
    4. proj/sql/mysql_specific.sql

    And then I abstract out all my SQL queries so that I can build the entire project for MySQL, Oracle, MSSQL or anything else.

    Build and test automation uses these build-scripts as they are as important as the app source and tests everything from integrity through triggers, procedures and logging.

提交回复
热议问题