create-crm-tmp 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/bin/create-crm-tmp.js +56 -35
  2. package/package.json +1 -1
  3. package/template/README.md +230 -115
  4. package/template/eslint.config.mjs +13 -0
  5. package/template/next.config.ts +14 -0
  6. package/template/package.json +15 -2
  7. package/template/prisma/migrations/20260318095700_init_db/migration.sql +978 -0
  8. package/template/prisma/migrations/migration_lock.toml +3 -0
  9. package/template/prisma/schema.prisma +132 -637
  10. package/template/src/app/(auth)/invite/[token]/page.tsx +10 -8
  11. package/template/src/app/(auth)/layout.tsx +1 -1
  12. package/template/src/app/(auth)/reset-password/complete/page.tsx +11 -8
  13. package/template/src/app/(auth)/reset-password/page.tsx +4 -4
  14. package/template/src/app/(auth)/reset-password/verify/page.tsx +4 -4
  15. package/template/src/app/(auth)/signin/page.tsx +14 -6
  16. package/template/src/app/(dashboard)/agenda/page.tsx +2243 -988
  17. package/template/src/app/(dashboard)/automatisation/_components/workflow-editor.tsx +18 -104
  18. package/template/src/app/(dashboard)/automatisation/page.tsx +10 -26
  19. package/template/src/app/(dashboard)/closing/page.tsx +78 -62
  20. package/template/src/app/(dashboard)/contacts/[id]/page.tsx +2082 -1080
  21. package/template/src/app/(dashboard)/contacts/companies/[id]/page.tsx +46 -47
  22. package/template/src/app/(dashboard)/contacts/page.tsx +1062 -780
  23. package/template/src/app/(dashboard)/dashboard/page.tsx +533 -37
  24. package/template/src/app/(dashboard)/dev/page.tsx +1291 -0
  25. package/template/src/app/(dashboard)/layout.tsx +6 -2
  26. package/template/src/app/(dashboard)/settings/page.tsx +797 -2582
  27. package/template/src/app/(dashboard)/templates/page.tsx +55 -54
  28. package/template/src/app/(dashboard)/users/list/page.tsx +51 -48
  29. package/template/src/app/(dashboard)/users/page.tsx +1 -1
  30. package/template/src/app/(dashboard)/users/permissions/page.tsx +2 -2
  31. package/template/src/app/(dashboard)/users/roles/page.tsx +7 -5
  32. package/template/src/app/api/agenda/google-events/route.ts +92 -0
  33. package/template/src/app/api/auth/check-active/route.ts +3 -2
  34. package/template/src/app/api/auth/google/route.ts +2 -1
  35. package/template/src/app/api/auth/google/status/route.ts +7 -31
  36. package/template/src/app/api/companies/[id]/activities/route.ts +1 -3
  37. package/template/src/app/api/companies/[id]/route.ts +1 -2
  38. package/template/src/app/api/companies/route.ts +42 -12
  39. package/template/src/app/api/contacts/[id]/files/[fileId]/preview/route.ts +9 -31
  40. package/template/src/app/api/contacts/[id]/files/[fileId]/route.ts +14 -32
  41. package/template/src/app/api/contacts/[id]/files/route.ts +112 -212
  42. package/template/src/app/api/contacts/[id]/interactions/[interactionId]/route.ts +27 -1
  43. package/template/src/app/api/contacts/[id]/interactions/route.ts +16 -16
  44. package/template/src/app/api/contacts/[id]/kyc/route.ts +21 -11
  45. package/template/src/app/api/contacts/[id]/meet/route.ts +19 -2
  46. package/template/src/app/api/contacts/[id]/route.ts +106 -34
  47. package/template/src/app/api/contacts/[id]/send-email/route.ts +27 -11
  48. package/template/src/app/api/contacts/[id]/workflows/run/route.ts +6 -0
  49. package/template/src/app/api/contacts/export/route.ts +9 -13
  50. package/template/src/app/api/contacts/import/route.ts +55 -25
  51. package/template/src/app/api/contacts/import-preview/route.ts +1 -1
  52. package/template/src/app/api/contacts/origins/route.ts +63 -0
  53. package/template/src/app/api/contacts/route.ts +153 -41
  54. package/template/src/app/api/cron/cleanup-editor-images/route.ts +166 -0
  55. package/template/src/app/api/dashboard/widgets/[id]/route.ts +44 -0
  56. package/template/src/app/api/dashboard/widgets/route.ts +181 -0
  57. package/template/src/app/api/dev/reminders/test/route.ts +114 -0
  58. package/template/src/app/api/editor/upload-image/route.ts +61 -0
  59. package/template/src/app/api/integrations/google-sheet/jobs/[jobId]/route.ts +47 -0
  60. package/template/src/app/api/integrations/google-sheet/jobs/usage/route.ts +50 -0
  61. package/template/src/app/api/integrations/google-sheet/sync/route.ts +24 -556
  62. package/template/src/app/api/jobs/google-sheet/process/route.ts +84 -0
  63. package/template/src/app/api/jobs/google-sheet/schedule/route.ts +50 -0
  64. package/template/src/app/api/reminders/clear/route.ts +120 -0
  65. package/template/src/app/api/reminders/clear/undo/route.ts +112 -0
  66. package/template/src/app/api/reminders/route.ts +164 -39
  67. package/template/src/app/api/reminders/state/route.ts +164 -0
  68. package/template/src/app/api/reset-password/request/route.ts +1 -1
  69. package/template/src/app/api/reset-password/verify/route.ts +1 -1
  70. package/template/src/app/api/send/route.ts +16 -4
  71. package/template/src/app/api/settings/google-ads/route.ts +14 -0
  72. package/template/src/app/api/settings/google-calendar/calendars/route.ts +97 -0
  73. package/template/src/app/api/settings/google-calendar/route.ts +124 -0
  74. package/template/src/app/api/settings/google-sheet/[id]/route.ts +28 -0
  75. package/template/src/app/api/settings/google-sheet/auto-map/route.ts +37 -4
  76. package/template/src/app/api/settings/google-sheet/preview/route.ts +9 -3
  77. package/template/src/app/api/settings/google-sheet/route.ts +14 -0
  78. package/template/src/app/api/settings/integrations/logs/route.ts +93 -0
  79. package/template/src/app/api/settings/integrations/notifications/route.ts +67 -0
  80. package/template/src/app/api/settings/meta-leads/[id]/route.ts +0 -1
  81. package/template/src/app/api/settings/meta-leads/route.ts +14 -2
  82. package/template/src/app/api/settings/smtp/route.ts +53 -6
  83. package/template/src/app/api/tasks/[id]/attendees/route.ts +24 -8
  84. package/template/src/app/api/tasks/[id]/route.ts +234 -58
  85. package/template/src/app/api/tasks/meet/route.ts +27 -19
  86. package/template/src/app/api/tasks/route.ts +62 -17
  87. package/template/src/app/api/users/[id]/route.ts +20 -14
  88. package/template/src/app/api/users/list/route.ts +57 -19
  89. package/template/src/app/api/webhooks/google-ads/route.ts +34 -14
  90. package/template/src/app/api/webhooks/meta-leads/route.ts +32 -12
  91. package/template/src/app/api/workflows/[id]/route.ts +0 -4
  92. package/template/src/app/api/workflows/process/route.ts +22 -51
  93. package/template/src/app/api/workflows/route.ts +0 -4
  94. package/template/src/app/globals.css +342 -4
  95. package/template/src/app/layout.tsx +11 -3
  96. package/template/src/app/page.tsx +1 -1
  97. package/template/src/components/address-autocomplete.tsx +7 -6
  98. package/template/src/components/config-error-alert.tsx +46 -0
  99. package/template/src/components/contacts/filter-bar.tsx +12 -3
  100. package/template/src/components/contacts/filter-builder.tsx +28 -43
  101. package/template/src/components/contacts/save-view-dialog.tsx +1 -1
  102. package/template/src/components/contacts/views-tab-bar.tsx +15 -6
  103. package/template/src/components/dashboard/activity-chart.tsx +41 -28
  104. package/template/src/components/dashboard/add-widget-dialog.tsx +157 -0
  105. package/template/src/components/dashboard/color-picker.tsx +64 -0
  106. package/template/src/components/dashboard/contacts-chart.tsx +69 -0
  107. package/template/src/components/dashboard/interactions-by-type-chart.tsx +121 -0
  108. package/template/src/components/dashboard/recent-activity.tsx +154 -0
  109. package/template/src/components/dashboard/stat-card.tsx +40 -40
  110. package/template/src/components/dashboard/status-distribution-chart.tsx +81 -0
  111. package/template/src/components/dashboard/tasks-pie-chart.tsx +37 -34
  112. package/template/src/components/dashboard/top-contacts-list.tsx +113 -0
  113. package/template/src/components/dashboard/upcoming-tasks-list.tsx +72 -81
  114. package/template/src/components/dashboard/widget-wrapper.tsx +36 -0
  115. package/template/src/components/date-picker.tsx +9 -6
  116. package/template/src/components/editor/upload-editor-image.ts +42 -0
  117. package/template/src/components/editor.tsx +161 -22
  118. package/template/src/components/email-template.tsx +2 -2
  119. package/template/src/components/global-search.tsx +30 -28
  120. package/template/src/components/header.tsx +178 -80
  121. package/template/src/components/inactive-account-guard.tsx +58 -0
  122. package/template/src/components/integration-notifications-listener.tsx +12 -0
  123. package/template/src/components/invitation-email-template.tsx +2 -2
  124. package/template/src/components/meet-cancellation-email-template.tsx +3 -3
  125. package/template/src/components/meet-confirmation-email-template.tsx +3 -3
  126. package/template/src/components/meet-update-email-template.tsx +3 -3
  127. package/template/src/components/page-header.tsx +5 -5
  128. package/template/src/components/protected-page.tsx +1 -1
  129. package/template/src/components/reset-password-email-template.tsx +2 -2
  130. package/template/src/components/settings/integrations/GoogleAdsIntegration.tsx +428 -0
  131. package/template/src/components/settings/integrations/GoogleSheetConfigMonitoringModal.tsx +680 -0
  132. package/template/src/components/settings/integrations/GoogleSheetIntegration.tsx +809 -0
  133. package/template/src/components/settings/integrations/ImportResultDialog.tsx +124 -0
  134. package/template/src/components/settings/integrations/IntegrationLogPanel.tsx +57 -0
  135. package/template/src/components/settings/integrations/IntegrationLogsTable.tsx +186 -0
  136. package/template/src/components/settings/integrations/MetaLeadIntegration.tsx +451 -0
  137. package/template/src/components/sidebar.tsx +45 -26
  138. package/template/src/components/skeleton.tsx +40 -43
  139. package/template/src/components/ui/accordion.tsx +2 -2
  140. package/template/src/components/ui/alert-dialog.tsx +1 -1
  141. package/template/src/components/ui/button.tsx +20 -9
  142. package/template/src/components/ui/components.tsx +1 -1
  143. package/template/src/components/ui/date-picker.tsx +422 -0
  144. package/template/src/components/ui/datetime-picker.tsx +338 -0
  145. package/template/src/components/ui/status-select.tsx +271 -0
  146. package/template/src/components/ui/tooltip.tsx +37 -0
  147. package/template/src/components/view-as-modal.tsx +13 -7
  148. package/template/src/contexts/app-toast-context.tsx +245 -57
  149. package/template/src/contexts/dashboard-theme-context.tsx +53 -0
  150. package/template/src/contexts/sidebar-context.tsx +22 -17
  151. package/template/src/contexts/task-reminder-context.tsx +134 -160
  152. package/template/src/contexts/view-as-context.tsx +33 -6
  153. package/template/src/hooks/use-focus-trap.ts +2 -2
  154. package/template/src/hooks/useIntegrationNotifications.ts +49 -0
  155. package/template/src/lib/auth.ts +8 -1
  156. package/template/src/lib/config-links.ts +14 -0
  157. package/template/src/lib/contact-duplicate.ts +79 -61
  158. package/template/src/lib/contact-interactions.ts +21 -21
  159. package/template/src/lib/contact-view-filters.ts +24 -64
  160. package/template/src/lib/contacts-list-url.ts +190 -0
  161. package/template/src/lib/dashboard-stats.ts +65 -7
  162. package/template/src/lib/dashboard-themes.ts +135 -0
  163. package/template/src/lib/date-utils.ts +127 -0
  164. package/template/src/lib/default-widgets.ts +12 -0
  165. package/template/src/lib/editor-html-image-dimensions.ts +172 -0
  166. package/template/src/lib/editor-image-limits.ts +19 -0
  167. package/template/src/lib/email-html-sanitize.ts +19 -0
  168. package/template/src/lib/encryption.ts +9 -6
  169. package/template/src/lib/fr-geography.ts +192 -0
  170. package/template/src/lib/google-calendar-agenda.ts +201 -0
  171. package/template/src/lib/google-calendar.ts +255 -5
  172. package/template/src/lib/google-sheet-sync-jobs.ts +96 -0
  173. package/template/src/lib/google-sheet-sync-runner.ts +514 -0
  174. package/template/src/lib/integration-import-log.ts +21 -0
  175. package/template/src/lib/permissions.ts +40 -10
  176. package/template/src/lib/prisma.ts +4 -1
  177. package/template/src/lib/qstash.ts +65 -0
  178. package/template/src/lib/reminder-state-server.ts +80 -0
  179. package/template/src/lib/reminder-state.ts +29 -0
  180. package/template/src/lib/supabase-storage.ts +113 -0
  181. package/template/src/lib/template-variables.ts +164 -23
  182. package/template/src/lib/utils.ts +45 -0
  183. package/template/src/lib/widget-registry.ts +173 -0
  184. package/template/src/lib/workflow-executor.ts +16 -70
  185. package/template/src/proxy.ts +1 -0
  186. package/template/vercel.json +3 -10
  187. package/template/skills-lock.json +0 -25
  188. package/template/src/components/dashboard/dashboard-content.tsx +0 -79
  189. package/template/src/lib/google-drive.ts +0 -1101
  190. package/template/src/types/yousign.ts +0 -52
