Skip to content

Commit

Permalink
fix: 🐛fix problem in the migration for catalogswriteservice (#106)
Browse files Browse the repository at this point in the history
Fix #104
  • Loading branch information
mehdihadeli authored Jul 22, 2024
1 parent 3aa5aa6 commit 3b3af0b
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 21 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,21 @@ lint:
.PHONY: go-migrate
go-migrate:
@./scripts/go-migrate.sh -p ./internal/services/catalogwriteservice/db/migrations/go-migrate -c create -n create_product_table
@./scripts/go-migrate.sh -p ./internal/services/catalogwriteservice/db/migrations/go-migrate -c up -o postgres://postgres:postgres@localhost:5432/catalogs_service?sslmode=disable
@./scripts/go-migrate.sh -p ./internal/services/catalogwriteservice/db/migrations/go-migrate -c down -o postgres://postgres:postgres@localhost:5432/catalogs_service?sslmode=disable
@./scripts/go-migrate.sh -p ./internal/services/catalogwriteservice/db/migrations/go-migrate -c up -o postgres://postgres:postgres@localhost:5432/catalogs_write_service?sslmode=disable
@./scripts/go-migrate.sh -p ./internal/services/catalogwriteservice/db/migrations/go-migrate -c down -o postgres://postgres:postgres@localhost:5432/catalogs_write_service?sslmode=disable

# https://github.com/pressly/goose#usage
.PHONY: goose-migrate
goose-migrate:
@./scripts/goose-migrate.sh -p ./internal/services/catalogwriteservice/db/migrations/goose-migrate -c create -n create_product_table
@./scripts/goose-migrate.sh -p ./internal/services/catalogwriteservice/db/migrations/goose-migrate -c up -o "user=postgres password=postgres dbname=catalogs_service sslmode=disable"
@./scripts/goose-migrate.sh -p ./internal/services/catalogwriteservice/db/migrations/goose-migrate -c down -o "user=postgres password=postgres dbname=catalogs_service sslmode=disable"
@./scripts/goose-migrate.sh -p ./internal/services/catalogwriteservice/db/migrations/goose-migrate -c up -o "user=postgres password=postgres dbname=catalogs_write_service sslmode=disable"
@./scripts/goose-migrate.sh -p ./internal/services/catalogwriteservice/db/migrations/goose-migrate -c down -o "user=postgres password=postgres dbname=catalogs_write_service sslmode=disable"

# https://atlasgo.io/guides/orms/gorm
.PHONY: atlas
atlas:
@./scripts/atlas-migrate.sh -c gorm-sync -p "./internal/services/catalogwriteservice"
@./scripts/atlas-migrate.sh -c apply -p "./internal/services/catalogwriteservice" -o "postgres://postgres:postgres@localhost:5432/catalogs_service?sslmode=disable"
@./scripts/atlas-migrate.sh -c apply -p "./internal/services/catalogwriteservice" -o "postgres://postgres:postgres@localhost:5432/catalogs_write_service?sslmode=disable"

.PHONY: cycle-check
cycle-check:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"port": 27017,
"user": "admin",
"password": "admin",
"database": "catalogs_service",
"database": "catalogs_read_service",
"useAuth": true
},
"tracingOptions": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"port": 27017,
"user": "admin",
"password": "admin",
"database": "catalogs_service",
"database": "catalogs_read_service",
"useAuth": true
},
"tracingOptions": {
Expand Down
4 changes: 2 additions & 2 deletions internal/services/catalogwriteservice/atlas.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data "external_schema" "gorm" {

env "gorm" {
src = data.external_schema.gorm.url
dev = "postgres://postgres:postgres@localhost:5432/catalogs_service?sslmode=disable"
dev = "postgres://postgres:postgres@localhost:5432/catalogs_write_service?sslmode=disable"
migration {
dir = "file://db/migrations/atlas"
}
Expand All @@ -27,7 +27,7 @@ env "gorm" {

env "go-migrate" {
src = "file://db/migrations/go-migrate/schema.sql"
dev = "postgres://postgres:postgres@localhost:5432/catalogs_service?sslmode=disable"
dev = "postgres://postgres:postgres@localhost:5432/catalogs_write_service?sslmode=disable"
migration {
dir = "file://db/migrations/go-migrate"
format = golang-migrate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"port": 5432,
"user": "postgres",
"password": "postgres",
"dbName": "catalogs_service",
"dbName": "catalogs_write_service",
"sslMode": false
},
"rabbitmqOptions": {
Expand Down Expand Up @@ -105,7 +105,7 @@
"port": 5432,
"user": "postgres",
"password": "postgres",
"dbName": "catalogs_service",
"dbName": "catalogs_write_service",
"sslMode": false,
"migrationsDir": "db/migrations/goose-migrate",
"skipMigration": false
Expand Down
4 changes: 2 additions & 2 deletions internal/services/catalogwriteservice/config/config.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"port": 5432,
"user": "postgres",
"password": "postgres",
"dbName": "catalogs_service",
"dbName": "catalogs_write_service",
"sslMode": false
},
"rabbitmqOptions": {
Expand Down Expand Up @@ -81,7 +81,7 @@
"port": 5432,
"user": "postgres",
"password": "postgres",
"dbName": "catalogs_service",
"dbName": "catalogs_write_service",
"sslMode": false,
"migrationsDir": "db/migrations/goose-migrate",
"skipMigration": false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
-- Create "products" table
CREATE TABLE "public"."products" (
"product_id" text NOT NULL,
"id" text NOT NULL,
"name" text NULL,
"description" text NULL,
"price" numeric NULL,
"created_at" timestamptz NULL,
"updated_at" timestamptz NULL,
PRIMARY KEY ("product_id")
"deleted_at" timestamptz NULL,
PRIMARY KEY ("id")
);
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
CREATE TABLE IF NOT EXISTS products
(
product_id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
name text,
description text,
price numeric,
created_at timestamp with time zone,
updated_at timestamp with time zone
updated_at timestamp with time zone,
deleted_at timestamp with time zone
);
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
CREATE TABLE IF NOT EXISTS products
(
product_id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
name text,
description text,
price numeric,
created_at timestamp with time zone,
updated_at timestamp with time zone
updated_at timestamp with time zone,
deleted_at timestamp with time zone
);
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
-- +goose StatementBegin
CREATE TABLE IF NOT EXISTS products
(
product_id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
name text,
description text,
price numeric,
created_at timestamp with time zone,
updated_at timestamp with time zone
updated_at timestamp with time zone,
deleted_at timestamp with time zone
);
-- +goose StatementEnd

Expand Down

0 comments on commit 3b3af0b

Please sign in to comment.