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

uuid primary key on migration #4

Open
bendo01 opened this issue Jan 16, 2025 · 0 comments
Open

uuid primary key on migration #4

bendo01 opened this issue Jan 16, 2025 · 0 comments

Comments

@bendo01
Copy link

bendo01 commented Jan 16, 2025

Dear all,

New to this, coming from laravel i want to learn jetzig framework i want to create a migration with uuid v4 or uuid v7 with default value

if using uuid v4 with auto generate id

CREATE TABLE IF NOT EXISTS articles
(
    id uuid NOT NULL DEFAULT gen_random_uuid(),
    title character varying(255) COLLATE pg_catalog."default" NOT NULL,
    created_at timestamp(0) without time zone DEFAULT now(),
    updated_at timestamp(0) without time zone DEFAULT now(),
    sync_at timestamp without time zone,
    deleted_at timestamp(0) without time zone,
    created_by uuid DEFAULT '00000000-0000-0000-0000-000000000000'::uuid,
    updated_by uuid DEFAULT '00000000-0000-0000-0000-000000000000'::uuid,
    CONSTRAINT articles_pkey PRIMARY KEY (id)
)

if using uuid v7 with auto generate id

CREATE TABLE IF NOT EXISTS articles
(
    id uuid NOT NULL DEFAULT uuid_generate_v7(),
    title character varying(255) COLLATE pg_catalog."default" NOT NULL,
    created_at timestamp(0) without time zone DEFAULT now(),
    updated_at timestamp(0) without time zone DEFAULT now(),
    sync_at timestamp without time zone,
    deleted_at timestamp(0) without time zone,
    created_by uuid DEFAULT '00000000-0000-0000-0000-000000000000'::uuid,
    updated_by uuid DEFAULT '00000000-0000-0000-0000-000000000000'::uuid,
    CONSTRAINT articles_pkey PRIMARY KEY (id)
)

i'm using https://github.com/fboulnois/pg_uuidv7 in postgresql as an extension for uuid v7 and using https://github.com/r4gus/uuid-zig as plugin on jetzig

can you give an example on jetzig migration and jetzig model for this sql
Thanks in advance

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

1 participant