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

fix(drizzle)!: convert column names for radio and select fields to snake_case #8439

Conversation

r1tsuu
Copy link
Collaborator

@r1tsuu r1tsuu commented Sep 26, 2024

Fixes #8402 and #8027

Before DB column names were camelCase:
image

After this change, they are snake_case:
Screenshot 2024-10-04 114226

Breaking SQLite / Postgres ⚠️

If you had any select (not hasMany: true) or radio fields with the name in camelCase, for example:

{
  name: 'selectReadOnly',
  type: 'select',
  admin: {
    readOnly: true,
  },
  options: [
    {
      label: 'Value One',
      value: 'one',
    },
    {
      label: 'Value Two',
      value: 'two',
    },
  ],
},

This previously was mapped to the db column name "selectReadOnly". Now it's select_read_only.
Generate a new migration to rename your columns.

pnpm payload migrate:create

Then select "rename column" for targeted columns and Drizzle will handle the migration.

@r1tsuu r1tsuu changed the title fix(drizzle)!: convert column names for radio and select fields to sn… fix(drizzle)!: convert column names for radio and select fields to snake_case Sep 26, 2024
Copy link
Contributor

@DanRibbens DanRibbens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Postgres was in beta I think we should just make this the change and let people do the migration. I don't agree that we need a flag for disableConvertRadioAndGroupFieldsToSnakeCase.
@jmikrut let's talk about this before Sasha makes the change.

@DanRibbens DanRibbens enabled auto-merge (squash) October 4, 2024 16:21
@DanRibbens DanRibbens merged commit 0128eed into beta Oct 4, 2024
51 checks passed
@DanRibbens DanRibbens deleted the fix/drizzle-use-column-names-for-radio-fields-in-snake_case-instead-of-camelCase branch October 4, 2024 16:25
Copy link

github-actions bot commented Oct 4, 2024

🚀 This is included in version v3.0.0-beta.111

jacobsfletch added a commit that referenced this pull request Oct 7, 2024
commit 7a0609a
Author: Jacob Fletcher <[email protected]>
Date:   Mon Oct 7 10:00:34 2024 -0400

    wires abort controller into server fn provider

commit 633aaa7
Author: Jacob Fletcher <[email protected]>
Date:   Mon Oct 7 09:50:12 2024 -0400

    adjust err handling

commit 860b6cf
Author: Jacob Fletcher <[email protected]>
Date:   Mon Oct 7 09:26:01 2024 -0400

    safely accesses signal

commit 463e05d
Author: Jacob Fletcher <[email protected]>
Date:   Mon Oct 7 09:13:39 2024 -0400

    adds additional ac check prior to firing action

commit 231c4b3
Author: Jacob Fletcher <[email protected]>
Date:   Mon Oct 7 09:00:45 2024 -0400

    cleanup

commit 494c970
Author: Jacob Fletcher <[email protected]>
Date:   Mon Oct 7 08:46:28 2024 -0400

    more acs

commit 8dcb2ea
Author: Jacob Fletcher <[email protected]>
Date:   Sun Oct 6 23:33:53 2024 -0400

    adds abort controllers to docinfo and form actions

commit 0da4326
Author: Jacob Fletcher <[email protected]>
Date:   Sun Oct 6 23:05:14 2024 -0400

    adds back remaining actions

commit 292d8b5
Author: Jacob Fletcher <[email protected]>
Date:   Sun Oct 6 22:53:44 2024 -0400

    thrads abort controller to onchange

commit ca8629e
Author: Jacob Fletcher <[email protected]>
Date:   Sun Oct 6 22:02:20 2024 -0400

    reintroduces some actions

commit 5f001c0
Merge: 75dd030 2ba40f3
Author: Jacob Fletcher <[email protected]>
Date:   Sat Oct 5 09:15:25 2024 -0400

    Merge branch 'beta' into feat/server-actions

