yesodweb / yesodweb/persistent

Modifying the Id of a persistent entity to use serial4 instead of serial8

Open
#1,336 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Haskell
Stars
486
Forks
306
PR merge metrics
No merged PRs in 30d

Description

I have this:

fact
    Id Int32 sqltype=serial4

And that creates this:

CREATE TABLE public.fact (
    id integer NOT NULL
)

but not the sequence:

ALTER TABLE ONLY public.viewing_fact ALTER COLUMN id SET DEFAULT nextval('public.viewing_fact_id_seq'::regclass);

I guess only serial8 is supported in persistent after finding maySerial?

I think this is related to this comment of yours and that idea is blocked by #1321 maybe?

Info:

/bin/uname
Linux 01cd201e6c60 5.11.21 #1-NixOS SMP Fri May 14 08:50:20 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
/usr/local/bin/stack
Version 2.7.3, Git revision 7927a3aec32e2b2e5e4fb5be76d0d50eddcc197f x86_64 hpack-0.34.4
/usr/local/bin/stack
The Glorious Glasgow Haskell Compilation System, version 8.10.7
/usr/local/bin/stack

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in persistent-postgresql/Database/Persist/Postgresql.hs at the maySerial entry point linked in the issue, and compare the generated SQL for serial4 with the provided entity definition. Review the related discussion in issues #1037 and #1321. Done means serial4 produces the expected sequence and column default rather than only an integer column.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell, postgresql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.