Skip to content

uuid primary key on migration #4

Description

@bendo01

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions