Following the Build Your Own Blogging Software challenge.
- Spin up a PostgreSQL server and create a database.
- Create a table
postswith the following command:CREATE TABLE posts ( id SERIAL PRIMARY KEY, title VARCHAR(50) NOT NULL, summary VARCHAR(100) NOT NULL, body TEXT NOT NULL, created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); - Save the database URL in an environment variable
DATABASE_URL(something like "postgres://user:pass@localhost:5432/dbname"). - Run
go run main.goand navigate to localhost:8090 to use the service.