--- /dev/null
+module TSN.Codegen (
+ tsn_codegen_config )
+where
+
+import Data.List.Utils ( join, split )
+import Database.Groundhog.TH (
+ CodegenConfig ( namingStyle ),
+ NamingStyle ( mkDbFieldName ),
+ defaultCodegenConfig )
+
+default_ns :: NamingStyle
+default_ns = namingStyle defaultCodegenConfig
+
+-- | A database field name creator. It takes the field name (from a
+-- record type) and drops the first component determined by
+-- underscores. So, foo_bar_baz would get mapped to bar_baz in the
+-- database.
+tsn_db_field_namer :: String -> String -> Int -> String -> Int -> String
+tsn_db_field_namer _ _ _ fieldname _ =
+ (join "_") . tail . (split "_") $ fieldname
+
+tsn_naming_style :: NamingStyle
+tsn_naming_style = default_ns { mkDbFieldName = tsn_db_field_namer }
+
+tsn_codegen_config :: CodegenConfig
+tsn_codegen_config =
+ defaultCodegenConfig { namingStyle = tsn_naming_style }