1
Fork 0

fsharp(todolist-api): chore: added a db

Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
Matei Adriel 2020-01-02 13:00:02 +02:00 committed by prescientmoon
parent bbdd130382
commit 2fd9d0da2e
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4
3 changed files with 27 additions and 2 deletions

View file

@ -0,0 +1,2 @@
FROM postgres
COPY create.sql /docker-entrypoint-initdb.d/postgres_create.sql

View file

@ -0,0 +1,20 @@
CREATE DATABASE "todo_api_db";
\connect "todo_api_db"
DROP TABLE IF EXISTS "todos" CASCADE;
CREATE TABLE "todos" (
"id" SERIAL PRIMARY KEY NOT NULL,
"name" varchar(120) NULL,
"description" varchar(4000) NULL);
INSERT INTO "todos" ("name", "description") VALUES ('Example', 'I wonder if you are reading this.');
CREATE USER suave WITH ENCRYPTED Password '1234';
GRANT USAGE ON SCHEMA public to suave;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO suave;
GRANT CONNECT ON DATABASE "todo_api_db" to suave;
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO suave;
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO suave;

View file

@ -1,8 +1,11 @@
// Learn more about F# at http://fsharp.org // Learn more about F# at http://fsharp.org
open Suave
open Suave.Successful
[<EntryPoint>] [<EntryPoint>]
let main argv = let main argv =
printfn "Hello World from F#!"
startWebServer defaultConfig (OK "hello world")
0 // return an integer exit code 0 // return an integer exit code