yesodweb / yesodweb/persistent
Namespaces in models
Nobody has claimed this yet.
- Dominant language
- Haskell
- Stars
- 486
- Forks
- 306
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Persistent schema declarations using share, mkPersist, and mkMigrate, and compare the generated entities from the M1 and M2 examples. Trace how entity names become table names and how migrations represent them. Done would require an agreed namespacing design that keeps unrelated same-named entities separate and works with migrations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100