Skip to content

Commit

Permalink
Add customer_id column to users table in Prisma schema (#49)
Browse files Browse the repository at this point in the history
* Update Prisma model for User and updated migration that creates the User table

* Add customer_id to users table

---------

Co-authored-by: Jordan (Ee Hsin) <[email protected]>
  • Loading branch information
pahu2353 and Ee-Hsin authored Jul 9, 2024
1 parent 520c97a commit 408d7a9
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export const up: Migration = async ({ context: sequelize }) => {
type: DataType.ENUM("User", "Admin"),
allowNull: false,
},
customer_id: {
type: DataType.STRING,
allowNull: true,
},
createdAt: DataType.DATE,
updatedAt: DataType.DATE,
});
Expand Down
4 changes: 4 additions & 0 deletions backend/typescript/models/user.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ export default class User extends Model {

@Column({ type: DataType.ENUM("User", "Admin") })
role!: Role;

// Optional customer_id column for Stripe customer ids
@Column({ type: DataType.STRING, allowNull: true })
customer_id?: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "User" ADD COLUMN "customerID" TEXT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
Warnings:
- You are about to drop the column `customerID` on the `User` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "User" DROP COLUMN "customerID",
ADD COLUMN "customer_id" TEXT;
1 change: 1 addition & 0 deletions backend/typescript/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ model User {
updatedAt DateTime?
role RoleType
donations Donation[]
customer_id String?
}

enum RoleType {
Expand Down

0 comments on commit 408d7a9

Please sign in to comment.