![]() And the down script is run if we want to revert the change made by the up script. The up script is run to make a forward change to the schema. Well, basically it’s a best practice when writing database migration. They both have version 1 in the file name’s prefix, but their suffixes are different: 1 file is up and the other is down. And finally the name of the migration, which is init_schema in this case.Īs you can see, 2 migration files have been generated for us. We use the -seq flag to generate a sequential version number for the migration file. 3 How to write & run database migration in Golang 4 Generate CRUD Golang code from SQL | Compare db/sql, gorm, sqlx, sqlc 5 Write Go unit tests for db CRUD with random data 6 A clean way to implement database transaction in Golang 7 DB transaction lock & How to handle deadlock 8 How to avoid deadlock in DB transaction? Queries order matter! 9 Deeply understand Isolation levels and Read phenomena in MySQL & PostgreSQL 10 How to setup Github Actions for Go + Postgres to run automated tests 11 Implement RESTful HTTP API in Go using Gin 12 Load config from file & environment variables in Golang with Viper 13 Mock DB for testing HTTP API in Go and achieve 100% coverage 14 Implement transfer money API with a custom params validator in Go 15 Add users table with unique & foreign key constraints in PostgreSQL 16 How to handle DB errors in Golang correctly 17 How to securely store passwords? 18 How to write stronger unit tests with a custom go-mock matcher 19 Why PASETO is better than JWT for token-based authentication? 20 How to create and verify JWT & PASETO token in Golang 21 Implement login user API that returns PASETO or JWT access token in GoĮnter fullscreen mode Exit fullscreen mode 1 Design DB schema and generate SQL code with dbdiagram.io 2 Install & use Docker + Postgres + TablePlus to create DB schema.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |