Fix schema
This commit is contained in:
		@@ -1,5 +1,9 @@
 | 
				
			|||||||
create table users (
 | 
					CREATE TABLE public.users (
 | 
				
			||||||
  email varchar(64) primary key,
 | 
					  email text NOT NULL,
 | 
				
			||||||
  username varchar(64),
 | 
					  username text NOT NULL,
 | 
				
			||||||
  password varchar(64)
 | 
					  "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 :: ServerT API AppM
 | 
				
			||||||
handler = do
 | 
					handler = do
 | 
				
			||||||
  u <- runDB $
 | 
					  u <- runDB $ do
 | 
				
			||||||
    query $ select $ gen users
 | 
					    query $ select $ gen users
 | 
				
			||||||
  $logInfo $ "users: " <> (pack . show $ u)
 | 
					  $logInfo $ "users: " <> (pack . show $ u)
 | 
				
			||||||
  return Index
 | 
					  return Index
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										20
									
								
								src/Main.hs
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								src/Main.hs
									
									
									
									
									
								
							@@ -11,7 +11,6 @@ import Network.Wai.Handler.Warp (run)
 | 
				
			|||||||
import Types
 | 
					import Types
 | 
				
			||||||
import Configuration
 | 
					import Configuration
 | 
				
			||||||
import Dhall (input, auto)
 | 
					import Dhall (input, auto)
 | 
				
			||||||
import System.Process (callProcess)
 | 
					 | 
				
			||||||
import ClassyPrelude
 | 
					import ClassyPrelude
 | 
				
			||||||
import Control.Lens (view)
 | 
					import Control.Lens (view)
 | 
				
			||||||
import Data.Generics.Product
 | 
					import Data.Generics.Product
 | 
				
			||||||
@@ -29,18 +28,17 @@ defaultMain config = do
 | 
				
			|||||||
  let app = App{..}
 | 
					  let app = App{..}
 | 
				
			||||||
  run 8080 (server app)
 | 
					  run 8080 (server app)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
migrate :: Pg -> IO ()
 | 
					-- migrate :: Pg -> IO ()
 | 
				
			||||||
migrate Pg{..} = do
 | 
					-- migrate Pg{..} = do
 | 
				
			||||||
  -- Credentials visible on ps
 | 
					--   -- Credentials visible on ps
 | 
				
			||||||
  -- XXX: Modify this to write the credentials to a temporary file or something
 | 
					--   -- XXX: Modify this to write the credentials to a temporary file or something
 | 
				
			||||||
  callProcess "flyway" $ fmap unpack [ "migrate"
 | 
					--   callProcess "flyway" $ fmap unpack [ "migrate"
 | 
				
			||||||
                                     , "-locations=filesystem:migrations/"
 | 
					--                                      , "-locations=filesystem:migrations/"
 | 
				
			||||||
                                     , "-url=jdbc:postgresql://" <> host <> "/" <> database
 | 
					--                                      , "-url=jdbc:postgresql://" <> host <> "/" <> database
 | 
				
			||||||
                                     , "-user=" <> username
 | 
					--                                      , "-user=" <> username
 | 
				
			||||||
                                     , "-password=" <> password]
 | 
					--                                      , "-password=" <> password]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
main :: IO ()
 | 
					main :: IO ()
 | 
				
			||||||
main = do
 | 
					main = do
 | 
				
			||||||
  c <- input auto "./config/config.dhall"
 | 
					  c <- input auto "./config/config.dhall"
 | 
				
			||||||
  migrate (view (field @"database") c)
 | 
					 | 
				
			||||||
  defaultMain c
 | 
					  defaultMain c
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user