Search code examples
postgresqlelixirphoenix-frameworkecto

Append only data in phoenix, ecto and postgres


One of my models in Phoenix application has append-only semantics. There will be events that can be created, but should never be updated by the application (read only after creation).

Is there a postgres mechanism to enforce such thing on a table?

How should I define my migration to use it?


Solution

  • You can set the permissions on the table to allow INSERT and SELECT but not, for example, UPDATE or DELETE for the role that is used to access the data. This way there is no possibility to alter the data.

    More information on permissions.