diff --git a/Makefile b/Makefile index 1fc1b99a..9793d259 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/internal/services/catalogreadservice/config/config.development.json b/internal/services/catalogreadservice/config/config.development.json index 6b988ae3..4f4687b5 100644 --- a/internal/services/catalogreadservice/config/config.development.json +++ b/internal/services/catalogreadservice/config/config.development.json @@ -52,7 +52,7 @@ "port": 27017, "user": "admin", "password": "admin", - "database": "catalogs_service", + "database": "catalogs_read_service", "useAuth": true }, "tracingOptions": { diff --git a/internal/services/catalogreadservice/config/config.test.json b/internal/services/catalogreadservice/config/config.test.json index 5038d505..958b38f5 100644 --- a/internal/services/catalogreadservice/config/config.test.json +++ b/internal/services/catalogreadservice/config/config.test.json @@ -50,7 +50,7 @@ "port": 27017, "user": "admin", "password": "admin", - "database": "catalogs_service", + "database": "catalogs_read_service", "useAuth": true }, "tracingOptions": { diff --git a/internal/services/catalogwriteservice/atlas.hcl b/internal/services/catalogwriteservice/atlas.hcl index c2befff1..dedf1158 100644 --- a/internal/services/catalogwriteservice/atlas.hcl +++ b/internal/services/catalogwriteservice/atlas.hcl @@ -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" } @@ -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 diff --git a/internal/services/catalogwriteservice/config/config.development.json b/internal/services/catalogwriteservice/config/config.development.json index bcdc2233..1efca60c 100644 --- a/internal/services/catalogwriteservice/config/config.development.json +++ b/internal/services/catalogwriteservice/config/config.development.json @@ -34,7 +34,7 @@ "port": 5432, "user": "postgres", "password": "postgres", - "dbName": "catalogs_service", + "dbName": "catalogs_write_service", "sslMode": false }, "rabbitmqOptions": { @@ -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 diff --git a/internal/services/catalogwriteservice/config/config.test.json b/internal/services/catalogwriteservice/config/config.test.json index 8de7c47b..690b8d4e 100644 --- a/internal/services/catalogwriteservice/config/config.test.json +++ b/internal/services/catalogwriteservice/config/config.test.json @@ -34,7 +34,7 @@ "port": 5432, "user": "postgres", "password": "postgres", - "dbName": "catalogs_service", + "dbName": "catalogs_write_service", "sslMode": false }, "rabbitmqOptions": { @@ -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 diff --git a/internal/services/catalogwriteservice/db/migrations/atlas/20230919170700.sql b/internal/services/catalogwriteservice/db/migrations/atlas/20230919170700.sql index 09475fba..3f5f8bbe 100644 --- a/internal/services/catalogwriteservice/db/migrations/atlas/20230919170700.sql +++ b/internal/services/catalogwriteservice/db/migrations/atlas/20230919170700.sql @@ -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") ); diff --git a/internal/services/catalogwriteservice/db/migrations/atlas/goose/00002_create_products_table.sql b/internal/services/catalogwriteservice/db/migrations/atlas/goose/00002_create_products_table.sql index 3cd15971..3d9a03a3 100644 --- a/internal/services/catalogwriteservice/db/migrations/atlas/goose/00002_create_products_table.sql +++ b/internal/services/catalogwriteservice/db/migrations/atlas/goose/00002_create_products_table.sql @@ -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 ); diff --git a/internal/services/catalogwriteservice/db/migrations/go-migrate/000002_create_products_table.up.sql b/internal/services/catalogwriteservice/db/migrations/go-migrate/000002_create_products_table.up.sql index 3cd15971..3d9a03a3 100644 --- a/internal/services/catalogwriteservice/db/migrations/go-migrate/000002_create_products_table.up.sql +++ b/internal/services/catalogwriteservice/db/migrations/go-migrate/000002_create_products_table.up.sql @@ -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 ); diff --git a/internal/services/catalogwriteservice/db/migrations/goose-migrate/00002_create_products_table.sql b/internal/services/catalogwriteservice/db/migrations/goose-migrate/00002_create_products_table.sql index f7ed379b..26ff8974 100644 --- a/internal/services/catalogwriteservice/db/migrations/goose-migrate/00002_create_products_table.sql +++ b/internal/services/catalogwriteservice/db/migrations/goose-migrate/00002_create_products_table.sql @@ -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