Many ERP systems allow its user to write applications on top of them. Applications may store their stuff in the system's database, which means that each application has its own set of entities. If we're to write such a system using Persistent, how can we handle a case when two unrelated applications create entities with same names?
In other words, if we have two Haskell modules M1 and M2, both of which containing something like
share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
User
name Text
|]
then running
import qualified M1
import qualified M2
insert $ M1.User "User1"
insert $ M2.User "User2"
will place the data into the same table.
Would it make sense to implement some sort of namespacing in Persistent? If yes, what approach should be taken?
I'm thinking about taking a fully qualified module name (like, packagename-1.2.3.Database.Persist.Foo), computing a hash based on it and appending it to the table name.
Many ERP systems allow its user to write applications on top of them. Applications may store their stuff in the system's database, which means that each application has its own set of entities. If we're to write such a system using Persistent, how can we handle a case when two unrelated applications create entities with same names?
In other words, if we have two Haskell modules
M1andM2, both of which containing something likethen running
will place the data into the same table.
Would it make sense to implement some sort of namespacing in Persistent? If yes, what approach should be taken?
I'm thinking about taking a fully qualified module name (like,
packagename-1.2.3.Database.Persist.Foo), computing a hash based on it and appending it to the table name.