From 359b3d931f81e75f24197be5732588b528bb080e Mon Sep 17 00:00:00 2001 From: andream16 Date: Mon, 9 Dec 2024 15:41:47 +0000 Subject: [PATCH] Adding SQLite migration targets and documenting them. --- sdk/Makefile | 30 +++++++++++++++++++++++------- sdk/README.md | 12 +++++++++--- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/sdk/Makefile b/sdk/Makefile index f98d67588..cbfad5ad3 100644 --- a/sdk/Makefile +++ b/sdk/Makefile @@ -1,13 +1,9 @@ -.PHONY: pull-migrator-image new-migration +.PHONY: pull-migrator-image new-postgres-migration update-postgres-migrations-sum new-sqlite-migration update-sqlite-migrations-sum pull-migrator-image: docker pull --platform linux/amd64 arigaio/atlas:latest-alpine -new-migration: pull-migrator-image - @if [ -z "$(migration_name)" ]; then \ - echo "Error: migration_name is not defined"; \ - exit 1; \ - fi +new-postgres-migration: pull-migrator-image docker run \ --platform linux/amd64 \ -v ./component/store/remote/postgresql/sqlc/migrations:/migrations \ @@ -17,7 +13,7 @@ new-migration: pull-migrator-image new $(migration_name) \ --dir "file://migrations" -update-migrations-sum: pull-migrator-image +update-postgres-migrations-sum: pull-migrator-image docker run \ --platform linux/amd64 \ -v ./component/store/remote/postgresql/sqlc/migrations:/migrations \ @@ -26,3 +22,23 @@ update-migrations-sum: pull-migrator-image migrate \ hash \ --dir "file://migrations" + +new-sqlite-migration: pull-migrator-image + docker run \ + --platform linux/amd64 \ + -v ./component/store/local/sqlite/sqlc/migrations:/migrations \ + --rm \ + -it arigaio/atlas:latest-alpine \ + migrate \ + new $(migration_name) \ + --dir "file://migrations" + +update-sqlite-migrations-sum: pull-migrator-image + docker run \ + --platform linux/amd64 \ + -v ./component/store/local/sqlite/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 9f164d99e..f67b047ca 100644 --- a/sdk/README.md +++ b/sdk/README.md @@ -329,7 +329,13 @@ This is achieved with migrations. ##### SQLite -TBD. +Postgresql migrations live in `./component/store/local/sqlc/sqlc/migrations`. + +In order to create a new migration, you can follow these steps: + +* run `$ make new-sqlite-migration migration_name=my_migration` +* edit the migration +* run `$ update-sqlite-migrations-sum` to update `atlas.sum` ##### Postgresql @@ -337,6 +343,6 @@ Postgresql migrations live in `./component/store/remote/postgresql/sqlc/migratio In order to create a new migration, you can follow these steps: -* run `$ make new-migration migration_name=my_migration` +* run `$ make new-postgres-migration migration_name=my_migration` * edit the migration -* run `$ update-migrations-sum` to update `atlas.sum` +* run `$ update-postgres-migrations-sum` to update `atlas.sum`