[GH-ISSUE #121] feat: Support typed additional fields on core tables #8136

Closed
opened 2026-04-13 03:12:51 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @Bekacru on GitHub (Oct 8, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/121

Originally assigned to: @Bekacru on GitHub.

Allow custom fields to be added to the user and session tables, with potential support for organization as well. This functionality could be implemented as a plugin, as it requires configuration on both the client and server sides.

Originally created by @Bekacru on GitHub (Oct 8, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/121 Originally assigned to: @Bekacru on GitHub. Allow custom fields to be added to the `user` and `session` tables, with potential support for `organization` as well. This functionality could be implemented as a plugin, as it requires configuration on both the client and server sides.
GiteaMirror added the lockedenhancement labels 2026-04-13 03:12:51 -05:00
Author
Owner

@emroot commented on GitHub (Oct 9, 2024):

it would be interesting to take some inspiration from next-auth for this.
https://github.com/nextauthjs/next-auth/blob/main/packages/adapter-prisma/src/index.ts
It provides enough flexibility for devs to override those function and let them do what they need.
I'm currently using next-auth and override some of those functions to populate extra columns.
example usage with next-auth

...adapter: {
    ...PrismaAdapter(prismaClient),
    createUser(user) {
      return db.user.create({
        data: {
          ...user,
          customColumn: 'test'
        },
      });
    },

    deleteUser(userId) {
      return db.user.update({
        where: {
          id: userId,
        },
        data: {
          deletedAt: new Date(),
          isDeleted: true,
        },
      });
    },
    async getUser(id) {
      return db.user.findFirst({
        where: { id, isDeleted: false },
      });
    },
    async getUserByEmail(email) {
      return db.user.findFirst({
        where: { email, isDeleted: false },
      });
    },
    // },
  },
<!-- gh-comment-id:2401316346 --> @emroot commented on GitHub (Oct 9, 2024): it would be interesting to take some inspiration from next-auth for this. https://github.com/nextauthjs/next-auth/blob/main/packages/adapter-prisma/src/index.ts It provides enough flexibility for devs to override those function and let them do what they need. I'm currently using next-auth and override some of those functions to populate extra columns. example usage with next-auth ``` ...adapter: { ...PrismaAdapter(prismaClient), createUser(user) { return db.user.create({ data: { ...user, customColumn: 'test' }, }); }, deleteUser(userId) { return db.user.update({ where: { id: userId, }, data: { deletedAt: new Date(), isDeleted: true, }, }); }, async getUser(id) { return db.user.findFirst({ where: { id, isDeleted: false }, }); }, async getUserByEmail(email) { return db.user.findFirst({ where: { email, isDeleted: false }, }); }, // }, }, ```
Author
Owner

@andrewcoelho commented on GitHub (Oct 29, 2024):

@Bekacru are there any plans for supporting this on organizations as well?

<!-- gh-comment-id:2444750863 --> @andrewcoelho commented on GitHub (Oct 29, 2024): @Bekacru are there any plans for supporting this on organizations as well?
Author
Owner

@bhaleraosaurabh commented on GitHub (Jan 5, 2025):

@Bekacru I have the same question as @andrewcoelho.

At the moment, I've just added new columns to the table in my prisma schema as optional fields and created a separate endpoint through which I'm able to use the additional columns for updating the organization.

It would be nice if we could extend the schema for plugins like organization. Came here looking for an answer to the same question as I need to extend the organization table. Are there any plans to support this feature?

<!-- gh-comment-id:2571631402 --> @bhaleraosaurabh commented on GitHub (Jan 5, 2025): @Bekacru I have the same question as @andrewcoelho. At the moment, I've just added new columns to the table in my prisma schema as optional fields and created a separate endpoint through which I'm able to use the additional columns for updating the organization. It would be nice if we could extend the schema for plugins like organization. Came here looking for an answer to the same question as I need to extend the organization table. Are there any plans to support this feature?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8136