Database controlled source again!

We use MS SQL Server and C #. Our database is under control, and I will tell you some details of our implementation. We performed two operations:

  • Export database to text files. Database schema files: tables.sql relationships.sql views.sql ... and table contents files: Data / table 1.txt Data / table2.txt ... It is easy to view database changes using source control logs, since all of these files are in text format. Implementation is based on classes from the Microsoft.SqlServer.Management.Smo namespace.

  • Import the database from these text files. The implementation is quite simple - just execute sql commands from * .sql files, and then do a bunch of inserts.

So, we have two bat files: create-test-databse.bat and export-test-database.bat. When a developer needs a new test database, he simply runs the bat file and waits a minute. Each functional test that needs a database creates a new database, uses it, and then kills. But I have to say that this is not a very fast operation. :(

So what tools do you use to put your database under source control? I mean, how do you implement the operations "create a test database" and "export a test database", for example?

+3
source share
3 answers

, . -, . , Visual Studio Team Edition ( , TDD , )

-, . , , . . DBFit. XtUnit, . , , , SetUp, .

+2

Visual Studio . .

+1

I am using VSTS for DB Pros. You point it to your SQL server, and it analyzes your database and creates separate files for you. You can even generate test data for you. The next release will include third-party support (think Oracle, MySQL, DB2).

A truly remarkable feature here is the test. We found that parts of our database were completely broken (they were rudimentary and not used by the code anymore). This basically allows you to deploy your database on demand.

0
source

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


All Articles