# from project root# generate SSL certificate and private key
go run ./internal/gencert
go run .
Manage PostgreSQL database (from local machine)
# on local machine (from project root)cd .devcontainer
docker container exec -it <database_container_name> sh
# in the postgres container
psql --username=$POSTGRES_USER --dbname=$POSTGRES_DB\l# list databases\c<database_name># connect to a database\dt # list tables in the database\d<table_name># describe a table\g# run the previous command\timing # turn on timing\h DROP TABLE # get help of a statement e.g. DROP TABLE
createdatabasechitchat;
createtableusers (
id serialprimary key,
uuid varchar(64) not null unique,
name varchar(255),
email varchar(255) not null unique,
password varchar(255) not null,
created_at timestampnot null
);
createtablesessions (
id serialprimary key,
uuid varchar(64) not null unique,
email varchar(255),
user_id integerreferences users(id),
created_at timestampnot null
);
createtablethreads (
id serialprimary key,
uuid varchar(64) not null unique,
topic text,
user_id integerreferences users(id),
created_at timestampnot null
);
createtableposts (
id serialprimary key,
uuid varchar(64) not null unique,
body text,
user_id integerreferences users(id),
thread_id integerreferences threads(id),
created_at timestampnot null
);
About
Learn go with https://www.amazon.com/Web-Programming-Sau-Sheong-Chang/dp/1617292567