Fix schema
This commit is contained in:
		@@ -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
 | 
			
		||||
) ;
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										20
									
								
								src/Main.hs
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user