From b8311d3abfe0e1534bf2201eea8d8c75192a8e4b Mon Sep 17 00:00:00 2001 From: anthdm Date: Fri, 7 Jun 2024 09:23:06 +0200 Subject: [PATCH] added migration command --- bootstrap/.env | 2 +- bootstrap/.env.local | 2 +- bootstrap/Makefile | 5 ++++- bootstrap/app/events/foo_event.go | 7 +++++++ bootstrap/go.mod | 18 ++++++++++++++++++ event/event.go | 4 ++++ 6 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 bootstrap/app/events/foo_event.go diff --git a/bootstrap/.env b/bootstrap/.env index d612bdd..1e928c5 100644 --- a/bootstrap/.env +++ b/bootstrap/.env @@ -11,7 +11,7 @@ DB_DRIVER = sqlite3 DB_USER = DB_HOST = DB_PASSWORD = -DB_NAME = app_db +DB_NAME = app_db MIGRATION_DIR = app/db/migrations diff --git a/bootstrap/.env.local b/bootstrap/.env.local index d612bdd..1e928c5 100644 --- a/bootstrap/.env.local +++ b/bootstrap/.env.local @@ -11,7 +11,7 @@ DB_DRIVER = sqlite3 DB_USER = DB_HOST = DB_PASSWORD = -DB_NAME = app_db +DB_NAME = app_db MIGRATION_DIR = app/db/migrations diff --git a/bootstrap/Makefile b/bootstrap/Makefile index d1cb3cf..668d695 100644 --- a/bootstrap/Makefile +++ b/bootstrap/Makefile @@ -21,7 +21,7 @@ live/server: # run tailwindcss to generate the styles.css bundle in watch mode. live/tailwind: - tailwindcss -i assets/app.css -o ./public/styles.css --watch + tailwindcss -i app/assets/app.css -o ./public/styles.css --watch # run esbuild to generate the index.js bundle in watch mode. live/esbuild: @@ -50,5 +50,8 @@ db-reset: db-up: @GOOSE_DRIVER=$(DB_DRIVER) GOOSE_DBSTRING=$(DB_NAME) goose -dir=$(MIGRATION_DIR) up +db-mig: + @GOOSE_DRIVER=$(DB_DRIVER) GOOSE_DBSTRING=$(DB_NAME) goose -dir=$(MIGRATION_DIR) create $(filter-out $@,$(MAKECMDGOALS)) sql + db-seed: @go run cmd/scripts/seed/main.go \ No newline at end of file diff --git a/bootstrap/app/events/foo_event.go b/bootstrap/app/events/foo_event.go new file mode 100644 index 0000000..d8fb211 --- /dev/null +++ b/bootstrap/app/events/foo_event.go @@ -0,0 +1,7 @@ +package events + +import "context" + +func HandleFooEvent(ctx context.Context, event any) { + +} diff --git a/bootstrap/go.mod b/bootstrap/go.mod index 56fcbc9..656df2e 100644 --- a/bootstrap/go.mod +++ b/bootstrap/go.mod @@ -2,8 +2,26 @@ module AABBCCDD go 1.22.0 +require ( + github.com/mattn/go-sqlite3 v1.14.22 + github.com/uptrace/bun v1.2.1 +) + +require ( + github.com/fatih/color v1.16.0 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect +) + require ( github.com/a-h/templ v0.2.707 // indirect github.com/anthdm/gothkit v0.0.0-20240606141535-31a222db1a4a // indirect github.com/go-chi/chi/v5 v5.0.12 // indirect + github.com/jinzhu/inflection v1.0.0 // indirect + github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect + github.com/uptrace/bun/dialect/sqlitedialect v1.2.1 + github.com/uptrace/bun/extra/bundebug v1.2.1 + github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect + github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect + golang.org/x/sys v0.19.0 // indirect ) diff --git a/event/event.go b/event/event.go index 992b745..00b0539 100644 --- a/event/event.go +++ b/event/event.go @@ -12,6 +12,10 @@ type event struct { message any } +type CreateUserEvent struct{} + +func HandleCreateUserEvent(ctx context.Context, event CreateUserEvent) {} + // Handler is the function being called when receiving an event. type Handler func(context.Context, any)