Skip to content

Commit

Permalink
CRUDs v0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pieceowater committed Dec 23, 2024
1 parent e3c746e commit b680146
Show file tree
Hide file tree
Showing 21 changed files with 389 additions and 55 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
APP_NAME = lotof.sample.svc
APP_NAME = lotof.atrace.msvc.tracker
BUILD_DIR = bin
MAIN_FILE = cmd/server/main.go
PG_MIGRATION_DIR = cmd/server/db/pg/migrations
PROTOC = protoc
PROTOC_GEN_GO = $(GOPATH)/bin/protoc-gen-go
PROTOC_GEN_GRPC_GO = $(GOPATH)/bin/protoc-gen-go-grpc
PROTOC_PKG = github.com/pieceowater-dev/lotof.sample.proto
PROTOC_PKG = github.com/pieceowater-dev/lotof.atrace.proto
PROTOC_PKG_PATH = $(shell go list -m -f '{{.Dir}}' $(PROTOC_PKG))
PROTOC_DIR = protos
PROTOC_OUT_DIR = ./internal/core/grpc/generated
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# lotof.sample.svc
# lotof.atrace.msvc.tracker

Welcome to the **Lotof Sample Service** project! This project provides a structure to generate, build, and run a grpc microservice using [Docker](https://www.docker.com/) for containerization. Below you'll find a comprehensive guide to get started with this project.
Welcome to the **Lotof ATrace Tracker Service** project! This project provides a structure to generate, build, and run a grpc microservice using [Docker](https://www.docker.com/) for containerization. Below you'll find a comprehensive guide to get started with this project.

## Prerequisites

Expand Down
13 changes: 0 additions & 13 deletions cmd/server/db/pg/migrations/20241123162350.sql

This file was deleted.

2 changes: 0 additions & 2 deletions cmd/server/db/pg/migrations/20241130181357.sql

This file was deleted.

79 changes: 79 additions & 0 deletions cmd/server/db/pg/migrations/20241223103039.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
-- Create "posts" table
CREATE TABLE "public"."posts" (
"id" bigserial NOT NULL,
"created_at" timestamptz NULL,
"updated_at" timestamptz NULL,
"deleted_at" timestamptz NULL,
"title" text NOT NULL,
"description" text NULL,
"phrase" text NULL,
PRIMARY KEY ("id")
);
-- Create index "idx_posts_deleted_at" to table: "posts"
CREATE INDEX "idx_posts_deleted_at" ON "public"."posts" ("deleted_at");
-- Create "post_locations" table
CREATE TABLE "public"."post_locations" (
"id" bigserial NOT NULL,
"created_at" timestamptz NULL,
"updated_at" timestamptz NULL,
"deleted_at" timestamptz NULL,
"post_id" bigint NOT NULL,
"comment" text NULL,
"country" text NULL,
"city" text NULL,
"address" text NULL,
"latitude" numeric NULL,
"longitude" numeric NULL,
PRIMARY KEY ("id"),
CONSTRAINT "fk_posts_location" FOREIGN KEY ("post_id") REFERENCES "public"."posts" ("id") ON UPDATE NO ACTION ON DELETE CASCADE
);
-- Create index "idx_post_locations_deleted_at" to table: "post_locations"
CREATE INDEX "idx_post_locations_deleted_at" ON "public"."post_locations" ("deleted_at");
-- Create index "idx_post_locations_post_id" to table: "post_locations"
CREATE UNIQUE INDEX "idx_post_locations_post_id" ON "public"."post_locations" ("post_id");
-- Create "records" table
CREATE TABLE "public"."records" (
"id" bigserial NOT NULL,
"created_at" timestamptz NULL,
"updated_at" timestamptz NULL,
"deleted_at" timestamptz NULL,
"post_id" bigint NOT NULL,
"user_id" text NOT NULL,
"timestamp" timestamptz NULL,
"method" bigint NULL DEFAULT 0,
PRIMARY KEY ("id"),
CONSTRAINT "fk_posts_records" FOREIGN KEY ("post_id") REFERENCES "public"."posts" ("id") ON UPDATE NO ACTION ON DELETE CASCADE
);
-- Create index "idx_records_deleted_at" to table: "records"
CREATE INDEX "idx_records_deleted_at" ON "public"."records" ("deleted_at");
-- Create index "idx_records_post_id" to table: "records"
CREATE INDEX "idx_records_post_id" ON "public"."records" ("post_id");
-- Create "routes" table
CREATE TABLE "public"."routes" (
"id" bigserial NOT NULL,
"created_at" timestamptz NULL,
"updated_at" timestamptz NULL,
"deleted_at" timestamptz NULL,
"title" text NOT NULL,
PRIMARY KEY ("id")
);
-- Create index "idx_routes_deleted_at" to table: "routes"
CREATE INDEX "idx_routes_deleted_at" ON "public"."routes" ("deleted_at");
-- Create "route_milestones" table
CREATE TABLE "public"."route_milestones" (
"id" bigserial NOT NULL,
"created_at" timestamptz NULL,
"updated_at" timestamptz NULL,
"deleted_at" timestamptz NULL,
"route_id" bigint NOT NULL,
"post_id" bigint NOT NULL,
"priority" bigint NOT NULL,
PRIMARY KEY ("id"),
CONSTRAINT "fk_routes_milestones" FOREIGN KEY ("route_id") REFERENCES "public"."routes" ("id") ON UPDATE NO ACTION ON DELETE CASCADE
);
-- Create index "idx_route_milestones_deleted_at" to table: "route_milestones"
CREATE INDEX "idx_route_milestones_deleted_at" ON "public"."route_milestones" ("deleted_at");
-- Create index "idx_route_milestones_post_id" to table: "route_milestones"
CREATE INDEX "idx_route_milestones_post_id" ON "public"."route_milestones" ("post_id");
-- Create index "idx_route_milestones_route_id" to table: "route_milestones"
CREATE INDEX "idx_route_milestones_route_id" ON "public"."route_milestones" ("route_id");
5 changes: 2 additions & 3 deletions cmd/server/db/pg/migrations/atlas.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
h1:wGR9nmeFxEUmTtaAr2Oi4a1GtuuJC9kt2HgOwhfezsg=
20241123162350.sql h1:ucccYXCMMwRyWWgS7e7u0u4f6HJao1f5A99pU8b8Wmg=
20241130181357.sql h1:pyiMsKk28BUQ+6tMFvhi9joJjlHHxLdoHAy/td4ULf0=
h1:femykkwctNFDgBmoEKDaWHh9xRDLkkhsByercBborLI=
20241223103039.sql h1:rWABiWO7Q0v5wLNrn+RO0wKuW9i6sKmghutB98U76sI=
2 changes: 0 additions & 2 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"app/internal/core/cfg"
"app/internal/pkg"
"github.com/gin-gonic/gin"
gossiper "github.com/pieceowater-dev/lotof.lib.gossiper/v2"
"google.golang.org/grpc"
)
Expand All @@ -14,7 +13,6 @@ func main() {

serverManager := gossiper.NewServerManager()
serverManager.AddServer(gossiper.NewGRPCServ(appCfg.GrpcPort, grpc.NewServer(), appRouter.InitGRPC))
serverManager.AddServer(gossiper.NewRESTServ(appCfg.RestPort, gin.Default(), appRouter.InitREST))

serverManager.StartAll()
defer serverManager.StopAll()
Expand Down
26 changes: 21 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,72 @@ go 1.23.0

require (
ariga.io/atlas-provider-gorm v0.5.0
github.com/gin-gonic/gin v1.10.0
github.com/joho/godotenv v1.5.1
github.com/pieceowater-dev/lotof.lib.gossiper/v2 v2.0.3
github.com/pieceowater-dev/lotof.sample.proto v0.0.12
google.golang.org/grpc v1.68.0
github.com/pieceowater-dev/lotof.atrace.proto v0.0.4
github.com/pieceowater-dev/lotof.lib.gossiper/v2 v2.0.9
google.golang.org/grpc v1.69.2
google.golang.org/protobuf v1.35.2
gorm.io/gorm v1.25.12
)

require (
ariga.io/atlas-go-sdk v0.6.4 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/ClickHouse/ch-go v0.61.5 // indirect
github.com/ClickHouse/clickhouse-go/v2 v2.23.2 // indirect
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/bytedance/sonic v1.11.6 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/gin-gonic/gin v1.10.0 // indirect
github.com/go-faster/city v1.0.1 // indirect
github.com/go-faster/errors v0.7.1 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.20.0 // indirect
github.com/go-sql-driver/mysql v1.8.1 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
github.com/golang-sql/sqlexp v0.1.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgx/v5 v5.7.1 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.8 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-sqlite3 v1.14.24 // indirect
github.com/microsoft/go-mssqldb v1.7.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/paulmach/orb v0.11.1 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pierrec/lz4/v4 v4.1.21 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
go.opentelemetry.io/otel v1.31.0 // indirect
go.opentelemetry.io/otel/trace v1.31.0 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.29.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/driver/clickhouse v0.6.1 // indirect
gorm.io/driver/mysql v1.5.7 // indirect
gorm.io/driver/postgres v1.5.9 // indirect
gorm.io/driver/sqlite v1.5.6 // indirect
Expand Down
Loading

0 comments on commit b680146

Please sign in to comment.