Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs need a note on foreign key references to user #14

Open
MichaelXavier opened this issue Jun 20, 2016 · 8 comments
Open

Docs need a note on foreign key references to user #14

MichaelXavier opened this issue Jun 20, 2016 · 8 comments
Assignees

Comments

@MichaelXavier
Copy link
Collaborator

This is from a discussion between myself, @denibertovic, and @bitemyapp. Because of the way QQ scopes things, schema.txt in this repo is not in the same scope when the user includes the decls into their own app. The result is that persistent can't figure out that SnapAuthUserId is a primary key and thus if you reference it in another table, it will not create a foreign key. The solution is to manually tell persistent's TH that the column is a reference.

@MichaelXavier MichaelXavier self-assigned this Jun 20, 2016
@MichaelXavier
Copy link
Collaborator Author

Working example: http://dpaste.com/35XTE73

@denibertovic
Copy link

denibertovic commented Jul 4, 2016

The dpaste I shared with you has been set to expire (and apparently has) so I'm sharing
the code here:

import qualified Snap.Snaplet.Auth.Backends.Persistent as SP

share [mkPersist sqlSettings, mkMigrate "migrateAll"] $ [persistLowerCase|
  SomeStuffz
    userId SP.SnapAuthUserId Eq reference=snap_auth_user
    createdAt UTCTime default=CURRENT_TIMESTAMP
  deriving Eq Show Generic
|] ++ SP.authEntityDefs

@bitemyapp
Copy link

@denibertovic you can make it highlight that as Haskell code in the following manner:

import Blah (myCode)

Example:

import Blah (myCode)

@denibertovic
Copy link

@bitemyapp Yeah I know. Just didn't think about it at the moment. Thanks, I've updated the snippet.

@bitemyapp
Copy link

@denibertovic cheers.

Also is it me or is Github missing a "view source" button for comments?

@denibertovic
Copy link

I don't remember seeing that so it might be just you. :P

@bitemyapp
Copy link

@denibertovic I mean it should be added. It's a turn of phrase.

@denibertovic
Copy link

Ah. Indeed. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants