Skip to content

Commit

Permalink
add migrations & edit faq for Readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
RemezovaJulia committed May 2, 2023
1 parent dd5b521 commit 489eb4b
Show file tree
Hide file tree
Showing 11 changed files with 2,230 additions and 3 deletions.
12 changes: 12 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,15 @@ GO_BASE = $(CURDIR)
GO_BIN = $(GO_BASE)/cmd/$(PROJECT_NAME)
GO_FILES = $(wildcard $(GO_BIN)/*.go)

# DB.
DB_HOST= host string
DB_PORT= port string
DB_NAME= name string
DB_LOGIN= login string
DB_PASSWORD= pwd string

# Migrations
MIGRATIONS_FILES_PATH = FULL PATH for example ~/go/creativehair/internal/migrations
# Don't forget to hash special characters in the URL such as: '^', '!', '#': https://snipp.ru/handbk/url-code
DB_URL = for example postgres://user:password@localhost:5432/database_name?sslmode=disable

11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
include .env

go-build:
@echo "> Building binary to $(GO_BIN)"
ifeq ($(OS),Windows_NT)
@set GOPATH=%GOPATH% & set GO_BIN=$(GO_BIN) & go build -o $(GO_BIN) $(GO_FILES)
else
@GOPATH='$(GOPATH)' GO_BIN=$(GO_BIN) go build -o $(GO_BIN) $(GO_FILES)
endif
endif

all-migrate-up:
@echo "try all migrations up"
migrate -path $(MIGRATIONS_FILES_PATH) -database $(DB_URL) up

all-migrate-down:
@echo "try all migrations down"
migrate -path $(MIGRATIONS_FILES_PATH) -database $(DB_URL) down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@
### Как скомпилировать проект? ###
1. можно использовать утилиту make:
[windows](https://gnuwin32.sourceforge.net/downlinks/make.php) или [unix](https://ftp.gnu.org/gnu/make/)
далее нужно прейти в папку с проектом cd creativehair и выполнить команду: ``make go-build ``. Бинарный файл
далее нужно прейти в папку с проектом cd creativehair и выполнить команду: `make go-build`. Бинарный файл
будет находиться по пути: _creativehair/cmd/creativehair_;
2. используя компилятор Go, нужно перейти по пути _creativehair/cmd/creativehair_ затем выполнить команду: `` go build -o filename(.exe) ``
2. используя компилятор Go, нужно перейти по пути _creativehair/cmd/creativehair_
затем выполнить команду: `go build -o filename(.exe)`

### Как запустить проект? ###
1. установить [postgresql](https://www.postgresql.org/download/)
2. создать базу данных **creativehair**, выполнить команду: `createdb creativehair`
3. установить [golang-migrate](https://pkg.go.dev/github.com/golang-migrate/migrate)
нужно выполнить команду: `go install -u 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate`
4. 'накатить' миграции выполнить команду в корне проекта: `make all-migrate-up` или
`migrate -path ~/your_path_to_the_project/creativehair/internal/migrations -database postgres://user:password@localhost:5432/database_name?sslmode=disable up`
только не забудьте, то что строка: **postgres://user:password@localhost:5432/database_name?sslmode=disable** должна иметь
формат URL, то есть такие спец символы как:'^', '!', '#' должны быть хэшированные в формат url: https://snipp.ru/handbk/url-code
137 changes: 137 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,140 @@
module github.com/RemezovaJulia/creativehair

go 1.20

require (
github.com/jackc/pgx/v5 v5.3.1
github.com/joho/godotenv v1.5.1
)

require (
cloud.google.com/go v0.99.0 // indirect
cloud.google.com/go/spanner v1.28.0 // indirect
cloud.google.com/go/storage v1.10.0 // indirect
github.com/Azure/azure-pipeline-go v0.2.3 // indirect
github.com/Azure/azure-storage-blob-go v0.14.0 // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.16 // indirect
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
github.com/Azure/go-autorest/logger v0.2.1 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/ClickHouse/clickhouse-go v1.4.3 // indirect
github.com/apache/arrow/go/arrow v0.0.0-20211013220434-5962184e7a30 // indirect
github.com/aws/aws-sdk-go v1.17.7 // indirect
github.com/aws/aws-sdk-go-v2 v1.9.2 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.4.3 // indirect
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.5.4 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.3.0 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.3.2 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.7.2 // indirect
github.com/aws/aws-sdk-go-v2/service/s3 v1.16.1 // indirect
github.com/aws/smithy-go v1.8.0 // indirect
github.com/cenkalti/backoff/v4 v4.1.2 // indirect
github.com/census-instrumentation/opencensus-proto v0.3.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 // indirect
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4 // indirect
github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490 // indirect
github.com/cockroachdb/cockroach-go/v2 v2.1.1 // indirect
github.com/cznic/mathutil v0.0.0-20180504122225-ca4c9f2c1369 // indirect
github.com/denisenkom/go-mssqldb v0.10.0 // indirect
github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712 // indirect
github.com/envoyproxy/go-control-plane v0.10.1 // indirect
github.com/envoyproxy/protoc-gen-validate v0.6.2 // indirect
github.com/form3tech-oss/jwt-go v3.2.5+incompatible // indirect
github.com/gabriel-vasile/mimetype v1.4.0 // indirect
github.com/go-sql-driver/mysql v1.5.0 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/gocql/gocql v0.0.0-20210515062232-b7ef815b4556 // indirect
github.com/golang-jwt/jwt/v4 v4.1.0 // indirect
github.com/golang-migrate/migrate/v4 v4.15.2 // indirect
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/flatbuffers v2.0.0+incompatible // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/go-github/v39 v39.2.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/gax-go/v2 v2.1.1 // indirect
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.8.0 // indirect
github.com/jackc/pgerrcode v0.0.0-20201024163028-a0d42d470451 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgproto3/v2 v2.0.7 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgtype v1.6.2 // indirect
github.com/jackc/pgx/v4 v4.10.1 // indirect
github.com/jackc/puddle/v2 v2.2.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/k0kubun/pp v2.3.0+incompatible // indirect
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/ktrysmt/go-bitbucket v0.6.4 // indirect
github.com/lib/pq v1.10.0 // indirect
github.com/mattn/go-colorable v0.1.6 // indirect
github.com/mattn/go-ieproxy v0.0.1 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/mattn/go-sqlite3 v1.14.10 // indirect
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/mutecomm/go-sqlcipher/v4 v4.4.0 // indirect
github.com/nakagami/firebirdsql v0.0.0-20190310045651-3c02a58cfed8 // indirect
github.com/neo4j/neo4j-go-driver v1.8.1-0.20200803113522-b626aa943eba // indirect
github.com/pierrec/lz4/v4 v4.1.8 // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/snowflakedb/gosnowflake v1.6.3 // indirect
github.com/stretchr/testify v1.8.2 // indirect
github.com/xanzy/go-gitlab v0.15.0 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.0.2 // indirect
github.com/xdg-go/stringprep v1.0.2 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
gitlab.com/nyarla/go-crypt v0.0.0-20160106005555-d9a5dc2b789b // indirect
go.mongodb.org/mongo-driver v1.7.0 // indirect
go.opencensus.io v0.23.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
golang.org/x/crypto v0.8.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/tools v0.6.0 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/api v0.62.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220314164441-57ef72a4c106 // indirect
google.golang.org/grpc v1.45.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
modernc.org/b v1.0.0 // indirect
modernc.org/cc/v3 v3.32.4 // indirect
modernc.org/ccgo/v3 v3.9.2 // indirect
modernc.org/db v1.0.0 // indirect
modernc.org/file v1.0.0 // indirect
modernc.org/fileutil v1.0.0 // indirect
modernc.org/golex v1.0.0 // indirect
modernc.org/internal v1.0.0 // indirect
modernc.org/libc v1.9.5 // indirect
modernc.org/lldb v1.0.0 // indirect
modernc.org/mathutil v1.2.2 // indirect
modernc.org/memory v1.0.4 // indirect
modernc.org/opt v0.1.1 // indirect
modernc.org/ql v1.0.0 // indirect
modernc.org/sortutil v1.1.0 // indirect
modernc.org/sqlite v1.10.6 // indirect
modernc.org/strutil v1.1.0 // indirect
modernc.org/token v1.0.0 // indirect
modernc.org/zappy v1.0.0 // indirect
)
Loading

0 comments on commit 489eb4b

Please sign in to comment.