diff --git a/migrations/V1__Initial_databas.sql b/migrations/V1__Initial_databas.sql index bfbc1f4..ad87669 100644 --- a/migrations/V1__Initial_databas.sql +++ b/migrations/V1__Initial_databas.sql @@ -1,5 +1,9 @@ -create table users ( - email varchar(64) primary key, - username varchar(64), - password varchar(64) -); +CREATE TABLE public.users ( + email text NOT NULL, + username text NOT NULL, + "password" bytea NOT NULL, + CONSTRAINT users_pkey PRIMARY KEY (email) +) +WITH ( + OIDS=FALSE +) ; diff --git a/src/API.hs b/src/API.hs index cec504a..218099d 100644 --- a/src/API.hs +++ b/src/API.hs @@ -47,7 +47,7 @@ type API = Get '[HTML] Index handler :: ServerT API AppM handler = do - u <- runDB $ + u <- runDB $ do query $ select $ gen users $logInfo $ "users: " <> (pack . show $ u) return Index diff --git a/src/Main.hs b/src/Main.hs index 3bb73a3..5f5d3c4 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -11,7 +11,6 @@ import Network.Wai.Handler.Warp (run) import Types import Configuration import Dhall (input, auto) -import System.Process (callProcess) import ClassyPrelude import Control.Lens (view) import Data.Generics.Product @@ -29,18 +28,17 @@ defaultMain config = do let app = App{..} run 8080 (server app) -migrate :: Pg -> IO () -migrate Pg{..} = do - -- Credentials visible on ps - -- XXX: Modify this to write the credentials to a temporary file or something - callProcess "flyway" $ fmap unpack [ "migrate" - , "-locations=filesystem:migrations/" - , "-url=jdbc:postgresql://" <> host <> "/" <> database - , "-user=" <> username - , "-password=" <> password] +-- migrate :: Pg -> IO () +-- migrate Pg{..} = do +-- -- Credentials visible on ps +-- -- XXX: Modify this to write the credentials to a temporary file or something +-- callProcess "flyway" $ fmap unpack [ "migrate" +-- , "-locations=filesystem:migrations/" +-- , "-url=jdbc:postgresql://" <> host <> "/" <> database +-- , "-user=" <> username +-- , "-password=" <> password] main :: IO () main = do c <- input auto "./config/config.dhall" - migrate (view (field @"database") c) defaultMain c