Playlist ▶️: • Go Programming
In this video, we'll look at the goose package for database migrations in Go. We'll see how to connect to a PostgreSQL database using Docker, and how to manage the database schema using migrations.
☕️ 𝗕𝘂𝘆 𝗺𝗲 𝗮 𝗰𝗼𝗳𝗳𝗲𝗲:
To support the channel and encourage new videos, please consider buying me a coffee here:
ko-fi.com/bugbytes
📌 𝗖𝗵𝗮𝗽𝘁𝗲𝗿𝘀:
00:00 Intro
01:04 Installing Goose
03:03 Creating migrations with goose create command
05:52 Setting up Postgres Docker container
07:27 Applying migrations with goose up command
10:32 Reverting migrations with goose down command
11:42 Adding more complex migration with Foreign Keys
15:06 Passing DBSTRING and DRIVER as environment variables
17:56 Creating test data in migration
19:01 Querying data using Go sql module
𝗦𝗼𝗰𝗶𝗮𝗹 𝗠𝗲𝗱𝗶𝗮:
📖 Blog: bugbytes.io/posts/
👾 Github: github.com/bugbytes-io
🐦 Twitter: twitter.com/bugbytesio
📚 𝗙𝘂𝗿𝘁𝗵𝗲𝗿 𝗿𝗲𝗮𝗱𝗶𝗻𝗴 𝗮𝗻𝗱 𝗶𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻:
Goose: github.com/pressly/goose
Docker Hub Postgres: hub.docker.com/_/postgres
VSCode PostgreSQL extension: marketplace.visualstudio.com/items?itemName=ckolkm…
pq driver: github.com/lib/pq
Go database/sql package: pkg.go.dev/database/sql
#golang #webdevelopment #database #sql
コメント