diff --git a/sdk/Makefile b/sdk/Makefile new file mode 100644 index 000000000..af2d90a49 --- /dev/null +++ b/sdk/Makefile @@ -0,0 +1,24 @@ +.PHONY: pull-migrator-image new-migration + +pull-migrator-image: + docker pull --platform linux/amd64 arigaio/atlas:latest-alpine + +new-migration: pull-migrator-image + docker run \ + --platform linux/amd64 \ + -v ./component/store/remote/postgresql/sqlc/migrations:/migrations \ + --rm \ + -it arigaio/atlas:latest-alpine \ + migrate \ + new $(migration_name) \ + --dir "file://migrations" + +update-migrations-sum: pull-migrator-image + docker run \ + --platform linux/amd64 \ + -v ./component/store/remote/postgresql/sqlc/migrations:/migrations \ + --rm \ + -it arigaio/atlas:latest-alpine \ + migrate \ + hash \ + --dir "file://migrations" diff --git a/sdk/README.md b/sdk/README.md index 03e4cfe98..5a073e315 100644 --- a/sdk/README.md +++ b/sdk/README.md @@ -288,3 +288,33 @@ if err := component.RunReporter( log.Fatalf("unexpected run error: %v", err) } ``` + +### Contributing + +#### Database Schemas + +They are generated using [sqlc](https://sqlc.dev/) from real SQL schemas and queries. + +##### Generation + +You can generate types mapping schemas and queries by leveraging the `go:generate` entries in `tools.go`. + +#### Migrations + +Components require a common database/tables setup to function properly. + +This is achieved with migrations. + +##### SQLite + +TBD. + +##### Postgresql + +Postgresql migrations live in `./component/store/remote/postgresql/sqlc/migrations`. + +In order to create a new migration, you can follow these steps: + +* run `$ make new-migration migration_name=my_migration` +* edit the migration +* run `$ update-migrations-sum` to update `atlas.sum`