Skip to content

Commit

Permalink
Adding SQLite migration targets and documenting them.
Browse files Browse the repository at this point in the history
  • Loading branch information
andream16 committed Dec 16, 2024
1 parent 4043283 commit 359b3d9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
30 changes: 23 additions & 7 deletions sdk/Makefile
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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 \
Expand All @@ -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"
12 changes: 9 additions & 3 deletions sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,20 @@ 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

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`
* 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`

0 comments on commit 359b3d9

Please sign in to comment.