@@ -0,0 +1,978 @@
1
+ -- CreateEnum
2
+ CREATE TYPE "Role" AS ENUM ('USER', 'ADMIN', 'MANAGER', 'COMMERCIAL', 'TELEPRO', 'COMPTABLE');
3
+
4
+ -- CreateEnum
5
+ CREATE TYPE "ReminderStateStatus" AS ENUM ('UNREAD', 'READ', 'DISMISSED', 'CLEARED');
6
+
7
+ -- CreateEnum
8
+ CREATE TYPE "Civility" AS ENUM ('M', 'MME', 'MLLE');
9
+
10
+ -- CreateEnum
11
+ CREATE TYPE "InteractionType" AS ENUM ('CALL', 'SMS', 'EMAIL', 'MEETING', 'NOTE', 'TASK', 'STATUS_CHANGE', 'CONTACT_UPDATE', 'APPOINTMENT_CREATED', 'APPOINTMENT_DELETED', 'APPOINTMENT_CHANGED', 'ASSIGNMENT_CHANGE', 'FILE_UPLOADED', 'FILE_REPLACED', 'FILE_DELETED');
12
+
13
+ -- CreateEnum
14
+ CREATE TYPE "TaskType" AS ENUM ('CALL', 'MEETING', 'EMAIL', 'VIDEO_CONFERENCE', 'OTHER', 'TASK', 'PHYSICAL_APPOINTMENT');
15
+
16
+ -- CreateEnum
17
+ CREATE TYPE "TaskPriority" AS ENUM ('LOW', 'MEDIUM', 'HIGH', 'URGENT');
18
+
19
+ -- CreateEnum
20
+ CREATE TYPE "TemplateType" AS ENUM ('EMAIL', 'SMS', 'NOTE');
21
+
22
+ -- CreateEnum
23
+ CREATE TYPE "WorkflowTriggerType" AS ENUM ('CONTACT_CREATED', 'STATUS_CHANGED', 'TIME_BASED', 'MANUAL', 'TASK_COMPLETED', 'CONTACT_ASSIGNMENT_CHANGED');
24
+
25
+ -- CreateEnum
26
+ CREATE TYPE "WorkflowTimeReference" AS ENUM ('CONTACT_CREATED_DATE', 'LAST_STATUS_CHANGE', 'LAST_INTERACTION');
27
+
28
+ -- CreateEnum
29
+ CREATE TYPE "WorkflowActionType" AS ENUM ('SEND_EMAIL', 'SEND_SMS', 'CHANGE_STATUS', 'CREATE_TASK', 'WAIT', 'ASSIGN_CONTACT', 'ADD_NOTE', 'NOTIFY_USER');
30
+
31
+ -- CreateEnum
32
+ CREATE TYPE "WorkflowConditionOperator" AS ENUM ('EQUALS', 'NOT_EQUALS');
33
+
34
+ -- CreateEnum
35
+ CREATE TYPE "GoogleSheetSyncJobStatus" AS ENUM ('QUEUED', 'RUNNING', 'SUCCEEDED', 'FAILED');
36
+
37
+ -- CreateEnum
38
+ CREATE TYPE "GoogleSheetSyncJobTriggerType" AS ENUM ('MANUAL', 'SCHEDULED');
39
+
40
+ -- CreateTable
41
+ CREATE TABLE "custom_role" (
42
+ "id" TEXT NOT NULL,
43
+ "name" TEXT NOT NULL,
44
+ "description" TEXT,
45
+ "permissions" JSONB NOT NULL,
46
+ "isSystem" BOOLEAN NOT NULL DEFAULT false,
47
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
48
+ "updatedAt" TIMESTAMP(3) NOT NULL,
49
+
50
+ CONSTRAINT "custom_role_pkey" PRIMARY KEY ("id")
51
+ );
52
+
53
+ -- CreateTable
54
+ CREATE TABLE "user" (
55
+ "id" TEXT NOT NULL,
56
+ "name" TEXT NOT NULL,
57
+ "email" TEXT NOT NULL,
58
+ "emailVerified" BOOLEAN NOT NULL DEFAULT false,
59
+ "active" BOOLEAN NOT NULL DEFAULT true,
60
+ "image" TEXT,
61
+ "role" "Role" NOT NULL DEFAULT 'USER',
62
+ "customRoleId" TEXT,
63
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
64
+ "updatedAt" TIMESTAMP(3) NOT NULL,
65
+
66
+ CONSTRAINT "user_pkey" PRIMARY KEY ("id")
67
+ );
68
+
69
+ -- CreateTable
70
+ CREATE TABLE "audit_log" (
71
+ "id" TEXT NOT NULL,
72
+ "actorId" TEXT,
73
+ "targetUserId" TEXT,
74
+ "action" TEXT NOT NULL,
75
+ "entityType" TEXT NOT NULL,
76
+ "entityId" TEXT,
77
+ "metadata" JSONB,
78
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
79
+
80
+ CONSTRAINT "audit_log_pkey" PRIMARY KEY ("id")
81
+ );
82
+
83
+ -- CreateTable
84
+ CREATE TABLE "session" (
85
+ "id" TEXT NOT NULL,
86
+ "expiresAt" TIMESTAMP(3) NOT NULL,
87
+ "token" TEXT NOT NULL,
88
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
89
+ "updatedAt" TIMESTAMP(3) NOT NULL,
90
+ "ipAddress" TEXT,
91
+ "userAgent" TEXT,
92
+ "userId" TEXT NOT NULL,
93
+
94
+ CONSTRAINT "session_pkey" PRIMARY KEY ("id")
95
+ );
96
+
97
+ -- CreateTable
98
+ CREATE TABLE "account" (
99
+ "id" TEXT NOT NULL,
100
+ "accountId" TEXT NOT NULL,
101
+ "providerId" TEXT NOT NULL,
102
+ "userId" TEXT NOT NULL,
103
+ "accessToken" TEXT,
104
+ "refreshToken" TEXT,
105
+ "idToken" TEXT,
106
+ "accessTokenExpiresAt" TIMESTAMP(3),
107
+ "refreshTokenExpiresAt" TIMESTAMP(3),
108
+ "scope" TEXT,
109
+ "password" TEXT,
110
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
111
+ "updatedAt" TIMESTAMP(3) NOT NULL,
112
+
113
+ CONSTRAINT "account_pkey" PRIMARY KEY ("id")
114
+ );
115
+
116
+ -- CreateTable
117
+ CREATE TABLE "verification" (
118
+ "id" TEXT NOT NULL,
119
+ "identifier" TEXT NOT NULL,
120
+ "value" TEXT NOT NULL,
121
+ "expiresAt" TIMESTAMP(3) NOT NULL,
122
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
123
+ "updatedAt" TIMESTAMP(3) NOT NULL,
124
+
125
+ CONSTRAINT "verification_pkey" PRIMARY KEY ("id")
126
+ );
127
+
128
+ -- CreateTable
129
+ CREATE TABLE "company" (
130
+ "id" TEXT NOT NULL DEFAULT 'company',
131
+ "name" TEXT,
132
+ "legalRepresentative" TEXT,
133
+ "address" TEXT,
134
+ "city" TEXT,
135
+ "postalCode" TEXT,
136
+ "country" TEXT,
137
+ "phone" TEXT,
138
+ "email" TEXT,
139
+ "website" TEXT,
140
+ "siret" TEXT,
141
+ "vatNumber" TEXT,
142
+ "logo" TEXT,
143
+ "cerfaTemplateFileId" TEXT,
144
+ "contractTemplateFileId" TEXT,
145
+ "signaturePosition" JSONB,
146
+ "retractionPosition" JSONB,
147
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
148
+ "updatedAt" TIMESTAMP(3) NOT NULL,
149
+
150
+ CONSTRAINT "company_pkey" PRIMARY KEY ("id")
151
+ );
152
+
153
+ -- CreateTable
154
+ CREATE TABLE "companies" (
155
+ "id" TEXT NOT NULL,
156
+ "name" TEXT NOT NULL,
157
+ "phone" TEXT,
158
+ "email" TEXT,
159
+ "address" TEXT,
160
+ "city" TEXT,
161
+ "postalCode" TEXT,
162
+ "website" TEXT,
163
+ "siret" TEXT,
164
+ "industry" TEXT,
165
+ "notes" TEXT,
166
+ "assignedCommercialId" TEXT,
167
+ "assignedTeleproId" TEXT,
168
+ "createdById" TEXT,
169
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
170
+ "updatedAt" TIMESTAMP(3) NOT NULL,
171
+
172
+ CONSTRAINT "companies_pkey" PRIMARY KEY ("id")
173
+ );
174
+
175
+ -- CreateTable
176
+ CREATE TABLE "company_activity" (
177
+ "id" TEXT NOT NULL,
178
+ "companyId" TEXT NOT NULL,
179
+ "type" TEXT NOT NULL,
180
+ "title" TEXT,
181
+ "content" TEXT NOT NULL,
182
+ "metadata" JSONB,
183
+ "userId" TEXT,
184
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
185
+
186
+ CONSTRAINT "company_activity_pkey" PRIMARY KEY ("id")
187
+ );
188
+
189
+ -- CreateTable
190
+ CREATE TABLE "smtp_config" (
191
+ "id" TEXT NOT NULL,
192
+ "userId" TEXT NOT NULL,
193
+ "host" TEXT NOT NULL,
194
+ "port" INTEGER NOT NULL,
195
+ "secure" BOOLEAN NOT NULL DEFAULT false,
196
+ "username" TEXT NOT NULL,
197
+ "password" TEXT NOT NULL,
198
+ "fromEmail" TEXT NOT NULL,
199
+ "fromName" TEXT,
200
+ "signature" TEXT,
201
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
202
+ "updatedAt" TIMESTAMP(3) NOT NULL,
203
+
204
+ CONSTRAINT "smtp_config_pkey" PRIMARY KEY ("id")
205
+ );
206
+
207
+ -- CreateTable
208
+ CREATE TABLE "status" (
209
+ "id" TEXT NOT NULL,
210
+ "name" TEXT NOT NULL,
211
+ "color" TEXT NOT NULL,
212
+ "order" INTEGER NOT NULL DEFAULT 0,
213
+ "isSystem" BOOLEAN NOT NULL DEFAULT false,
214
+ "requiresClosingReason" BOOLEAN NOT NULL DEFAULT false,
215
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
216
+ "updatedAt" TIMESTAMP(3) NOT NULL,
217
+
218
+ CONSTRAINT "status_pkey" PRIMARY KEY ("id")
219
+ );
220
+
221
+ -- CreateTable
222
+ CREATE TABLE "contact" (
223
+ "id" TEXT NOT NULL,
224
+ "civility" "Civility",
225
+ "firstName" TEXT,
226
+ "lastName" TEXT,
227
+ "phone" TEXT NOT NULL,
228
+ "secondaryPhone" TEXT,
229
+ "email" TEXT,
230
+ "address" TEXT,
231
+ "city" TEXT,
232
+ "postalCode" TEXT,
233
+ "origin" TEXT,
234
+ "companyName" TEXT,
235
+ "companyId" TEXT,
236
+ "jobTitle" TEXT,
237
+ "website" TEXT,
238
+ "socialNetworks" JSONB,
239
+ "statusId" TEXT,
240
+ "closingReason" TEXT,
241
+ "assignedCommercialId" TEXT,
242
+ "assignedTeleproId" TEXT,
243
+ "createdById" TEXT,
244
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
245
+ "updatedAt" TIMESTAMP(3) NOT NULL,
246
+ "placeOfBirth" TEXT,
247
+ "dateOfBirth" TIMESTAMP(3),
248
+ "idType" TEXT,
249
+ "idNumber" TEXT,
250
+ "idExpiryDate" TIMESTAMP(3),
251
+ "idDocumentUrl" TEXT,
252
+ "idVerifiedByAdmin" BOOLEAN NOT NULL DEFAULT false,
253
+
254
+ CONSTRAINT "contact_pkey" PRIMARY KEY ("id")
255
+ );
256
+
257
+ -- CreateTable
258
+ CREATE TABLE "interaction" (
259
+ "id" TEXT NOT NULL,
260
+ "contactId" TEXT NOT NULL,
261
+ "type" "InteractionType" NOT NULL,
262
+ "title" TEXT,
263
+ "content" TEXT NOT NULL,
264
+ "metadata" JSONB,
265
+ "userId" TEXT,
266
+ "date" TIMESTAMP(3),
267
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
268
+ "updatedAt" TIMESTAMP(3) NOT NULL,
269
+
270
+ CONSTRAINT "interaction_pkey" PRIMARY KEY ("id")
271
+ );
272
+
273
+ -- CreateTable
274
+ CREATE TABLE "email_tracking" (
275
+ "id" TEXT NOT NULL,
276
+ "interactionId" TEXT NOT NULL,
277
+ "openCount" INTEGER NOT NULL DEFAULT 0,
278
+ "firstOpenedAt" TIMESTAMP(3),
279
+ "lastOpenedAt" TIMESTAMP(3),
280
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
281
+ "updatedAt" TIMESTAMP(3) NOT NULL,
282
+
283
+ CONSTRAINT "email_tracking_pkey" PRIMARY KEY ("id")
284
+ );
285
+
286
+ -- CreateTable
287
+ CREATE TABLE "task" (
288
+ "id" TEXT NOT NULL,
289
+ "contactId" TEXT,
290
+ "type" "TaskType" NOT NULL,
291
+ "title" TEXT,
292
+ "description" TEXT NOT NULL,
293
+ "priority" "TaskPriority" NOT NULL DEFAULT 'MEDIUM',
294
+ "scheduledAt" TIMESTAMP(3) NOT NULL,
295
+ "reminderMinutesBefore" INTEGER,
296
+ "assignedUserId" TEXT,
297
+ "createdById" TEXT,
298
+ "completed" BOOLEAN NOT NULL DEFAULT false,
299
+ "completedAt" TIMESTAMP(3),
300
+ "googleEventId" TEXT,
301
+ "googleCalendarId" TEXT,
302
+ "googleMeetLink" TEXT,
303
+ "durationMinutes" INTEGER,
304
+ "internalNote" TEXT,
305
+ "notifyContact" BOOLEAN,
306
+ "location" TEXT,
307
+ "locationAddress" TEXT,
308
+ "locationCity" TEXT,
309
+ "locationPostalCode" TEXT,
310
+ "isAtHome" BOOLEAN NOT NULL DEFAULT false,
311
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
312
+ "updatedAt" TIMESTAMP(3) NOT NULL,
313
+
314
+ CONSTRAINT "task_pkey" PRIMARY KEY ("id")
315
+ );
316
+
317
+ -- CreateTable
318
+ CREATE TABLE "user_reminder_state" (
319
+ "id" TEXT NOT NULL,
320
+ "userId" TEXT NOT NULL,
321
+ "reminderId" TEXT NOT NULL,
322
+ "status" "ReminderStateStatus" NOT NULL,
323
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
324
+ "updatedAt" TIMESTAMP(3) NOT NULL,
325
+ "expiresAt" TIMESTAMP(3),
326
+ "clearedCutoffAt" TIMESTAMP(3),
327
+ "metadata" JSONB,
328
+
329
+ CONSTRAINT "user_reminder_state_pkey" PRIMARY KEY ("id")
330
+ );
331
+
332
+ -- CreateTable
333
+ CREATE TABLE "user_google_account" (
334
+ "id" TEXT NOT NULL,
335
+ "userId" TEXT NOT NULL,
336
+ "accessToken" TEXT NOT NULL,
337
+ "refreshToken" TEXT NOT NULL,
338
+ "tokenExpiresAt" TIMESTAMP(3) NOT NULL,
339
+ "email" TEXT,
340
+ "defaultGoogleCalendarId" TEXT,
341
+ "agendaVisibleGoogleCalendarIds" JSONB,
342
+ "agendaGoogleEventColor" TEXT,
343
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
344
+ "updatedAt" TIMESTAMP(3) NOT NULL,
345
+
346
+ CONSTRAINT "user_google_account_pkey" PRIMARY KEY ("id")
347
+ );
348
+
349
+ -- CreateTable
350
+ CREATE TABLE "contact_file" (
351
+ "id" TEXT NOT NULL,
352
+ "contactId" TEXT NOT NULL,
353
+ "fileName" TEXT NOT NULL,
354
+ "fileSize" INTEGER NOT NULL,
355
+ "mimeType" TEXT NOT NULL,
356
+ "storagePath" TEXT NOT NULL,
357
+ "uploadedById" TEXT,
358
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
359
+ "updatedAt" TIMESTAMP(3) NOT NULL,
360
+
361
+ CONSTRAINT "contact_file_pkey" PRIMARY KEY ("id")
362
+ );
363
+
364
+ -- CreateTable
365
+ CREATE TABLE "meta_lead_config" (
366
+ "id" TEXT NOT NULL,
367
+ "name" TEXT NOT NULL,
368
+ "pageId" TEXT NOT NULL,
369
+ "accessToken" TEXT NOT NULL,
370
+ "verifyToken" TEXT NOT NULL,
371
+ "active" BOOLEAN NOT NULL DEFAULT true,
372
+ "defaultStatusId" TEXT,
373
+ "defaultAssignedUserId" TEXT,
374
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
375
+ "updatedAt" TIMESTAMP(3) NOT NULL,
376
+
377
+ CONSTRAINT "meta_lead_config_pkey" PRIMARY KEY ("id")
378
+ );
379
+
380
+ -- CreateTable
381
+ CREATE TABLE "google_ads_lead_config" (
382
+ "id" TEXT NOT NULL,
383
+ "name" TEXT NOT NULL,
384
+ "webhookKey" TEXT NOT NULL,
385
+ "active" BOOLEAN NOT NULL DEFAULT true,
386
+ "defaultStatusId" TEXT,
387
+ "defaultAssignedUserId" TEXT,
388
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
389
+ "updatedAt" TIMESTAMP(3) NOT NULL,
390
+
391
+ CONSTRAINT "google_ads_lead_config_pkey" PRIMARY KEY ("id")
392
+ );
393
+
394
+ -- CreateTable
395
+ CREATE TABLE "google_sheet_sync_config" (
396
+ "id" TEXT NOT NULL,
397
+ "name" TEXT NOT NULL,
398
+ "ownerUserId" TEXT,
399
+ "spreadsheetId" TEXT NOT NULL,
400
+ "sheetName" TEXT NOT NULL,
401
+ "headerRow" INTEGER NOT NULL,
402
+ "phoneColumn" TEXT NOT NULL,
403
+ "firstNameColumn" TEXT,
404
+ "lastNameColumn" TEXT,
405
+ "emailColumn" TEXT,
406
+ "cityColumn" TEXT,
407
+ "postalCodeColumn" TEXT,
408
+ "originColumn" TEXT,
409
+ "columnMappings" JSONB,
410
+ "active" BOOLEAN NOT NULL DEFAULT true,
411
+ "lastSyncedRow" INTEGER,
412
+ "defaultStatusId" TEXT,
413
+ "defaultAssignedUserId" TEXT,
414
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
415
+ "updatedAt" TIMESTAMP(3) NOT NULL,
416
+
417
+ CONSTRAINT "google_sheet_sync_config_pkey" PRIMARY KEY ("id")
418
+ );
419
+
420
+ -- CreateTable
421
+ CREATE TABLE "integration_import_log" (
422
+ "id" TEXT NOT NULL,
423
+ "integrationType" TEXT NOT NULL,
424
+ "configId" TEXT NOT NULL,
425
+ "configName" TEXT NOT NULL,
426
+ "action" TEXT NOT NULL,
427
+ "actorId" TEXT,
428
+ "totalImported" INTEGER NOT NULL DEFAULT 0,
429
+ "totalDuplicates" INTEGER NOT NULL DEFAULT 0,
430
+ "totalUpdated" INTEGER NOT NULL DEFAULT 0,
431
+ "totalErrors" INTEGER NOT NULL DEFAULT 0,
432
+ "errorDetails" JSONB,
433
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
434
+
435
+ CONSTRAINT "integration_import_log_pkey" PRIMARY KEY ("id")
436
+ );
437
+
438
+ -- CreateTable
439
+ CREATE TABLE "google_sheet_sync_job" (
440
+ "id" TEXT NOT NULL,
441
+ "status" "GoogleSheetSyncJobStatus" NOT NULL DEFAULT 'QUEUED',
442
+ "triggerType" "GoogleSheetSyncJobTriggerType" NOT NULL DEFAULT 'MANUAL',
443
+ "requestedByUserId" TEXT,
444
+ "configId" TEXT,
445
+ "payload" JSONB,
446
+ "result" JSONB,
447
+ "error" TEXT,
448
+ "startedAt" TIMESTAMP(3),
449
+ "finishedAt" TIMESTAMP(3),
450
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
451
+ "updatedAt" TIMESTAMP(3) NOT NULL,
452
+
453
+ CONSTRAINT "google_sheet_sync_job_pkey" PRIMARY KEY ("id")
454
+ );
455
+
456
+ -- CreateTable
457
+ CREATE TABLE "closing_reason" (
458
+ "id" TEXT NOT NULL,
459
+ "name" TEXT NOT NULL,
460
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
461
+ "updatedAt" TIMESTAMP(3) NOT NULL,
462
+
463
+ CONSTRAINT "closing_reason_pkey" PRIMARY KEY ("id")
464
+ );
465
+
466
+ -- CreateTable
467
+ CREATE TABLE "template" (
468
+ "id" TEXT NOT NULL,
469
+ "name" TEXT NOT NULL,
470
+ "type" "TemplateType" NOT NULL,
471
+ "subject" TEXT,
472
+ "content" TEXT NOT NULL,
473
+ "userId" TEXT,
474
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
475
+ "updatedAt" TIMESTAMP(3) NOT NULL,
476
+
477
+ CONSTRAINT "template_pkey" PRIMARY KEY ("id")
478
+ );
479
+
480
+ -- CreateTable
481
+ CREATE TABLE "workflow" (
482
+ "id" TEXT NOT NULL,
483
+ "name" TEXT NOT NULL,
484
+ "description" TEXT,
485
+ "active" BOOLEAN NOT NULL DEFAULT true,
486
+ "userId" TEXT,
487
+ "triggerType" "WorkflowTriggerType" NOT NULL,
488
+ "triggerFromStatusId" TEXT,
489
+ "triggerToStatusId" TEXT,
490
+ "triggerTimeDays" INTEGER,
491
+ "triggerTimeHours" INTEGER,
492
+ "triggerTimeReference" "WorkflowTimeReference",
493
+ "triggerTaskType" "TaskType",
494
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
495
+ "updatedAt" TIMESTAMP(3) NOT NULL,
496
+
497
+ CONSTRAINT "workflow_pkey" PRIMARY KEY ("id")
498
+ );
499
+
500
+ -- CreateTable
501
+ CREATE TABLE "workflow_action" (
502
+ "id" TEXT NOT NULL,
503
+ "workflowId" TEXT NOT NULL,
504
+ "actionType" "WorkflowActionType" NOT NULL,
505
+ "order" INTEGER NOT NULL DEFAULT 0,
506
+ "delayDays" INTEGER NOT NULL DEFAULT 0,
507
+ "delayHours" INTEGER NOT NULL DEFAULT 0,
508
+ "emailTemplateId" TEXT,
509
+ "smsMessage" TEXT,
510
+ "newStatusId" TEXT,
511
+ "taskTitle" TEXT,
512
+ "taskDescription" TEXT,
513
+ "taskType" "TaskType",
514
+ "taskPriority" "TaskPriority",
515
+ "taskAssignedUserId" TEXT,
516
+ "assignCommercialId" TEXT,
517
+ "assignTeleproId" TEXT,
518
+ "noteContent" TEXT,
519
+ "notifyUserId" TEXT,
520
+ "conditionOperator" "WorkflowConditionOperator",
521
+ "conditionStatusId" TEXT,
522
+ "conditionOrigin" TEXT,
523
+ "conditionHasCompany" BOOLEAN,
524
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
525
+ "updatedAt" TIMESTAMP(3) NOT NULL,
526
+
527
+ CONSTRAINT "workflow_action_pkey" PRIMARY KEY ("id")
528
+ );
529
+
530
+ -- CreateTable
531
+ CREATE TABLE "scheduled_workflow_action" (
532
+ "id" TEXT NOT NULL,
533
+ "workflowId" TEXT NOT NULL,
534
+ "actionId" TEXT,
535
+ "contactId" TEXT NOT NULL,
536
+ "actionType" TEXT NOT NULL,
537
+ "actionData" JSONB NOT NULL,
538
+ "executeAt" TIMESTAMP(3) NOT NULL,
539
+ "executed" BOOLEAN NOT NULL DEFAULT false,
540
+ "executedAt" TIMESTAMP(3),
541
+ "error" TEXT,
542
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
543
+ "updatedAt" TIMESTAMP(3) NOT NULL,
544
+
545
+ CONSTRAINT "scheduled_workflow_action_pkey" PRIMARY KEY ("id")
546
+ );
547
+
548
+ -- CreateTable
549
+ CREATE TABLE "contact_view" (
550
+ "id" TEXT NOT NULL,
551
+ "name" TEXT NOT NULL,
552
+ "userId" TEXT NOT NULL,
553
+ "isPublic" BOOLEAN NOT NULL DEFAULT false,
554
+ "isDefault" BOOLEAN NOT NULL DEFAULT false,
555
+ "entityType" TEXT NOT NULL DEFAULT 'contacts',
556
+ "filters" JSONB NOT NULL DEFAULT '[]',
557
+ "columns" JSONB,
558
+ "sortConfig" JSONB,
559
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
560
+ "updatedAt" TIMESTAMP(3) NOT NULL,
561
+
562
+ CONSTRAINT "contact_view_pkey" PRIMARY KEY ("id")
563
+ );
564
+
565
+ -- CreateTable
566
+ CREATE TABLE "contact_view_pin" (
567
+ "id" TEXT NOT NULL,
568
+ "userId" TEXT NOT NULL,
569
+ "viewId" TEXT NOT NULL,
570
+ "pinOrder" INTEGER NOT NULL DEFAULT 0,
571
+
572
+ CONSTRAINT "contact_view_pin_pkey" PRIMARY KEY ("id")
573
+ );
574
+
575
+ -- CreateTable
576
+ CREATE TABLE "dashboard_widget" (
577
+ "id" TEXT NOT NULL,
578
+ "userId" TEXT NOT NULL,
579
+ "type" TEXT NOT NULL,
580
+ "x" INTEGER NOT NULL DEFAULT 0,
581
+ "y" INTEGER NOT NULL DEFAULT 0,
582
+ "w" INTEGER NOT NULL DEFAULT 4,
583
+ "h" INTEGER NOT NULL DEFAULT 3,
584
+ "settings" JSONB NOT NULL DEFAULT '{}',
585
+
586
+ CONSTRAINT "dashboard_widget_pkey" PRIMARY KEY ("id")
587
+ );
588
+
589
+ -- CreateIndex
590
+ CREATE UNIQUE INDEX "custom_role_name_key" ON "custom_role"("name");
591
+
592
+ -- CreateIndex
593
+ CREATE UNIQUE INDEX "user_email_key" ON "user"("email");
594
+
595
+ -- CreateIndex
596
+ CREATE INDEX "user_customRoleId_idx" ON "user"("customRoleId");
597
+
598
+ -- CreateIndex
599
+ CREATE INDEX "audit_log_entityType_entityId_idx" ON "audit_log"("entityType", "entityId");
600
+
601
+ -- CreateIndex
602
+ CREATE INDEX "audit_log_createdAt_idx" ON "audit_log"("createdAt");
603
+
604
+ -- CreateIndex
605
+ CREATE UNIQUE INDEX "session_token_key" ON "session"("token");
606
+
607
+ -- CreateIndex
608
+ CREATE INDEX "session_userId_idx" ON "session"("userId");
609
+
610
+ -- CreateIndex
611
+ CREATE INDEX "account_userId_idx" ON "account"("userId");
612
+
613
+ -- CreateIndex
614
+ CREATE INDEX "verification_identifier_idx" ON "verification"("identifier");
615
+
616
+ -- CreateIndex
617
+ CREATE INDEX "verification_value_idx" ON "verification"("value");
618
+
619
+ -- CreateIndex
620
+ CREATE INDEX "companies_assignedCommercialId_idx" ON "companies"("assignedCommercialId");
621
+
622
+ -- CreateIndex
623
+ CREATE INDEX "companies_assignedTeleproId_idx" ON "companies"("assignedTeleproId");
624
+
625
+ -- CreateIndex
626
+ CREATE INDEX "companies_createdById_idx" ON "companies"("createdById");
627
+
628
+ -- CreateIndex
629
+ CREATE INDEX "companies_name_idx" ON "companies"("name");
630
+
631
+ -- CreateIndex
632
+ CREATE INDEX "company_activity_companyId_idx" ON "company_activity"("companyId");
633
+
634
+ -- CreateIndex
635
+ CREATE INDEX "company_activity_companyId_createdAt_idx" ON "company_activity"("companyId", "createdAt");
636
+
637
+ -- CreateIndex
638
+ CREATE INDEX "company_activity_userId_idx" ON "company_activity"("userId");
639
+
640
+ -- CreateIndex
641
+ CREATE UNIQUE INDEX "smtp_config_userId_key" ON "smtp_config"("userId");
642
+
643
+ -- CreateIndex
644
+ CREATE UNIQUE INDEX "status_name_key" ON "status"("name");
645
+
646
+ -- CreateIndex
647
+ CREATE INDEX "contact_statusId_idx" ON "contact"("statusId");
648
+
649
+ -- CreateIndex
650
+ CREATE INDEX "contact_assignedCommercialId_idx" ON "contact"("assignedCommercialId");
651
+
652
+ -- CreateIndex
653
+ CREATE INDEX "contact_assignedTeleproId_idx" ON "contact"("assignedTeleproId");
654
+
655
+ -- CreateIndex
656
+ CREATE INDEX "contact_createdById_idx" ON "contact"("createdById");
657
+
658
+ -- CreateIndex
659
+ CREATE INDEX "contact_companyId_idx" ON "contact"("companyId");
660
+
661
+ -- CreateIndex
662
+ CREATE INDEX "contact_phone_idx" ON "contact"("phone");
663
+
664
+ -- CreateIndex
665
+ CREATE INDEX "contact_createdAt_idx" ON "contact"("createdAt");
666
+
667
+ -- CreateIndex
668
+ CREATE INDEX "contact_updatedAt_idx" ON "contact"("updatedAt");
669
+
670
+ -- CreateIndex
671
+ CREATE INDEX "contact_statusId_updatedAt_idx" ON "contact"("statusId", "updatedAt");
672
+
673
+ -- CreateIndex
674
+ CREATE INDEX "interaction_contactId_idx" ON "interaction"("contactId");
675
+
676
+ -- CreateIndex
677
+ CREATE INDEX "interaction_userId_idx" ON "interaction"("userId");
678
+
679
+ -- CreateIndex
680
+ CREATE INDEX "interaction_contactId_createdAt_idx" ON "interaction"("contactId", "createdAt");
681
+
682
+ -- CreateIndex
683
+ CREATE UNIQUE INDEX "email_tracking_interactionId_key" ON "email_tracking"("interactionId");
684
+
685
+ -- CreateIndex
686
+ CREATE INDEX "email_tracking_interactionId_idx" ON "email_tracking"("interactionId");
687
+
688
+ -- CreateIndex
689
+ CREATE INDEX "task_contactId_idx" ON "task"("contactId");
690
+
691
+ -- CreateIndex
692
+ CREATE INDEX "task_assignedUserId_idx" ON "task"("assignedUserId");
693
+
694
+ -- CreateIndex
695
+ CREATE INDEX "task_createdById_idx" ON "task"("createdById");
696
+
697
+ -- CreateIndex
698
+ CREATE INDEX "task_scheduledAt_idx" ON "task"("scheduledAt");
699
+
700
+ -- CreateIndex
701
+ CREATE INDEX "task_googleEventId_idx" ON "task"("googleEventId");
702
+
703
+ -- CreateIndex
704
+ CREATE INDEX "task_assignedUserId_completed_scheduledAt_idx" ON "task"("assignedUserId", "completed", "scheduledAt");
705
+
706
+ -- CreateIndex
707
+ CREATE INDEX "task_assignedUserId_createdAt_idx" ON "task"("assignedUserId", "createdAt");
708
+
709
+ -- CreateIndex
710
+ CREATE UNIQUE INDEX "user_reminder_state_userId_reminderId_key" ON "user_reminder_state"("userId", "reminderId");
711
+
712
+ -- CreateIndex
713
+ CREATE INDEX "user_reminder_state_userId_status_idx" ON "user_reminder_state"("userId", "status");
714
+
715
+ -- CreateIndex
716
+ CREATE INDEX "user_reminder_state_updatedAt_idx" ON "user_reminder_state"("updatedAt");
717
+
718
+ -- CreateIndex
719
+ CREATE INDEX "user_reminder_state_userId_expiresAt_idx" ON "user_reminder_state"("userId", "expiresAt");
720
+
721
+ -- CreateIndex
722
+ CREATE UNIQUE INDEX "user_google_account_userId_key" ON "user_google_account"("userId");
723
+
724
+ -- CreateIndex
725
+ CREATE INDEX "contact_file_contactId_idx" ON "contact_file"("contactId");
726
+
727
+ -- CreateIndex
728
+ CREATE INDEX "contact_file_uploadedById_idx" ON "contact_file"("uploadedById");
729
+
730
+ -- CreateIndex
731
+ CREATE INDEX "integration_import_log_integrationType_configId_idx" ON "integration_import_log"("integrationType", "configId");
732
+
733
+ -- CreateIndex
734
+ CREATE INDEX "integration_import_log_createdAt_idx" ON "integration_import_log"("createdAt");
735
+
736
+ -- CreateIndex
737
+ CREATE INDEX "google_sheet_sync_job_status_idx" ON "google_sheet_sync_job"("status");
738
+
739
+ -- CreateIndex
740
+ CREATE INDEX "google_sheet_sync_job_createdAt_idx" ON "google_sheet_sync_job"("createdAt");
741
+
742
+ -- CreateIndex
743
+ CREATE INDEX "google_sheet_sync_job_requestedByUserId_idx" ON "google_sheet_sync_job"("requestedByUserId");
744
+
745
+ -- CreateIndex
746
+ CREATE INDEX "google_sheet_sync_job_triggerType_createdAt_idx" ON "google_sheet_sync_job"("triggerType", "createdAt");
747
+
748
+ -- CreateIndex
749
+ CREATE INDEX "template_userId_idx" ON "template"("userId");
750
+
751
+ -- CreateIndex
752
+ CREATE INDEX "template_type_idx" ON "template"("type");
753
+
754
+ -- CreateIndex
755
+ CREATE INDEX "workflow_userId_idx" ON "workflow"("userId");
756
+
757
+ -- CreateIndex
758
+ CREATE INDEX "workflow_active_triggerType_idx" ON "workflow"("active", "triggerType");
759
+
760
+ -- CreateIndex
761
+ CREATE INDEX "workflow_action_workflowId_idx" ON "workflow_action"("workflowId");
762
+
763
+ -- CreateIndex
764
+ CREATE INDEX "workflow_action_order_idx" ON "workflow_action"("order");
765
+
766
+ -- CreateIndex
767
+ CREATE INDEX "scheduled_workflow_action_executeAt_executed_idx" ON "scheduled_workflow_action"("executeAt", "executed");
768
+
769
+ -- CreateIndex
770
+ CREATE INDEX "scheduled_workflow_action_contactId_idx" ON "scheduled_workflow_action"("contactId");
771
+
772
+ -- CreateIndex
773
+ CREATE INDEX "scheduled_workflow_action_workflowId_idx" ON "scheduled_workflow_action"("workflowId");
774
+
775
+ -- CreateIndex
776
+ CREATE INDEX "contact_view_userId_idx" ON "contact_view"("userId");
777
+
778
+ -- CreateIndex
779
+ CREATE INDEX "contact_view_isPublic_idx" ON "contact_view"("isPublic");
780
+
781
+ -- CreateIndex
782
+ CREATE INDEX "contact_view_entityType_isPublic_idx" ON "contact_view"("entityType", "isPublic");
783
+
784
+ -- CreateIndex
785
+ CREATE UNIQUE INDEX "contact_view_pin_userId_viewId_key" ON "contact_view_pin"("userId", "viewId");
786
+
787
+ -- CreateIndex
788
+ CREATE INDEX "contact_view_pin_userId_idx" ON "contact_view_pin"("userId");
789
+
790
+ -- CreateIndex
791
+ CREATE INDEX "dashboard_widget_userId_idx" ON "dashboard_widget"("userId");
792
+
793
+ -- AddForeignKey
794
+ ALTER TABLE "user" ADD CONSTRAINT "user_customRoleId_fkey" FOREIGN KEY ("customRoleId") REFERENCES "custom_role"("id") ON DELETE SET NULL ON UPDATE CASCADE;
795
+
796
+ -- AddForeignKey
797
+ ALTER TABLE "audit_log" ADD CONSTRAINT "audit_log_actorId_fkey" FOREIGN KEY ("actorId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
798
+
799
+ -- AddForeignKey
800
+ ALTER TABLE "audit_log" ADD CONSTRAINT "audit_log_targetUserId_fkey" FOREIGN KEY ("targetUserId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
801
+
802
+ -- AddForeignKey
803
+ ALTER TABLE "session" ADD CONSTRAINT "session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
804
+
805
+ -- AddForeignKey
806
+ ALTER TABLE "account" ADD CONSTRAINT "account_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
807
+
808
+ -- AddForeignKey
809
+ ALTER TABLE "companies" ADD CONSTRAINT "companies_assignedCommercialId_fkey" FOREIGN KEY ("assignedCommercialId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
810
+
811
+ -- AddForeignKey
812
+ ALTER TABLE "companies" ADD CONSTRAINT "companies_assignedTeleproId_fkey" FOREIGN KEY ("assignedTeleproId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
813
+
814
+ -- AddForeignKey
815
+ ALTER TABLE "companies" ADD CONSTRAINT "companies_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
816
+
817
+ -- AddForeignKey
818
+ ALTER TABLE "company_activity" ADD CONSTRAINT "company_activity_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "companies"("id") ON DELETE CASCADE ON UPDATE CASCADE;
819
+
820
+ -- AddForeignKey
821
+ ALTER TABLE "company_activity" ADD CONSTRAINT "company_activity_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
822
+
823
+ -- AddForeignKey
824
+ ALTER TABLE "smtp_config" ADD CONSTRAINT "smtp_config_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
825
+
826
+ -- AddForeignKey
827
+ ALTER TABLE "contact" ADD CONSTRAINT "contact_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "companies"("id") ON DELETE SET NULL ON UPDATE CASCADE;
828
+
829
+ -- AddForeignKey
830
+ ALTER TABLE "contact" ADD CONSTRAINT "contact_statusId_fkey" FOREIGN KEY ("statusId") REFERENCES "status"("id") ON DELETE SET NULL ON UPDATE CASCADE;
831
+
832
+ -- AddForeignKey
833
+ ALTER TABLE "contact" ADD CONSTRAINT "contact_assignedCommercialId_fkey" FOREIGN KEY ("assignedCommercialId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
834
+
835
+ -- AddForeignKey
836
+ ALTER TABLE "contact" ADD CONSTRAINT "contact_assignedTeleproId_fkey" FOREIGN KEY ("assignedTeleproId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
837
+
838
+ -- AddForeignKey
839
+ ALTER TABLE "contact" ADD CONSTRAINT "contact_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
840
+
841
+ -- AddForeignKey
842
+ ALTER TABLE "interaction" ADD CONSTRAINT "interaction_contactId_fkey" FOREIGN KEY ("contactId") REFERENCES "contact"("id") ON DELETE CASCADE ON UPDATE CASCADE;
843
+
844
+ -- AddForeignKey
845
+ ALTER TABLE "interaction" ADD CONSTRAINT "interaction_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
846
+
847
+ -- AddForeignKey
848
+ ALTER TABLE "email_tracking" ADD CONSTRAINT "email_tracking_interactionId_fkey" FOREIGN KEY ("interactionId") REFERENCES "interaction"("id") ON DELETE CASCADE ON UPDATE CASCADE;
849
+
850
+ -- AddForeignKey
851
+ ALTER TABLE "task" ADD CONSTRAINT "task_contactId_fkey" FOREIGN KEY ("contactId") REFERENCES "contact"("id") ON DELETE SET NULL ON UPDATE CASCADE;
852
+
853
+ -- AddForeignKey
854
+ ALTER TABLE "task" ADD CONSTRAINT "task_assignedUserId_fkey" FOREIGN KEY ("assignedUserId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
855
+
856
+ -- AddForeignKey
857
+ ALTER TABLE "task" ADD CONSTRAINT "task_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
858
+
859
+ -- AddForeignKey
860
+ ALTER TABLE "user_reminder_state" ADD CONSTRAINT "user_reminder_state_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
861
+
862
+ -- AddForeignKey
863
+ ALTER TABLE "user_google_account" ADD CONSTRAINT "user_google_account_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
864
+
865
+ -- AddForeignKey
866
+ ALTER TABLE "contact_file" ADD CONSTRAINT "contact_file_contactId_fkey" FOREIGN KEY ("contactId") REFERENCES "contact"("id") ON DELETE CASCADE ON UPDATE CASCADE;
867
+
868
+ -- AddForeignKey
869
+ ALTER TABLE "contact_file" ADD CONSTRAINT "contact_file_uploadedById_fkey" FOREIGN KEY ("uploadedById") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
870
+
871
+ -- AddForeignKey
872
+ ALTER TABLE "meta_lead_config" ADD CONSTRAINT "meta_lead_config_defaultStatusId_fkey" FOREIGN KEY ("defaultStatusId") REFERENCES "status"("id") ON DELETE SET NULL ON UPDATE CASCADE;
873
+
874
+ -- AddForeignKey
875
+ ALTER TABLE "meta_lead_config" ADD CONSTRAINT "meta_lead_config_defaultAssignedUserId_fkey" FOREIGN KEY ("defaultAssignedUserId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
876
+
877
+ -- AddForeignKey
878
+ ALTER TABLE "google_ads_lead_config" ADD CONSTRAINT "google_ads_lead_config_defaultStatusId_fkey" FOREIGN KEY ("defaultStatusId") REFERENCES "status"("id") ON DELETE SET NULL ON UPDATE CASCADE;
879
+
880
+ -- AddForeignKey
881
+ ALTER TABLE "google_ads_lead_config" ADD CONSTRAINT "google_ads_lead_config_defaultAssignedUserId_fkey" FOREIGN KEY ("defaultAssignedUserId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
882
+
883
+ -- AddForeignKey
884
+ ALTER TABLE "google_sheet_sync_config" ADD CONSTRAINT "google_sheet_sync_config_ownerUserId_fkey" FOREIGN KEY ("ownerUserId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
885
+
886
+ -- AddForeignKey
887
+ ALTER TABLE "google_sheet_sync_config" ADD CONSTRAINT "google_sheet_sync_config_defaultStatusId_fkey" FOREIGN KEY ("defaultStatusId") REFERENCES "status"("id") ON DELETE SET NULL ON UPDATE CASCADE;
888
+
889
+ -- AddForeignKey
890
+ ALTER TABLE "google_sheet_sync_config" ADD CONSTRAINT "google_sheet_sync_config_defaultAssignedUserId_fkey" FOREIGN KEY ("defaultAssignedUserId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
891
+
892
+ -- AddForeignKey
893
+ ALTER TABLE "integration_import_log" ADD CONSTRAINT "integration_import_log_actorId_fkey" FOREIGN KEY ("actorId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
894
+
895
+ -- AddForeignKey
896
+ ALTER TABLE "google_sheet_sync_job" ADD CONSTRAINT "google_sheet_sync_job_requestedByUserId_fkey" FOREIGN KEY ("requestedByUserId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
897
+
898
+ -- AddForeignKey
899
+ ALTER TABLE "template" ADD CONSTRAINT "template_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
900
+
901
+ -- AddForeignKey
902
+ ALTER TABLE "workflow" ADD CONSTRAINT "workflow_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
903
+
904
+ -- AddForeignKey
905
+ ALTER TABLE "workflow" ADD CONSTRAINT "workflow_triggerFromStatusId_fkey" FOREIGN KEY ("triggerFromStatusId") REFERENCES "status"("id") ON DELETE SET NULL ON UPDATE CASCADE;
906
+
907
+ -- AddForeignKey
908
+ ALTER TABLE "workflow" ADD CONSTRAINT "workflow_triggerToStatusId_fkey" FOREIGN KEY ("triggerToStatusId") REFERENCES "status"("id") ON DELETE SET NULL ON UPDATE CASCADE;
909
+
910
+ -- AddForeignKey
911
+ ALTER TABLE "workflow_action" ADD CONSTRAINT "workflow_action_workflowId_fkey" FOREIGN KEY ("workflowId") REFERENCES "workflow"("id") ON DELETE CASCADE ON UPDATE CASCADE;
912
+
913
+ -- AddForeignKey
914
+ ALTER TABLE "workflow_action" ADD CONSTRAINT "workflow_action_emailTemplateId_fkey" FOREIGN KEY ("emailTemplateId") REFERENCES "template"("id") ON DELETE SET NULL ON UPDATE CASCADE;
915
+
916
+ -- AddForeignKey
917
+ ALTER TABLE "workflow_action" ADD CONSTRAINT "workflow_action_newStatusId_fkey" FOREIGN KEY ("newStatusId") REFERENCES "status"("id") ON DELETE SET NULL ON UPDATE CASCADE;
918
+
919
+ -- AddForeignKey
920
+ ALTER TABLE "workflow_action" ADD CONSTRAINT "workflow_action_taskAssignedUserId_fkey" FOREIGN KEY ("taskAssignedUserId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
921
+
922
+ -- AddForeignKey
923
+ ALTER TABLE "workflow_action" ADD CONSTRAINT "workflow_action_assignCommercialId_fkey" FOREIGN KEY ("assignCommercialId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
924
+
925
+ -- AddForeignKey
926
+ ALTER TABLE "workflow_action" ADD CONSTRAINT "workflow_action_assignTeleproId_fkey" FOREIGN KEY ("assignTeleproId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
927
+
928
+ -- AddForeignKey
929
+ ALTER TABLE "workflow_action" ADD CONSTRAINT "workflow_action_notifyUserId_fkey" FOREIGN KEY ("notifyUserId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
930
+
931
+ -- AddForeignKey
932
+ ALTER TABLE "workflow_action" ADD CONSTRAINT "workflow_action_conditionStatusId_fkey" FOREIGN KEY ("conditionStatusId") REFERENCES "status"("id") ON DELETE SET NULL ON UPDATE CASCADE;
933
+
934
+ -- AddForeignKey
935
+ ALTER TABLE "scheduled_workflow_action" ADD CONSTRAINT "scheduled_workflow_action_workflowId_fkey" FOREIGN KEY ("workflowId") REFERENCES "workflow"("id") ON DELETE CASCADE ON UPDATE CASCADE;
936
+
937
+ -- AddForeignKey
938
+ ALTER TABLE "scheduled_workflow_action" ADD CONSTRAINT "scheduled_workflow_action_contactId_fkey" FOREIGN KEY ("contactId") REFERENCES "contact"("id") ON DELETE CASCADE ON UPDATE CASCADE;
939
+
940
+ -- AddForeignKey
941
+ ALTER TABLE "contact_view" ADD CONSTRAINT "contact_view_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
942
+
943
+ -- AddForeignKey
944
+ ALTER TABLE "contact_view_pin" ADD CONSTRAINT "contact_view_pin_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
945
+
946
+ -- AddForeignKey
947
+ ALTER TABLE "contact_view_pin" ADD CONSTRAINT "contact_view_pin_viewId_fkey" FOREIGN KEY ("viewId") REFERENCES "contact_view"("id") ON DELETE CASCADE ON UPDATE CASCADE;
948
+
949
+ -- AddForeignKey
950
+ ALTER TABLE "dashboard_widget" ADD CONSTRAINT "dashboard_widget_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
951
+
952
+ -- Seed: Default statuses
953
+ INSERT INTO "status" ("id", "name", "color", "order", "isSystem", "requiresClosingReason", "createdAt", "updatedAt") VALUES
954
+ ('status_nouveau', 'Nouveau', '#3B82F6', 0, false, false, NOW(), NOW()),
955
+ ('status_ferme', 'Fermé', '#EF4444', 1, false, true, NOW(), NOW()),
956
+ ('status_signe', 'Signé', '#22C55E', 2, false, false, NOW(), NOW()),
957
+ ('status_a_rappeler', 'À rappeler', '#F59E0B', 3, false, false, NOW(), NOW()),
958
+ ('status_rdv_pris', 'RDV pris', '#8B5CF6', 4, false, false, NOW(), NOW()),
959
+ ('status_doublon', 'Doublon', '#EF4444', 5, true, false, NOW(), NOW()),
960
+ ('status_nrp', 'NRP', '#F59E0B', 6, false, false, NOW(), NOW());
961
+
962
+ -- Seed: Default closing reasons
963
+ INSERT INTO "closing_reason" ("id", "name", "createdAt", "updatedAt") VALUES
964
+ ('cr_faux_numero', 'Faux numéro', NOW(), NOW()),
965
+ ('cr_pas_interessant', 'Pas intéressant', NOW(), NOW()),
966
+ ('cr_pas_interesse', 'Pas intéressé', NOW(), NOW());
967
+
968
+ -- Seed: Default roles (custom_role) with permissions
969
+ INSERT INTO "custom_role" ("id", "name", "description", "permissions", "isSystem", "createdAt", "updatedAt") VALUES
970
+ ('role_admin', 'Administrateur', 'Accès complet à toutes les fonctionnalités du système', '["dashboard.view","dashboard.widgets.manage","dashboard.widgets.reset","analytics.view","analytics.export","contacts.view_all","contacts.view_own","contacts.view_unassigned","contacts.create","contacts.edit_own","contacts.edit_all","contacts.delete","contacts.assign","contacts.assign_to_sales","contacts.import","contacts.export","contacts.upload_files","contacts.view_files","contacts.view_closing_pipeline","contacts.manage_pipeline","contacts.send_email","contacts.delete_files","contacts.views.create","contacts.views.edit_own","contacts.views.edit_all","contacts.views.delete_own","contacts.views.delete_all","contacts.views.share","companies.view_all","companies.view_own","companies.create","companies.edit","companies.delete","companies.view_activities","companies.add_activity","tasks.view_all","tasks.view_own","tasks.view_other_users_events","tasks.create","tasks.edit_own","tasks.edit_all","tasks.delete","tasks.assign","tasks.assign_to_sales","workflows.view","workflows.create","workflows.edit","workflows.delete","workflows.activate","templates.view","templates.create","templates.edit","templates.delete","integrations.view","integrations.create","integrations.edit","integrations.delete","integrations.google.connect","integrations.meta.manage","integrations.google_ads.manage","integrations.google_sheets.manage","users.view","users.create","users.edit","users.deactivate","users.delete","users.manage_roles","settings.view","settings.company.edit","settings.smtp.edit","settings.status.manage","settings.closing_reasons.manage","settings.workflows.manage","audit.view_all","audit.view_own","audit.export","general.view_all_companies"]', true, NOW(), NOW()),
971
+
972
+ ('role_manager', 'Manager', 'Gestion d''équipe et accès étendu aux leads', '["dashboard.view","dashboard.widgets.manage","dashboard.widgets.reset","analytics.view","general.view_all_companies","contacts.view_all","contacts.create","contacts.edit_all","contacts.assign","contacts.import","contacts.export","contacts.view_files","contacts.upload_files","contacts.view_closing_pipeline","contacts.manage_pipeline","contacts.send_email","contacts.delete_files","contacts.views.create","contacts.views.edit_own","contacts.views.edit_all","contacts.views.delete_own","contacts.views.delete_all","contacts.views.share","companies.view_all","companies.create","companies.edit","companies.delete","companies.view_activities","companies.add_activity","tasks.view_all","tasks.create","tasks.edit_all","tasks.assign","tasks.view_other_users_events","workflows.view","workflows.create","workflows.edit","workflows.activate","settings.workflows.manage","templates.view","templates.create","templates.edit","templates.delete","integrations.view","integrations.create","integrations.edit","integrations.delete","integrations.meta.manage","integrations.google_ads.manage","integrations.google_sheets.manage","users.view","settings.view","settings.status.manage","settings.closing_reasons.manage","audit.view_all","audit.view_own","audit.export"]', true, NOW(), NOW()),
973
+
974
+ ('role_commercial', 'Commercial', 'Accès de base pour la gestion des leads personnels', '["dashboard.view","dashboard.widgets.manage","contacts.view_own","contacts.view_unassigned","contacts.create","contacts.edit_own","contacts.assign_to_sales","contacts.export","contacts.view_files","contacts.upload_files","contacts.view_closing_pipeline","contacts.manage_pipeline","contacts.send_email","contacts.views.create","contacts.views.edit_own","contacts.views.delete_own","contacts.views.share","companies.view_own","companies.create","companies.edit","companies.view_activities","companies.add_activity","tasks.view_own","tasks.create","tasks.edit_own","tasks.assign_to_sales","audit.view_own","templates.view","templates.create","templates.edit","integrations.view","integrations.google.connect","settings.view","settings.smtp.edit"]', true, NOW(), NOW()),
975
+
976
+ ('role_telepro', 'Télépro', 'Accès limité pour la qualification de leads', '["dashboard.view","dashboard.widgets.manage","contacts.view_own","contacts.view_unassigned","contacts.create","contacts.edit_own","contacts.assign_to_sales","contacts.view_files","contacts.upload_files","contacts.view_closing_pipeline","contacts.manage_pipeline","contacts.send_email","contacts.views.create","contacts.views.edit_own","contacts.views.delete_own","contacts.views.share","companies.view_own","companies.create","companies.edit","companies.view_activities","companies.add_activity","tasks.view_own","tasks.create","tasks.edit_own","tasks.assign_to_sales","templates.view","templates.create","templates.edit","settings.view","settings.smtp.edit"]', true, NOW(), NOW()),
977
+
978
+ ('role_comptable', 'Comptable', 'Accès limité aux informations financières et reporting', '["dashboard.view","analytics.view","analytics.export","contacts.view_all","contacts.export","companies.view_all","companies.view_activities","tasks.view_all","general.view_all_companies","templates.view","settings.view","audit.view_all","audit.view_own","audit.export"]', true, NOW(), NOW());