haskell-webapps icon indicating copy to clipboard operation
haskell-webapps copied to clipboard

Start of Sprint 2

Open sras opened this issue 9 years ago • 3 comments

Things planned

1. Solve the createdAt/updatedAt problem -- 10 Hrs

Use either of these options

  1. Make the fields non-writable in TableW definitions and use default column values and triggers to update these fields directly in the DB.

  2. 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:

  1. Using Posgres triggers
  2. 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

sras avatar Nov 04 '16 12:11 sras

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.

saurabhnanda avatar Nov 10 '16 11:11 saurabhnanda

Overall the Auditable interface looks like a great attempt. Did you already know TH, or did you learn it to solve this problem?

saurabhnanda avatar Nov 19 '16 08:11 saurabhnanda

@saurabhnanda

I didn't know TH before. Learned it for this solution.

sras avatar Nov 19 '16 19:11 sras