$ # Go 1.16+
$ go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@$TAG
migration in sqlc
sqlc does not perform database migrations for you. However, sqlc is able to differentiate between up and down migrations. sqlc ignores down migrations when parsing SQL files.
sqlc supports parsing migrations from the following tools:
dbmate
golang-migrate
goose
sql-migrate
tern
comparing database/sql package, gorm, sqlx, and sqlc
A transaction is a single logical unit of work that accesses and possibly modifies the contents of a database. Transactions access data using read and write operations.
In order to maintain consistency in a database, before and after the transaction, certain properties are followed. These are called ACID properties.
In a database, a deadlock is a situation in which two or more transactions are waiting for one another to give up locks. For example, Transaction A might hold a lock on some rows in the Accounts table and needs to update some rows in the Orders table to finish.
Mock Testing
Mock testing are using "White Box" testing techniques, used to testing every functional func in code.
https://github.com/golang/mock
Testing Method TDD / BDD / ATDD
TDD (test-driven development) approach with step:
First creating failing unit test.
Then start implementing unit test with MINIMAL code until all unit test condition are satisfied.
Last testing are passed, programmer refactor the design & making an improvement without changing the behavior from second step.
TDD in short explanation:
TDD steps :
Create unit test(Code) that including all process nedeed/writen.
Test unitTest (Failed result test).
Then repeating changes/implement code until all test are passed.
Done TDD cycle.
TDD Auidence are programmer-side since it's focuses more on code implementation of a feature.
TDD are more likely realted to "White Box" testing techniques.
BDD (Behavioral-Driven Development) are derived/similar from TDD but using the Given-When-Then approach is used for writing test cases. Some Given-When-Then example:
Given the user has entered valid login credentials
When a user clicks on the login button
Then display the successful validation message
BDD in short explanation:
BDD Steps are similar to TDD but "unit test" test are changed to Behavioral test that writen and describe in human language (ex:English).
BDD Auidence are more wide to other than programmer team, because main focus on Understanding Requirements.
BDD are more likely realted to "Black Box" testing techniques.
ATDD (Acceptance Test-Driven development) are similar with BDD focuses more on the behavior of the feature, whereas ATDD focuses on capturing the precise requirements.
ATDD in short explanation:
BDD are still very similar to BDD testing techniques but focusing in More detailed an precise requirements at development feature.