5 import Data.List.Utils ( join, split )
6 import Database.Groundhog.TH (
7 CodegenConfig ( namingStyle ),
8 NamingStyle ( mkDbFieldName ),
11 default_ns :: NamingStyle
12 default_ns = namingStyle defaultCodegenConfig
14 -- | A database field name creator. It takes the field name (from a
15 -- record type) and drops the first component determined by
16 -- underscores. So, foo_bar_baz would get mapped to bar_baz in the
18 tsn_db_field_namer :: String -> String -> Int -> String -> Int -> String
19 tsn_db_field_namer _ _ _ fieldname _ =
20 (join "_") . tail . (split "_") $ fieldname
22 tsn_naming_style :: NamingStyle
23 tsn_naming_style = default_ns { mkDbFieldName = tsn_db_field_namer }
25 tsn_codegen_config :: CodegenConfig
27 defaultCodegenConfig { namingStyle = tsn_naming_style }