Skip to content

Commit

Permalink
feat: datamodels etc (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
crlssn authored Oct 17, 2024
1 parent f65e170 commit 948f752
Show file tree
Hide file tree
Showing 44 changed files with 9,662 additions and 102 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@ run_migrations:
migrate -path db/migrations/ -database "postgresql://root:root@localhost:5433/postgres?sslmode=disable" -verbose down --all
migrate -path db/migrations/ -database "postgresql://root:root@localhost:5433/postgres?sslmode=disable" -verbose up
sqlboiler -c ./db/sqlboiler.toml psql

migrate:
$(MAKE) run_db
sleep 1
$(MAKE) run_migrations

protos:
buf generate
17 changes: 17 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: v2
managed:
enabled: true
override:
- file_option: go_package_prefix
value: github.com/crlssn/getstronger/go/pkg/pb
disable:
- module: buf.build/bufbuild/protovalidate
plugins:
- remote: buf.build/protocolbuffers/go
out: go/pkg/pb
opt: paths=source_relative
- remote: buf.build/connectrpc/go
out: go/pkg/pb
opt: paths=source_relative
inputs:
- directory: proto
6 changes: 6 additions & 0 deletions buf.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Generated by buf. DO NOT EDIT.
version: v2
deps:
- name: buf.build/bufbuild/protovalidate
commit: a6c49f84cc0f4e038680d390392e2ab0
digest: b5:e968392e88ff7915adcbd1635d670b45bff8836ec2415d81fc559ca5470a695dbdc30030bad8bc5764647c731079e9e7bba0023ea25c4e4a1672a7d2561d4a19
12 changes: 12 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# For details on buf.yaml configuration, visit https://buf.build/docs/configuration/v2/buf-yaml
version: v2
modules:
- path: proto
lint:
use:
- DEFAULT
breaking:
use:
- FILE
deps:
- buf.build/bufbuild/protovalidate
1 change: 1 addition & 0 deletions db/migrations/001_schema.up.sql
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
CREATE SCHEMA IF NOT EXISTS getstronger;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
57 changes: 57 additions & 0 deletions db/migrations/002_base.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
CREATE TABLE getstronger.auth
(
id UUID PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
email VARCHAR(255) NOT NULL UNIQUE,
password BYTEA NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT (NOW() AT TIME ZONE 'UTC')
);

CREATE TABLE getstronger.users
(
id UUID PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
auth_id UUID NOT NULL REFERENCES getstronger.auth (id),
name VARCHAR NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT (NOW() AT TIME ZONE 'UTC')
);

CREATE TABLE getstronger.routines
(
id UUID PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
user_id UUID NOT NULL REFERENCES getstronger.users (id),
title VARCHAR NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT (NOW() AT TIME ZONE 'UTC')
);

CREATE TABLE getstronger.exercises
(
id UUID PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
user_id UUID NOT NULL REFERENCES getstronger.users (id),
title VARCHAR NOT NULL,
sub_title VARCHAR,
created_at TIMESTAMP NOT NULL DEFAULT (NOW() AT TIME ZONE 'UTC')
);

CREATE TABLE getstronger.routine_exercises
(
routine_id UUID NOT NULL REFERENCES getstronger.routines (id),
exercise_id UUID NOT NULL REFERENCES getstronger.exercises (id),
PRIMARY KEY (routine_id, exercise_id)
);

CREATE TABLE getstronger.workouts
(
id UUID PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
user_id UUID NOT NULL REFERENCES getstronger.users (id),
date DATE NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT (NOW() AT TIME ZONE 'UTC')
);

CREATE TABLE getstronger.sets
(
id UUID PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
workout_id UUID NOT NULL REFERENCES getstronger.workouts (id),
exercise_id UUID NOT NULL REFERENCES getstronger.exercises (id),
weight DECIMAL(8, 2) NOT NULL,
reps INT NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT (NOW() AT TIME ZONE 'UTC')
);
7 changes: 0 additions & 7 deletions db/migrations/002_users.up.sql

This file was deleted.

2 changes: 1 addition & 1 deletion db/sqlboiler.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
output = "pkg/orm"
output = "go/pkg/orm"
pkgname = "orm"
wipe = true
no-tests = true
Expand Down
34 changes: 33 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,18 +1,50 @@
module getstronger
module github.com/crlssn/getstronger

go 1.23.0

require (
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240920164238-5a7b106cbb87.2
connectrpc.com/connect v1.16.2
github.com/bufbuild/protovalidate-go v0.7.2
github.com/friendsofgo/errors v0.9.2
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/google/uuid v1.6.0
github.com/jackc/pgx/v5 v5.6.0
github.com/stretchr/testify v1.9.0
github.com/volatiletech/null/v8 v8.1.2
github.com/volatiletech/sqlboiler/v4 v4.16.2
github.com/volatiletech/strmangle v0.0.6
go.uber.org/fx v1.22.2
go.uber.org/zap v1.26.0
golang.org/x/crypto v0.27.0
google.golang.org/grpc v1.67.1
google.golang.org/protobuf v1.35.1
)

require (
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/ericlagergren/decimal v0.0.0-20190420051523-6335edbaa640 // indirect
github.com/gofrs/uuid v4.2.0+incompatible // indirect
github.com/google/cel-go v0.21.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/puddle/v2 v2.2.1 // indirect
github.com/lib/pq v1.10.6 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/stoewer/go-strcase v1.3.0 // indirect
github.com/volatiletech/inflect v0.0.1 // indirect
github.com/volatiletech/randomize v0.0.1 // indirect
go.uber.org/dig v1.18.0 // indirect
go.uber.org/multierr v1.10.0 // indirect
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 948f752

Please sign in to comment.