commit 2ba40f3
Author: Jacob Fletcher <[email protected]>
Date:   Sat Oct 5 09:13:43 2024 -0400

    chore: removes duplicative join field test (#8558)

    There are two of the exact same e2e tests for the join field, which
    throws an error when running these tests locally because they have
    identical names.

commit 463490f
Author: Elliot DeNolf <[email protected]>
Date:   Fri Oct 4 18:38:27 2024 -0700

    fix(templates): await params/cookies properly (#8560)

commit d564cd4
Author: Jacob Fletcher <[email protected]>
Date:   Fri Oct 4 17:29:38 2024 -0400

    chore: deflakes lexical e2e test (#8559)

    This has caused me great pain. The problem with this test is that the
    page was waiting for a URL which includes a search query that never
    arrives. This moves the check into a regex pattern for a more accurate
    catch.

commit 75dd030
Author: Jacob Fletcher <[email protected]>
Date:   Fri Oct 4 16:26:19 2024 -0400

    reverts reset back to fetch to test

commit 7c62e2a
Author: Paul <[email protected]>
Date:   Fri Oct 4 13:02:56 2024 -0600

    feat(ui)!: scope all payload css to payload-default layer (#8545)

    All payload css is now encapsulated inside CSS layers under `@layer
    payload-default`

    Any custom css will now have the highest possible specificity.
    We have also provided a new layer `@layer payload` if you want to use
    layers and ensure that your styles are applied after payload.

    To override existing styles in a way that the existing rules of
    specificity would be respected you can use the default layer like so
    ```css
    @layer payload-default {
      // my styles within the payload specificity
    }
    ```

commit 400293b
Author: Sasha <[email protected]>
Date:   Fri Oct 4 21:46:41 2024 +0300

    fix: duplicate with upload collections (#8552)

    Fixes the duplicate operation with uploads
    Enables duplicate for upload collections by default

commit e4a413e
Author: Elliot DeNolf <[email protected]>
Date:   Fri Oct 4 11:31:06 2024 -0700

    chore(release): v3.0.0-beta.111 [skip ci]

commit b99590f
Author: Sasha <[email protected]>
Date:   Fri Oct 4 21:28:43 2024 +0300

    chore(templates): update templates with next.js promises (#8547)

    Updates templates according to this PR
    #8489

commit a4704c1
Author: Jacob Fletcher <[email protected]>
Date:   Fri Oct 4 13:53:52 2024 -0400

    moves docinfo back to fetch to test

commit 0d3416c
Author: Alessio Gravili <[email protected]>
Date:   Fri Oct 4 13:39:03 2024 -0400

    fix(db-postgres): missing types for db.pool by moving @types/pg from devDependencies to dependencies (#8556)

    Fixes lack of types in installed project:

    ![CleanShot 2024-10-04 at 19 18
    58@2x](https://github.com/user-attachments/assets/e7c519ee-72fd-424b-8f6c-41032322fa5e)

    Since we expose stuff from @types/pg to the end user, we need it to be
    installed in the end users project => move to dependencies.

commit 2f6ee80
Author: Jacob Fletcher <[email protected]>
Date:   Fri Oct 4 12:54:45 2024 -0400

    changes addFieldRow back to fetch

commit 0128eed
Author: Sasha <[email protected]>
Date:   Fri Oct 4 19:25:05 2024 +0300

    fix(drizzle)!: make radio and select column names to snake_case (#8439)

    Fixes #8402 and
    #8027

    Before DB column names were camelCase:

    ![image](https://github.com/user-attachments/assets/d2965bcf-290a-4f86-9bf4-dfe7e8613934)

    After this change, they are snake_case:
    ![Screenshot 2024-10-04
    114226](https://github.com/user-attachments/assets/bbc8c20b-6745-4dd3-b0c8-56263a4e37b1)

    #### Breaking SQLite / Postgres ⚠️
    If you had any select (not `hasMany: true`) or radio fields with the
    name in camelCase, for example:
    ```ts
    {
      name: 'selectReadOnly',
      type: 'select',
      admin: {
        readOnly: true,
      },
      options: [
        {
          label: 'Value One',
          value: 'one',
        },
        {
          label: 'Value Two',
          value: 'two',
        },
      ],
    },
    ```
    This previously was mapped to the db column name `"selectReadOnly"`. Now
    it's `select_read_only`.
    Generate a new migration to rename your columns.
    ```sh
    pnpm payload migrate:create
    ```
    Then select "rename column" for targeted columns and Drizzle will handle
    the migration.

    ---------

    Co-authored-by: Dan Ribbens <[email protected]>

commit 414030e
Author: Sasha <[email protected]>
Date:   Fri Oct 4 18:48:54 2024 +0300

    fix(drizzle): row / collapsible inside of localized fields (#8539)

    Fixes #8405

commit 41efcbe
Author: Jacob Fletcher <[email protected]>
Date:   Fri Oct 4 10:02:48 2024 -0400

    build err

commit 2203d60
Author: Jacob Fletcher <[email protected]>
Date:   Fri Oct 4 08:32:13 2024 -0400

    reverts default edit view onChange

commit 2cd9594
Author: Jacob Fletcher <[email protected]>
Date:   Fri Oct 4 07:47:49 2024 -0400

    brings back actions for everything except lexical

commit cc2cad3
Author: Jacob Fletcher <[email protected]>
Date:   Fri Oct 4 00:58:35 2024 -0400

    more cleanup

commit 87e11bd
Author: Jacob Fletcher <[email protected]>
Date:   Fri Oct 4 00:20:02 2024 -0400

    remove website lockfile

commit caf4c4a
Author: Jacob Fletcher <[email protected]>
Date:   Fri Oct 4 00:12:25 2024 -0400

    properly scopes effect cleanup return

commit 3ddd972
Author: Jacob Fletcher <[email protected]>
Date:   Fri Oct 4 00:07:09 2024 -0400

    adjusts abort controllers

commit 6c95f0a
Author: Jacob Fletcher <[email protected]>
Date:   Fri Oct 4 00:00:00 2024 -0400

    fix api route

commit 9206ade
Merge: 726f8b0 f6eb027
Author: Jacob Fletcher <[email protected]>
Date:   Thu Oct 3 23:45:17 2024 -0400

    Merge branch 'beta' into feat/server-actions

commit 726f8b0
Author: Jacob Fletcher <[email protected]>
Date:   Thu Oct 3 23:11:53 2024 -0400

    again

commit 40e5571
Author: Jacob Fletcher <[email protected]>
Date:   Thu Oct 3 22:56:55 2024 -0400

    more

commit bdbe7dd
Author: Jacob Fletcher <[email protected]>
Date:   Thu Oct 3 22:10:48 2024 -0400

    temprarily brings back fetch to debug

commit 08bd461
Author: Jacob Fletcher <[email protected]>
Date:   Thu Oct 3 19:43:59 2024 -0400

    properly aborts on unmount

commit cf61776
Author: Jacob Fletcher <[email protected]>
Date:   Thu Oct 3 19:21:42 2024 -0400

    prevents signal sent from client to server

commit ee85323
Author: Jacob Fletcher <[email protected]>
Date:   Thu Oct 3 18:35:23 2024 -0400

    temp debug

commit 23cd537
Author: Jacob Fletcher <[email protected]>
Date:   Thu Oct 3 14:59:35 2024 -0400

    removes auto gen upload dirs from test

commit 0a950c0
Author: Jacob Fletcher <[email protected]>
Date:   Thu Oct 3 14:47:56 2024 -0400

    plz

commit f84822e
Author: Jacob Fletcher <[email protected]>
Date:   Thu Oct 3 13:48:10 2024 -0400

    returns errors instead of throws

commit ee577f5
Author: Jacob Fletcher <[email protected]>
Date:   Thu Oct 3 13:34:36 2024 -0400

    increases test bodysizelimit

commit 6641bff
Author: Jacob Fletcher <[email protected]>
Date:   Thu Oct 3 13:25:44 2024 -0400

    removes default server action body size limit

commit 53a6dcf
Author: Jacob Fletcher <[email protected]>
Date:   Thu Oct 3 12:49:04 2024 -0400

    plz be it

commit 9e8e7c7
Author: Jacob Fletcher <[email protected]>
Date:   Thu Oct 3 11:48:11 2024 -0400

    creates shared callback for common server fns

commit b4d081d
Author: Jacob Fletcher <[email protected]>
Date:   Thu Oct 3 09:39:40 2024 -0400

    some docs

commit bc36bf7
Author: Jacob Fletcher <[email protected]>
Date:   Wed Oct 2 16:26:25 2024 -0400

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

Successfully merging this pull request may close these issues.

2 participants