From 356270857fec7798d3100c9ae2625e005bd16992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Krop=C3=A1=C4=8Dek?= Date: Mon, 10 Mar 2025 22:39:32 +0100 Subject: [PATCH] WiP --- cmd/secret-santa/main.go | 5 +++-- internal/config/parse.go | 3 ++- .../postgres/000001_create_users_table.down.sql | 1 + .../000001_create_users_table.up.sql} | 8 ++------ sql/queries/{ => postgres}/user.sql | 0 sqlc.yaml | 6 +++--- 6 files changed, 11 insertions(+), 12 deletions(-) create mode 100644 sql/migrations/postgres/000001_create_users_table.down.sql rename sql/migrations/{20241114201119-initial.sql => postgres/000001_create_users_table.up.sql} (58%) rename sql/queries/{ => postgres}/user.sql (100%) diff --git a/cmd/secret-santa/main.go b/cmd/secret-santa/main.go index 5bb99ea..70af421 100644 --- a/cmd/secret-santa/main.go +++ b/cmd/secret-santa/main.go @@ -3,13 +3,14 @@ package main import ( "database/sql" "flag" + "log" + "os" + "git.katuwoss.dev/JustScreaMy/secret-santa/internal/app" "git.katuwoss.dev/JustScreaMy/secret-santa/internal/config" _ "github.com/go-sql-driver/mysql" _ "github.com/jackc/pgx/v5/stdlib" _ "github.com/mattn/go-sqlite3" - "log" - "os" ) var ( diff --git a/internal/config/parse.go b/internal/config/parse.go index 40262af..a576e1a 100644 --- a/internal/config/parse.go +++ b/internal/config/parse.go @@ -3,11 +3,12 @@ package config import ( "encoding/json" "fmt" - "github.com/go-playground/validator/v10" "io" "os" "path/filepath" + "github.com/go-playground/validator/v10" + "github.com/pelletier/go-toml/v2" "gopkg.in/yaml.v3" ) diff --git a/sql/migrations/postgres/000001_create_users_table.down.sql b/sql/migrations/postgres/000001_create_users_table.down.sql new file mode 100644 index 0000000..365a210 --- /dev/null +++ b/sql/migrations/postgres/000001_create_users_table.down.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS users; \ No newline at end of file diff --git a/sql/migrations/20241114201119-initial.sql b/sql/migrations/postgres/000001_create_users_table.up.sql similarity index 58% rename from sql/migrations/20241114201119-initial.sql rename to sql/migrations/postgres/000001_create_users_table.up.sql index 930ed84..cd00aa0 100644 --- a/sql/migrations/20241114201119-initial.sql +++ b/sql/migrations/postgres/000001_create_users_table.up.sql @@ -1,10 +1,6 @@ --- +migrate Up CREATE TABLE users ( - id INTEGER PRIMARY KEY, + id UUID PRIMARY KEY, first_name VARCHAR(64) NOT NULL, last_name VARCHAR(64) NOT NULL, email VARCHAR(128) NOT NULL -); - --- +migrate Down -DROP TABLE IF EXISTS users; \ No newline at end of file +); \ No newline at end of file diff --git a/sql/queries/user.sql b/sql/queries/postgres/user.sql similarity index 100% rename from sql/queries/user.sql rename to sql/queries/postgres/user.sql diff --git a/sqlc.yaml b/sqlc.yaml index 79a7f0b..d670ffc 100644 --- a/sqlc.yaml +++ b/sqlc.yaml @@ -1,8 +1,8 @@ version: "2" sql: - - engine: sqlite - queries: sql/queries/ - schema: sql/migrations/ + - engine: postgresql + queries: sql/queries/postgres/ + schema: sql/migrations/postgres/ gen: go: package: "queries"