Compare commits
No commits in common. "e1a4c1234ff31ad7a5edece083a87e2107baf278" and "f60a6f1204fceff8645d40a0fefed8ca228cba9d" have entirely different histories.
e1a4c1234f
...
f60a6f1204
8 changed files with 9 additions and 64 deletions
10
.env
10
.env
|
|
@ -1,5 +1,5 @@
|
|||
WSRS_DATABASE_NAME="wsrs"
|
||||
WSRS_DATABASE_USER="postgres"
|
||||
WSRS_DATABASE_PASSWORD="123456789"
|
||||
WSRS_DATABASE_PORT=5432
|
||||
WSRS_DATABASE_HOST="localhost"
|
||||
WRSR_DATABASE_NAME="wsrs"
|
||||
WRSR_DATABASE_USER="postgres"
|
||||
WRSR_DATABASE_PASSWORD="123456789"
|
||||
WRSR_DATABASE_PORT=5432
|
||||
WRSR_DATABASE_HOST="localhost"
|
||||
|
|
|
|||
|
|
@ -22,8 +22,3 @@ $ go install github.com/jackc/tern/v2@latest
|
|||
$ tern new --migrations ./internal/store/pgstore/migrations create_rooms_table
|
||||
$ tern new --migrations ./internal/store/pgstore/migrations create_messages_table
|
||||
```
|
||||
|
||||
### Wrapper around tern
|
||||
|
||||
`tern.config` does not read `.env` file directly so a wrapper was created to be
|
||||
able to load environment variables.
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := godotenv.Load(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
cmd := exec.Command("tern", "migrate", "--migrations", "./internal/store/pgstore/migrations", "--config", "./internal/store/pgstore/migrations/tern.conf")
|
||||
|
||||
if err := cmd.Run(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
|
@ -3,11 +3,11 @@ services:
|
|||
image: postgres:latest
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- ${WSRS_DATABASE_PORT:-5432}:5432
|
||||
- ${WRSR_DATABASE_PORT:-5432}:5432
|
||||
environment:
|
||||
POSTGRES_USER: ${WSRS_DATABASE_USER}
|
||||
POSTGRES_PASSWORD: ${WSRS_DATABASE_PASSWORD}
|
||||
POSTGRES_DB: ${WSRS_DATABASE_NAME}
|
||||
POSTGRES_USER: ${WRSR_DATABASE_USER}
|
||||
POSTGRES_PASSWORD: ${WRSR_DATABASE_PASSWORD}
|
||||
POSTGRES_DB: ${WRSR_DATABASE_NAME}
|
||||
volumes:
|
||||
- db:/var/lib/postgresql/data
|
||||
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -1,5 +1,3 @@
|
|||
module forgejo.home.viniciussouza.me/learning/go-react-server
|
||||
|
||||
go 1.22.2
|
||||
|
||||
require github.com/joho/godotenv v1.5.1
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
CREATE TABLE IF NOT EXISTS rooms (
|
||||
"id" uuid PRIMARY KEY NOT NULL DEFAULT gen_random_uuid(),
|
||||
"theme" VARCHAR(255) NOT NULL
|
||||
);
|
||||
|
||||
---- create above / drop below ----
|
||||
|
||||
DROP TABLE IF EXISTS rooms;
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
CREATE TABLE IF NOT EXISTS messages (
|
||||
"id" uuid PRIMARY KEY NOT NULL DEFAULT gen_random_uuid(),
|
||||
"room_id" uuid NOT NULL,
|
||||
"message" VARCHAR(255) NOT NULL,
|
||||
"reaction_count" BIGINT NOT NULL DEFAULT 0,
|
||||
"answered" BOOLEAN NOT NULL DEFAULT false,
|
||||
|
||||
FOREIGN KEY (room_id) REFERENCES rooms(id)
|
||||
);
|
||||
|
||||
---- create above / drop below ----
|
||||
|
||||
DROP TABLE IF EXISTS messages;
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
[database]
|
||||
host = {{ env "WSRS_DATABASE_HOST" }}
|
||||
port = {{ env "WSRS_DATABASE_PORT" }}
|
||||
# database is required
|
||||
database = {{ env "WSRS_DATABASE_NAME" }}
|
||||
# user defaults to OS user
|
||||
user = {{ env "WSRS_DATABASE_USER" }}
|
||||
password = {{ env "WSRS_DATABASE_PASSWORD" }}
|
||||
Loading…
Reference in a new issue