Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
WMS Server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Software
WMS Server
Commits
6f7ca47d
Commit
6f7ca47d
authored
Jan 13, 2020
by
Nicolas Lenz
❄
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch to PostgreSQL
parent
120faf1f
Pipeline
#338
passed with stage
in 25 minutes and 23 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
12 deletions
+16
-12
app-ctl/Main.hs
app-ctl/Main.hs
+6
-2
config/settings.yml
config/settings.yml
+2
-2
package.yaml
package.yaml
+1
-1
src/Application.hs
src/Application.hs
+5
-5
src/Settings.hs
src/Settings.hs
+2
-2
No files found.
app-ctl/Main.hs
View file @
6f7ca47d
...
...
@@ -4,7 +4,8 @@ module Main where
import
Import
import
Auth
import
Database.Persist.Sqlite
import
Control.Monad.Logger
(
runStderrLoggingT
)
import
Database.Persist.Postgresql
main
::
IO
()
main
=
do
...
...
@@ -22,7 +23,10 @@ addUser name = do
hFlush
stdout
pass
<-
withEcho
False
getLine
putChar
'
\n
'
runSqlite
"wms-server.sqlite3"
$
Auth
.
addUser
name
pass
settings
<-
loadYamlSettings
[
configSettingsYml
]
[]
useEnv
runStderrLoggingT
$
withPostgresqlConn
(
pgConnStr
$
appDatabaseConf
settings
)
(
runSqlConn
$
Auth
.
addUser
name
pass
)
putStrLn
"User added."
withEcho
::
Bool
->
IO
a
->
IO
a
...
...
config/settings.yml
View file @
6f7ca47d
...
...
@@ -30,8 +30,8 @@ ip-from-header: "_env:YESOD_IP_FROM_HEADER:false"
database
:
# See config/test-settings.yml for an override during tests
database
:
"
_env:YESOD_SQLITE_DATABASE:wms-server.sqlite3
"
poolsize
:
"
_env:YESOD_
SQLITE
_POOLSIZE:10"
connstr
:
"
_env:YESOD_PG_CONNSTR:postgresql://wms@localhost/wms
"
poolsize
:
"
_env:YESOD_
PG
_POOLSIZE:10"
copyright
:
Insert copyright statement here
#analytics: UA-YOURCODE
package.yaml
View file @
6f7ca47d
...
...
@@ -13,7 +13,7 @@ dependencies:
-
bytestring
-
text
-
persistent
-
persistent-
sqlite
-
persistent-
postgresql
-
persistent-template
-
template-haskell
-
shakespeare
...
...
src/Application.hs
View file @
6f7ca47d
...
...
@@ -21,8 +21,8 @@ module Application
)
where
import
Control.Monad.Logger
(
liftLoc
,
runLoggingT
)
import
Database.Persist.
Sqlite
(
createSqlite
Pool
,
runSqlPool
,
sqlDatabase
,
sql
PoolSize
)
import
Database.Persist.
Postgresql
(
createPostgresql
Pool
,
runSqlPool
,
pgConnStr
,
pg
PoolSize
)
import
Import
import
Language.Haskell.TH.Syntax
(
qLocation
)
import
Network.Wai
(
Middleware
)
...
...
@@ -73,9 +73,9 @@ makeFoundation appSettings = do
logFunc
=
messageLoggerSource
tempFoundation
appLogger
-- Create the database connection pool
pool
<-
flip
runLoggingT
logFunc
$
create
Sqlite
Pool
(
sqlDatabase
$
appDatabaseConf
appSettings
)
(
sql
PoolSize
$
appDatabaseConf
appSettings
)
pool
<-
flip
runLoggingT
logFunc
$
create
Postgresql
Pool
(
pgConnStr
$
appDatabaseConf
appSettings
)
(
pg
PoolSize
$
appDatabaseConf
appSettings
)
-- Perform database migration using our application's logging settings.
runLoggingT
(
runSqlPool
(
runMigration
migrateAll
)
pool
)
logFunc
...
...
src/Settings.hs
View file @
6f7ca47d
...
...
@@ -16,7 +16,7 @@ import Data.Aeson (Result (..), fromJSON, withObject, (.!=),
(
.:?
))
import
Data.FileEmbed
(
embedFile
)
import
Data.Yaml
(
decodeEither'
)
import
Database.Persist.
Sqlite
(
Sqlite
Conf
)
import
Database.Persist.
Postgresql
(
Postgres
Conf
)
import
Language.Haskell.TH.Syntax
(
Exp
,
Name
,
Q
)
import
Network.Wai.Handler.Warp
(
HostPreference
)
import
Yesod.Default.Config2
(
applyEnvValue
,
configSettingsYml
)
...
...
@@ -29,7 +29,7 @@ import Yesod.Default.Util (WidgetFileSettings, widgetFileNoReload,
data
AppSettings
=
AppSettings
{
appStaticDir
::
String
-- ^ Directory from which to serve static files.
,
appDatabaseConf
::
Sqlite
Conf
,
appDatabaseConf
::
Postgres
Conf
-- ^ Configuration settings for accessing the database.
,
appRoot
::
Maybe
Text
-- ^ Base for all generated URLs. If @Nothing@, determined
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment