haskell-webapps
haskell-webapps copied to clipboard
Start of Sprint 2
Things planned
1. Solve the createdAt/updatedAt problem -- 10 Hrs
Use either of these options
-
Make the fields non-writable in TableW definitions and use default column values and triggers to update these fields directly in the DB.
-
Keep these fields writeable and use a wrapper function over insertManyAndReturning and runUpdate which sets & updates these columns automatically (this reducing boilerplate)
2. Make the id field non-writable in the TableW mappings. However, it should be readable. Opalaye should never be writing out primary keys of tables. -- 1 Hr
3. Use lenses in all the domain API functions so that you don’t have to pattern-match the record constructor everywhere -- 2 Hrs
4. Implement audit logs -- 10 Hrs
Use ether of two options:
- Using Posgres triggers
- Using wrapper functions over insertManyAndReturning and runUpdate that somehow track the changes being made to the record and insert a row in the audit_logs table
Use a helper function to remove the following boilerplate from all places: return $ case r of [] -> Nothing (x:xs) -> Just x
Just check if we already have access to a safeHead or a headMaybe function from a package that we're already using.
Overall the Auditable interface looks like a great attempt. Did you already know TH, or did you learn it to solve this problem?
@saurabhnanda
I didn't know TH before. Learned it for this solution.