2
0

🗃️ Add updatedAt fields where missing

This commit is contained in:
Baptiste Arnaud
2023-02-03 07:58:14 +01:00
parent bf607289f4
commit 0b34321bf7
10 changed files with 80 additions and 29 deletions

4
.gitignore vendored
View File

@ -32,4 +32,6 @@ dump.tar
__env.js __env.js
typebotsToFix.json typebotsToFix.json
**/scripts/logs **/scripts/logs
snapshots

View File

@ -4,7 +4,7 @@ import { sendRequest } from 'utils'
export const updateCollaboratorQuery = ( export const updateCollaboratorQuery = (
typebotId: string, typebotId: string,
userId: string, userId: string,
collaborator: CollaboratorsOnTypebots collaborator: Omit<CollaboratorsOnTypebots, 'createdAt' | 'updatedAt'>
) => ) =>
sendRequest({ sendRequest({
method: 'PATCH', method: 'PATCH',

View File

@ -4,7 +4,7 @@ import { sendRequest } from 'utils'
export const updateInvitationQuery = ( export const updateInvitationQuery = (
typebotId: string, typebotId: string,
email: string, email: string,
invitation: Omit<Invitation, 'createdAt' | 'id'> invitation: Omit<Invitation, 'createdAt' | 'id' | 'updatedAt'>
) => ) =>
sendRequest({ sendRequest({
method: 'PATCH', method: 'PATCH',

View File

@ -3,7 +3,7 @@ import { sendRequest } from 'utils'
import { Member } from '../types' import { Member } from '../types'
export const sendInvitationQuery = ( export const sendInvitationQuery = (
invitation: Omit<WorkspaceInvitation, 'id' | 'createdAt'> invitation: Omit<WorkspaceInvitation, 'id' | 'createdAt' | 'updatedAt'>
) => ) =>
sendRequest<{ invitation?: WorkspaceInvitation; member?: Member }>({ sendRequest<{ invitation?: WorkspaceInvitation; member?: Member }>({
url: `/api/workspaces/${invitation.workspaceId}/invitations`, url: `/api/workspaces/${invitation.workspaceId}/invitations`,

View File

@ -127,13 +127,17 @@
"id": { "id": {
"type": "string" "type": "string"
}, },
"name": {
"type": "string"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
}, },
"updatedAt": {
"type": "string",
"format": "date-time"
},
"name": {
"type": "string"
},
"icon": { "icon": {
"type": "string", "type": "string",
"nullable": true "nullable": true
@ -195,8 +199,9 @@
}, },
"required": [ "required": [
"id", "id",
"name",
"createdAt", "createdAt",
"updatedAt",
"name",
"icon", "icon",
"plan", "plan",
"stripeId", "stripeId",
@ -263,13 +268,17 @@
"id": { "id": {
"type": "string" "type": "string"
}, },
"name": {
"type": "string"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
}, },
"updatedAt": {
"type": "string",
"format": "date-time"
},
"name": {
"type": "string"
},
"icon": { "icon": {
"type": "string", "type": "string",
"nullable": true "nullable": true
@ -331,8 +340,9 @@
}, },
"required": [ "required": [
"id", "id",
"name",
"createdAt", "createdAt",
"updatedAt",
"name",
"icon", "icon",
"plan", "plan",
"stripeId", "stripeId",
@ -416,13 +426,17 @@
"id": { "id": {
"type": "string" "type": "string"
}, },
"name": {
"type": "string"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
}, },
"updatedAt": {
"type": "string",
"format": "date-time"
},
"name": {
"type": "string"
},
"icon": { "icon": {
"type": "string", "type": "string",
"nullable": true "nullable": true
@ -484,8 +498,9 @@
}, },
"required": [ "required": [
"id", "id",
"name",
"createdAt", "createdAt",
"updatedAt",
"name",
"icon", "icon",
"plan", "plan",
"stripeId", "stripeId",

View File

@ -0,0 +1,25 @@
/*
Warnings:
- You are about to drop the column `lastUsedAt` on the `ApiToken` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "ApiToken" DROP COLUMN "lastUsedAt";
-- AlterTable
ALTER TABLE "CollaboratorsOnTypebots" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
-- AlterTable
ALTER TABLE "Invitation" ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
-- AlterTable
ALTER TABLE "MemberInWorkspace" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
-- AlterTable
ALTER TABLE "Workspace" ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
-- AlterTable
ALTER TABLE "WorkspaceInvitation" ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;

View File

@ -57,20 +57,20 @@ model User {
} }
model ApiToken { model ApiToken {
id String @id @default(cuid()) id String @id @default(cuid())
token String @unique createdAt DateTime @default(now())
name String token String @unique
ownerId String name String
lastUsedAt DateTime @default(now()) ownerId String
createdAt DateTime @default(now()) owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
} }
model Workspace { model Workspace {
id String @id @default(cuid()) id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
name String name String
icon String? icon String?
createdAt DateTime @default(now())
plan Plan @default(FREE) plan Plan @default(FREE)
stripeId String? @unique stripeId String? @unique
credentials Credentials[] credentials Credentials[]
@ -92,6 +92,8 @@ model Workspace {
} }
model MemberInWorkspace { model MemberInWorkspace {
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
userId String userId String
workspaceId String workspaceId String
role WorkspaceRole role WorkspaceRole
@ -104,6 +106,7 @@ model MemberInWorkspace {
model WorkspaceInvitation { model WorkspaceInvitation {
id String @id @default(cuid()) id String @id @default(cuid())
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
email String email String
workspaceId String workspaceId String
type WorkspaceRole type WorkspaceRole
@ -180,6 +183,7 @@ model Typebot {
model Invitation { model Invitation {
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
email String email String
typebotId String typebotId String
type CollaborationType type CollaborationType
@ -189,6 +193,8 @@ model Invitation {
} }
model CollaboratorsOnTypebots { model CollaboratorsOnTypebots {
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
userId String userId String
typebotId String typebotId String
type CollaborationType type CollaborationType
@ -240,7 +246,7 @@ model Log {
} }
model Answer { model Answer {
createdAt DateTime @default(now()) createdAt DateTime @default(now()) @updatedAt
resultId String resultId String
blockId String blockId String
groupId String groupId String

View File

@ -19,6 +19,7 @@ export const answerInputSchema =
answerSchema answerSchema
.omit({ .omit({
createdAt: true, createdAt: true,
updatedAt: true,
resultId: true, resultId: true,
variableId: true, variableId: true,
storageUsed: true, storageUsed: true,

View File

@ -30,7 +30,7 @@ export type WebhookResponse = {
export const defaultWebhookAttributes: Omit< export const defaultWebhookAttributes: Omit<
Webhook, Webhook,
'id' | 'body' | 'url' | 'typebotId' 'id' | 'body' | 'url' | 'typebotId' | 'createdAt' | 'updatedAt'
> = { > = {
method: HttpMethod.POST, method: HttpMethod.POST,
headers: [], headers: [],

View File

@ -10,7 +10,7 @@ import {
} from 'db' } from 'db'
export const workspaceMemberSchema = schemaForType< export const workspaceMemberSchema = schemaForType<
Omit<MemberInWorkspacePrisma, 'userId'> & { Omit<MemberInWorkspacePrisma, 'userId' | 'createdAt' | 'updatedAt'> & {
user: Pick<UserPrisma, 'name' | 'email' | 'image'> user: Pick<UserPrisma, 'name' | 'email' | 'image'>
} }
>()( >()(
@ -29,17 +29,19 @@ export const workspaceInvitationSchema = schemaForType<
Omit<WorkspaceInvitationPrisma, 'workspaceId' | 'userId' | 'id'> Omit<WorkspaceInvitationPrisma, 'workspaceId' | 'userId' | 'id'>
>()( >()(
z.object({ z.object({
createdAt: z.date(),
updatedAt: z.date(),
email: z.string(), email: z.string(),
type: z.nativeEnum(WorkspaceRole), type: z.nativeEnum(WorkspaceRole),
createdAt: z.date(),
}) })
) )
export const workspaceSchema = schemaForType<WorkspacePrisma>()( export const workspaceSchema = schemaForType<WorkspacePrisma>()(
z.object({ z.object({
id: z.string(), id: z.string(),
name: z.string(),
createdAt: z.date(), createdAt: z.date(),
updatedAt: z.date(),
name: z.string(),
icon: z.string().nullable(), icon: z.string().nullable(),
plan: z.nativeEnum(Plan), plan: z.nativeEnum(Plan),
stripeId: z.string().nullable(), stripeId: z.string().nullable(),