db: create user table

This commit is contained in:
Muyao CHEN 2024-10-04 21:19:49 +02:00
parent 8e14ccd12a
commit b9d4a58d71
6 changed files with 49 additions and 0 deletions

1
.gitignore vendored
View File

@ -24,3 +24,4 @@ go.work.sum
# Custom # Custom
/_output /_output
/deployment/db_data

View File

@ -195,3 +195,5 @@ type User struct {
ID int ID int
} }
``` ```
Use Buffalo pop `Soda CLI` to create database migrations.

7
database.yml Normal file
View File

@ -0,0 +1,7 @@
development:
dialect: postgres
database: howmuch
user: postgres
password: example
host: 127.0.0.1
pool: 5

View File

@ -0,0 +1,22 @@
services:
postgres:
image: postgres
restart: always
ports:
- "5432:5432"
deploy:
mode: replicated
replicas: 1
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: example
POSTGRES_DB: howmuch
volumes:
- ./db_data/postgres/:/var/lib/postgresql/data
adminer:
image: adminer
restart: always
ports:
- 8080:8080

View File

@ -0,0 +1,3 @@
DROP TABLE IF EXISTS "user";
DROP SEQUENCE IF EXISTS user_id_seq;

View File

@ -0,0 +1,14 @@
CREATE SEQUENCE user_id_seq INCREMENT 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1;
CREATE TABLE "public"."user" (
"id" integer DEFAULT nextval('user_id_seq') NOT NULL,
"email" character varying(255) NOT NULL UNIQUE,
"first_name" character varying(255) NOT NULL,
"last_name" character varying(255) NOT NULL,
"password" character varying(60) NOT NULL,
"created_at" timestamp NOT NULL,
"updated_at" timestamp NOT NULL,
CONSTRAINT "user_pkey" PRIMARY KEY ("id")
) WITH (oids = false);