Implementation

Basic Flow

  1. Spin up the docker compose.
  2. Make changes to the service-go-user/storage/schema.sql file.
  3. Run AtlasGo migration:
sh scripts/atlas.sh
  1. Modify service-go-user/storage/queries.sql file.
  2. Run sqlc to generate the SQL code:
sh scripts/sqlc.sh

Change Database

By default, the project uses local PostgreSQL. To change the database, you need to modify the following files:

  • scripts/atlas.sh - change the database connection string and docker dev image.
  • service-go-user/storage/sqlc.yaml - change the database configuration.
  • service-go-user/storage/schema.sql - change the schema to match the new database.
  • service-go-user/storage/queries.sql - change the queries to match the new database.
  • service-go-user/storage/storage.go - change the database implementation by commenting/uncommenting the database provider.

Troubleshooting

  • When running Docker on WSL2, the SQLite file may not work. In that case, you probably need to exclude it from volumes:
    volumes:
      - ./go:/server
      - /server/storage/db/
    environment:
      DB_PROVIDER: sqlite
      SQLITE_FILE: /server/storage/db/local.db

Need help?

Visit our discord server to ask any questions, make suggestions and give feedback :).

https://discord.gg/EdSZbQbRyJ