From 91916779e6eef01c87659a576d64606e5048944d Mon Sep 17 00:00:00 2001 From: Wittano Bonarotti Date: Mon, 29 Jul 2024 22:12:46 +0200 Subject: [PATCH] feat(sql): created and set up sqlc actions for basic jokes data --- .gitignore | 1 + Makefile | 14 ++- db/migrations/000001_create_tables.up.sql | 62 ----------- ...e_tables.down.sql => 000001_init.down.sql} | 5 +- db/migrations/000001_init.up.sql | 103 ++++++++++++++++++ db/sql/jokes.sql | 33 ++++++ go.mod | 3 + go.sum | 32 ++++-- go.work.sum | 5 +- shell.nix | 2 + sqlc.yaml | 12 ++ 11 files changed, 188 insertions(+), 84 deletions(-) delete mode 100644 db/migrations/000001_create_tables.up.sql rename db/migrations/{000001_create_tables.down.sql => 000001_init.down.sql} (54%) create mode 100644 db/migrations/000001_init.up.sql create mode 100644 db/sql/jokes.sql create mode 100644 sqlc.yaml diff --git a/.gitignore b/.gitignore index 190585d..6ee430b 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,4 @@ api # Sqlit *.sqlite +sql diff --git a/Makefile b/Makefile index 250a53c..c6c8357 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,6 @@ DEST_DIR = /opt/komputer ARCH = $(shell uname -m) OUTPUT_DIR=./build PROTOBUF_API_DEST=./api -DB_PATH ?= db.sqlite ifeq ($(ARCH), x86_64) GOARCH="amd64" @@ -12,14 +11,14 @@ endif .PHONY: test clean -bot-dev: proto +bot-dev: proto gen-sql CGO_ENABLED=1 GOOS=linux GOARCH=$(GOARCH) go build -tags dev -o $(OUTPUT_DIR)/komputer ./cmd/komputer/main.go -bot-prod: protobuf +bot-prod: protobuf gen-sql CGO_ENABLED=1 GOOS=linux GOARCH=$(GOARCH) go build -o $(OUTPUT_DIR)/komputer ./cmd/komputer/main.go -sever: protobuf +sever: protobuf gen-sql go build -o $(OUTPUT_DIR)/server ./cmd/server/main.go tui: protobuf @@ -31,7 +30,7 @@ protobuf: test: test-bot test-server -test-bot: protobuf +test-bot: protobuf gen-sql CGO_CFLAGS="-w" go test ./bot/...; test-server: protobuf @@ -39,12 +38,17 @@ test-server: protobuf all: bot-prod sever tui test +DB_PATH=db.sqlite + update-database: ifeq (,$(wildcard $(DB_PATH))) touch $(DB_PATH) endif migrate -database sqlite3://$(DB_PATH) -path db/migrations up +gen-sql: + sqlc -f sqlc.yaml generate + clean: cleanProto ifneq ("$(wildcard $(OUTPUT_DIR))", "") rm -r $(OUTPUT_DIR) diff --git a/db/migrations/000001_create_tables.up.sql b/db/migrations/000001_create_tables.up.sql deleted file mode 100644 index 93c2f79..0000000 --- a/db/migrations/000001_create_tables.up.sql +++ /dev/null @@ -1,62 +0,0 @@ -create table jokes -( - id integer primary key autoincrement, - question text, - answer text not null, - type text not null, - category text not null, - userID text, - guildID text -); - -create index jokes_index on jokes (id, guildID); - -create table jokes_audit -( - id primary key, - status text default 'CREATED', - joke_id integer not null, - question text, - answer text not null, - type text not null, - category text not null, - userID text, - guildID text -); - -create trigger joke_add_event_trigger - after insert - on jokes -begin - insert - into jokes_audit(joke_id, question, answer, type, category, userID, guildID) - values (new.id, new.question, new.answer, new.type, new.category, new.userID, new.guildID); -end; - -create trigger joke_update_event_trigger - after update - on jokes -begin - insert - into jokes_audit(status, joke_id, question, answer, type, category, userID, guildID) - values ('UPDATED', new.id, new.question, new.answer, new.type, - new.category, - new.userID, new.guildID); -end; - -create trigger joke_delete_event_trigger - before delete - on jokes -begin - insert - into jokes_audit(status, joke_id, question, answer, type, category, userID, guildID) - values ('DELETE', old.id, old.question, old.answer, old.type, - old.category, - old.userID, old.guildID); -end; - -create table admins -( - id primary key, - name text unique not null -); \ No newline at end of file diff --git a/db/migrations/000001_create_tables.down.sql b/db/migrations/000001_init.down.sql similarity index 54% rename from db/migrations/000001_create_tables.down.sql rename to db/migrations/000001_init.down.sql index 9991ba9..d3b367b 100644 --- a/db/migrations/000001_create_tables.down.sql +++ b/db/migrations/000001_init.down.sql @@ -2,4 +2,7 @@ drop table if exists jokes; drop trigger if exists joke_add_event_trigger; drop trigger if exists joke_update_event_trigger; drop table if exists jokes_audit; -drop table if exists jokes_audit; \ No newline at end of file +drop table if exists jokes_audit; +drop table if exists admins; +drop table if exists joke_types; +drop table if exists joke_categories; \ No newline at end of file diff --git a/db/migrations/000001_init.up.sql b/db/migrations/000001_init.up.sql new file mode 100644 index 0000000..a1036fc --- /dev/null +++ b/db/migrations/000001_init.up.sql @@ -0,0 +1,103 @@ +-- create admins +create table admins +( + id integer primary key autoincrement, + name text unique not null +); + +-- create default categories +create table joke_categories +( + id integer primary key autoincrement, + name text unique not null +); + +insert into joke_categories(name) +values ('Any'); +insert into joke_categories(name) +values ('Programming'); +insert into joke_categories(name) +values ('Misc'); +insert into joke_categories(name) +values ('Dark'); +insert into joke_categories(name) +values ('YoMama'); + +-- create default types + +create table joke_types +( + id integer primary key autoincrement, + name text unique not null +); + +create trigger joke_types_lower_case_name + after insert + on joke_types +begin + update joke_types set name = lower(new.name) where id = new.id; +end; + +insert into joke_types(name) +values ('single'); +insert into joke_types(name) +values ('twopart'); + +-- create jokes + +create table jokes +( + id integer primary key autoincrement, + question text, + answer text not null, + type_id integer not null references joke_types default 1, + category_id integer not null references joke_categories default 1, + userID text, + guildID text +); + +create index jokes_index on jokes (id, guildID); + +create table jokes_audit +( + id integer primary key autoincrement, + status text default 'CREATED', + joke_id integer not null, + question text, + answer text not null, + type_id integer not null references joke_types, + category_id integer not null references joke_categories, + userID text, + guildID text +); + +create trigger joke_add_event_trigger + after insert + on jokes +begin + insert + into jokes_audit(joke_id, question, answer, type_id, category_id, userID, guildID) + values (new.id, new.question, new.answer, new.type_id, new.category_id, new.userID, new.guildID); +end; + +create trigger joke_update_event_trigger + after update + on jokes +begin + insert + into jokes_audit(status, joke_id, question, answer, type_id, category_id, userID, guildID) + values ('UPDATED', new.id, new.question, new.answer, new.type_id, + new.category_id, + new.userID, new.guildID); +end; + +create trigger joke_delete_event_trigger + before delete + on jokes +begin + insert + into jokes_audit(status, joke_id, question, answer, type_id, category_id, userID, guildID) + values ('DELETE', old.id, old.question, old.answer, old.type_id, + old.category_id, + old.userID, old.guildID); +end; \ No newline at end of file diff --git a/db/sql/jokes.sql b/db/sql/jokes.sql new file mode 100644 index 0000000..e6c10c6 --- /dev/null +++ b/db/sql/jokes.sql @@ -0,0 +1,33 @@ +-- name: GetJokeById :one +select * +from jokes +where id == ? +limit 1; + +-- name: GetTypes :many +select * +from joke_types; + +-- name: GetCategories :many +select * +from joke_categories c; + +-- name: AddJoke :exec +insert +into jokes(question, answer, type_id, category_id, userID, guildID) +values (?, ?, ?, ?, ?, ?); + +-- name: RemoveJoke :exec +delete +from jokes +where id = ?; + +-- name: UpdateJoke :exec +update jokes +set question = ?, + answer = ?, + type_id = ?, + category_id = ?, + userID = ?, + guildID = ? +where id = ?; \ No newline at end of file diff --git a/go.mod b/go.mod index 2ca7bb0..34242ba 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ replace ( require ( github.com/google/uuid v1.6.0 + github.com/jackc/pgx/v5 v5.6.0 github.com/wittano/komputer/bot v0.0.0-20240630190043-d1c8d2e0a118 github.com/wittano/komputer/server v0.0.0 go.mongodb.org/mongo-driver v1.16.0 @@ -24,6 +25,8 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/gorilla/websocket v1.5.3 // indirect + github.com/jackc/pgpassfile v1.0.0 // indirect + github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect github.com/joho/godotenv v1.5.1 // indirect github.com/klauspost/compress v1.17.9 // indirect github.com/montanaflynn/stats v0.7.1 // indirect diff --git a/go.sum b/go.sum index 50f50c9..5512e21 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,7 @@ github.com/bwmarrin/dgvoice v0.0.0-20210225172318-caaac756e02e h1:IdfGDWLNL/ZAHd github.com/bwmarrin/dgvoice v0.0.0-20210225172318-caaac756e02e/go.mod h1:DT3heoMAQGrOExZ3Rb3TBOQ4Bm+wD4H48KFnt1YfLoQ= github.com/bwmarrin/discordgo v0.28.1 h1:gXsuo2GBO7NbR6uqmrrBDplPUx2T3nzu775q/Rd1aG4= github.com/bwmarrin/discordgo v0.28.1/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= @@ -13,6 +14,14 @@ github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= +github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= +github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= +github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= +github.com/jackc/pgx/v5 v5.6.0 h1:SWJzexBzPL5jb0GEsrPMLIsi/3jOo7RHlzTjcAeDrPY= +github.com/jackc/pgx/v5 v5.6.0/go.mod h1:DNZ/vlrUnhWCoFGxHAG8U2ljioxukquj7utPDgtQdTw= +github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= +github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= github.com/jarcoal/httpmock v1.3.1 h1:iUx3whfZWVf3jT01hQTO/Eo5sAYtB2/rqaUuOtpInww= github.com/jarcoal/httpmock v1.3.1/go.mod h1:3yb8rc4BI7TCBhFY8ng0gjuLKJNquuDNiPaZjnENuYg= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= @@ -21,14 +30,19 @@ github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2 github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE= github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY= github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4= github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8= github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= -github.com/youmark/pkcs8 v0.0.0-20240424034433-3c2c7870ae76 h1:tBiBTKHnIjovYoLX/TPkcf+OjqqKGQrPtGT3Foz+Pgo= -github.com/youmark/pkcs8 v0.0.0-20240424034433-3c2c7870ae76/go.mod h1:SQliXeA7Dhkt//vS29v3zpbEwoa+zb2Cn5xj5uO4K5U= github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM= github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= @@ -37,16 +51,12 @@ go.mongodb.org/mongo-driver v1.16.0/go.mod h1:oB6AhJQvFQL4LEHyXi6aJzQJtBiTQHiAd8 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= -golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= -golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -58,8 +68,6 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -74,15 +82,15 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d h1:k3zyW3BYYR30e8v3x0bTDdE9vpYFjZHK+HcyqkrppWk= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= google.golang.org/genproto/googleapis/rpc v0.0.0-20240725223205-93522f1f2a9f h1:RARaIm8pxYuxyNPbBQf5igT7XdOyCNtat1qAT2ZxjU4= google.golang.org/genproto/googleapis/rpc v0.0.0-20240725223205-93522f1f2a9f/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= -google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY= -google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg= google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= layeh.com/gopus v0.0.0-20210501142526-1ee02d434e32 h1:/S1gOotFo2sADAIdSGk1sDq1VxetoCWr6f5nxOG0dpY= layeh.com/gopus v0.0.0-20210501142526-1ee02d434e32/go.mod h1:yDtyzWZDFCVnva8NGtg38eH2Ns4J0D/6hD+MMeUGdF0= diff --git a/go.work.sum b/go.work.sum index 42bf1d9..1b3de9c 100644 --- a/go.work.sum +++ b/go.work.sum @@ -45,14 +45,13 @@ github.com/lyft/protoc-gen-star/v2 v2.0.3/go.mod h1:amey7yeodaJhXSbf/TlLvWiqQfLO github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/spf13/afero v1.10.0 h1:EaGW2JJh15aKOejeuJ+wpFSHnbd7GE6Wvp3TsNhb6LY= github.com/spf13/afero v1.10.0/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ= +github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/wittano/komputer v1.1.0/go.mod h1:JReUad3NfC4PJFCjW/DOqqpZFD9+yWmVF6xoEMx42Sw= @@ -102,5 +101,3 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/shell.nix b/shell.nix index 0de9f0f..94886a3 100644 --- a/shell.nix +++ b/shell.nix @@ -8,6 +8,7 @@ , protoc-gen-go-grpc , act , go-migrate +, sqlc , ... }: mkShell { hardeningDisable = [ "all" ]; @@ -15,6 +16,7 @@ go protobuf go-migrate + sqlc act ]; buildInputs = [ diff --git a/sqlc.yaml b/sqlc.yaml new file mode 100644 index 0000000..8c7a0fd --- /dev/null +++ b/sqlc.yaml @@ -0,0 +1,12 @@ +version: "2" +sql: + - engine: "sqlite" + schema: "db/migrations" + queries: "db/sql" + database: + uri: sqlite://db.sqlite + gen: + go: + package: "sql" + out: "sql" + sql_package: "pgx/v5" \ No newline at end of file