The minimalistic document archiving platform.
fix(tags): fixed the impossibility to delete a tag that have been affected to a document (#448)
Corentin Thomasset5868800bcec6
diff --git a/.changeset/cuddly-shoes-watch.md b/.changeset/cuddly-shoes-watch.mdnew file mode 100644index 00000000..6f729e62--- /dev/null+++ b/.changeset/cuddly-shoes-watch.md@@ -0,0 +1,5 @@+---+"@papra/app-client": patch+---++Added feedback when an error occurs while deleting a tagdiff --git a/.changeset/green-teeth-fall.md b/.changeset/green-teeth-fall.mdnew file mode 100644index 00000000..d354f6d0--- /dev/null+++ b/.changeset/green-teeth-fall.md@@ -0,0 +1,5 @@+---+"@papra/app-server": minor+---++Fixed the impossibility to delete a tag that has been assigned to a documentdiff --git a/apps/papra-client/src/locales/de.yml b/apps/papra-client/src/locales/de.ymlindex cfebbb7f..3d2446ea 100644--- a/apps/papra-client/src/locales/de.yml+++ b/apps/papra-client/src/locales/de.yml@@ -545,6 +545,7 @@ api-errors.user.already_in_organization: Dieser Benutzer ist bereits in dieser Oapi-errors.user.organization_invitation_limit_reached: Die maximale Anzahl an Einladungen für heute wurde erreicht. Bitte versuchen Sie es morgen erneut.api-errors.demo.not_available: Diese Funktion ist in der Demo nicht verfügbarapi-errors.tags.already_exists: Ein Tag mit diesem Namen existiert bereits für diese Organisation+api-errors.internal.error: Beim Verarbeiten Ihrer Anfrage ist ein Fehler aufgetreten. Bitte versuchen Sie es erneut.# Not founddiff --git a/apps/papra-client/src/locales/en.yml b/apps/papra-client/src/locales/en.ymlindex ffa17d8b..8f5d3825 100644--- a/apps/papra-client/src/locales/en.yml+++ b/apps/papra-client/src/locales/en.yml@@ -545,6 +545,7 @@ api-errors.user.already_in_organization: This user is already in this organizatiapi-errors.user.organization_invitation_limit_reached: The maximum number of invitations has been reached for today. Please try again tomorrow.api-errors.demo.not_available: This feature is not available in demoapi-errors.tags.already_exists: A tag with this name already exists for this organization+api-errors.internal.error: An error occurred while processing your request. Please try again later.# Not founddiff --git a/apps/papra-client/src/locales/es.yml b/apps/papra-client/src/locales/es.ymlindex 34cd7c23..c52eeec0 100644--- a/apps/papra-client/src/locales/es.yml+++ b/apps/papra-client/src/locales/es.yml@@ -545,6 +545,7 @@ api-errors.user.already_in_organization: Este usuario ya está en esta organizacapi-errors.user.organization_invitation_limit_reached: Se ha alcanzado el número máximo de invitaciones para hoy. Por favor, inténtalo de nuevo mañana.api-errors.demo.not_available: Esta función no está disponible en la demostraciónapi-errors.tags.already_exists: Ya existe una etiqueta con este nombre en esta organización+api-errors.internal.error: Ocurrió un error al procesar tu solicitud. Por favor, inténtalo de nuevo.# Not founddiff --git a/apps/papra-client/src/locales/fr.yml b/apps/papra-client/src/locales/fr.ymlindex 7c56ac61..3f220dae 100644--- a/apps/papra-client/src/locales/fr.yml+++ b/apps/papra-client/src/locales/fr.yml@@ -545,6 +545,7 @@ api-errors.user.already_in_organization: Cet utilisateur est déjà dans cette oapi-errors.user.organization_invitation_limit_reached: Le nombre maximum d'invitations a été atteint pour aujourd'hui. Veuillez réessayer demain.api-errors.demo.not_available: Cette fonctionnalité n'est pas disponible dans la démoapi-errors.tags.already_exists: Un tag avec ce nom existe déjà pour cette organisation+api-errors.internal.error: Une erreur est survenue lors du traitement de votre requête. Veuillez réessayer.# Not founddiff --git a/apps/papra-client/src/locales/it.yml b/apps/papra-client/src/locales/it.ymlindex 39b30e69..bf70ad2f 100644--- a/apps/papra-client/src/locales/it.yml+++ b/apps/papra-client/src/locales/it.yml@@ -545,6 +545,7 @@ api-errors.user.already_in_organization: Questo utente è già in questa organizapi-errors.user.organization_invitation_limit_reached: È stato raggiunto il numero massimo di inviti per oggi. Riprova domani.api-errors.demo.not_available: Questa funzionalità non è disponibile nella demoapi-errors.tags.already_exists: Esiste già un tag con questo nome per questa organizzazione+api-errors.internal.error: Si è verificato un errore durante l'elaborazione della richiesta. Riprova.# Not founddiff --git a/apps/papra-client/src/locales/pl.yml b/apps/papra-client/src/locales/pl.ymlindex 33b936e0..34de9551 100644--- a/apps/papra-client/src/locales/pl.yml+++ b/apps/papra-client/src/locales/pl.yml@@ -545,6 +545,7 @@ api-errors.user.already_in_organization: Ten użytkownik należy już do tej orgapi-errors.user.organization_invitation_limit_reached: Osiągnięto maksymalną liczbę zaproszeń na dzisiaj. Spróbuj ponownie jutro.api-errors.demo.not_available: Ta funkcja nie jest dostępna w wersji demoapi-errors.tags.already_exists: Tag o tej nazwie już istnieje w tej organizacji+api-errors.internal.error: Wystąpił błąd podczas przetwarzania żądania. Spróbuj ponownie później.# Not founddiff --git a/apps/papra-client/src/locales/pt-BR.yml b/apps/papra-client/src/locales/pt-BR.ymlindex fe21d41e..21ff024f 100644--- a/apps/papra-client/src/locales/pt-BR.yml+++ b/apps/papra-client/src/locales/pt-BR.yml@@ -545,6 +545,7 @@ api-errors.user.already_in_organization: Este usuário já faz parte desta organapi-errors.user.organization_invitation_limit_reached: O número máximo de convites por hoje foi atingido. Por favor, tente novamente amanhã.api-errors.demo.not_available: Este recurso não está disponível em ambiente de demonstraçãoapi-errors.tags.already_exists: Já existe uma tag com este nome nesta organização+api-errors.internal.error: Ocorreu um erro ao processar sua solicitação. Por favor, tente novamente.# Not founddiff --git a/apps/papra-client/src/locales/pt.yml b/apps/papra-client/src/locales/pt.ymlindex 3b054a02..bc490e36 100644--- a/apps/papra-client/src/locales/pt.yml+++ b/apps/papra-client/src/locales/pt.yml@@ -545,6 +545,7 @@ api-errors.user.already_in_organization: Este utilizadpr já faz parte desta orgapi-errors.user.organization_invitation_limit_reached: O número máximo de convites por hoje foi atingido. Por favor, tente novamente amanhã.api-errors.demo.not_available: Este recurso não está disponível em ambiente de demonstraçãoapi-errors.tags.already_exists: Já existe uma etiqueta com este nome nesta organização+api-errors.internal.error: Ocorreu um erro ao processar a solicitação. Por favor, tente novamente.# Not founddiff --git a/apps/papra-client/src/locales/ro.yml b/apps/papra-client/src/locales/ro.ymlindex 92594039..bd42d4fa 100644--- a/apps/papra-client/src/locales/ro.yml+++ b/apps/papra-client/src/locales/ro.yml@@ -545,6 +545,7 @@ api-errors.user.already_in_organization: Acest utilizator este deja în aceastăapi-errors.user.organization_invitation_limit_reached: Numărul maxim de invitații a fost atins pentru astazi. Te rugăm să încerci din nou mâine.api-errors.demo.not_available: Această functie nu este disponibila în demoapi-errors.tags.already_exists: O etichetă cu acest nume există deja pentru aceasta organizație+api-errors.internal.error: A apărut o eroare la procesarea cererii. Te rugăm să încerci din nou.# Not founddiff --git a/apps/papra-client/src/modules/i18n/locales.types.ts b/apps/papra-client/src/modules/i18n/locales.types.tsindex d3b88134..745604a4 100644--- a/apps/papra-client/src/modules/i18n/locales.types.ts+++ b/apps/papra-client/src/modules/i18n/locales.types.ts@@ -484,6 +484,7 @@ export type LocaleKeys =| 'api-errors.user.organization_invitation_limit_reached'| 'api-errors.demo.not_available'| 'api-errors.tags.already_exists'+ | 'api-errors.internal.error'| 'not-found.title'| 'not-found.description'| 'not-found.back-to-home'diff --git a/apps/papra-client/src/modules/tags/pages/tags.page.tsx b/apps/papra-client/src/modules/tags/pages/tags.page.tsxindex 608c195b..5ad587d8 100644--- a/apps/papra-client/src/modules/tags/pages/tags.page.tsx+++ b/apps/papra-client/src/modules/tags/pages/tags.page.tsx@@ -228,6 +228,7 @@ export const TagsPage: Component = () => {const params = useParams();const { confirm } = useConfirmModal();const { t } = useI18n();+ const { getErrorMessage } = useI18nApiErrors({ t });const query = useQuery(() => ({queryKey: ['organizations', params.organizationId, 'tags'],@@ -252,10 +253,19 @@ export const TagsPage: Component = () => {return;}- await deleteTag({+ const [, error] = await safely(deleteTag({organizationId: params.organizationId,tagId: tag.id,- });+ }));++ if (error) {+ createToast({+ message: getErrorMessage({ error }),+ type: 'error',+ });++ return;+ }await queryClient.invalidateQueries({queryKey: ['organizations', params.organizationId],diff --git a/apps/papra-server/migrations/0007_document-activity-log-on-delete-set-null.sql b/apps/papra-server/migrations/0007_document-activity-log-on-delete-set-null.sqlnew file mode 100644index 00000000..42bab0b5--- /dev/null+++ b/apps/papra-server/migrations/0007_document-activity-log-on-delete-set-null.sql@@ -0,0 +1,18 @@+PRAGMA foreign_keys=OFF;--> statement-breakpoint+CREATE TABLE `__new_document_activity_log` (+ `id` text PRIMARY KEY NOT NULL,+ `created_at` integer NOT NULL,+ `document_id` text NOT NULL,+ `event` text NOT NULL,+ `event_data` text,+ `user_id` text,+ `tag_id` text,+ FOREIGN KEY (`document_id`) REFERENCES `documents`(`id`) ON UPDATE cascade ON DELETE cascade,+ FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE set null,+ FOREIGN KEY (`tag_id`) REFERENCES `tags`(`id`) ON UPDATE cascade ON DELETE set null+);+--> statement-breakpoint+INSERT INTO `__new_document_activity_log`("id", "created_at", "document_id", "event", "event_data", "user_id", "tag_id") SELECT "id", "created_at", "document_id", "event", "event_data", "user_id", "tag_id" FROM `document_activity_log`;--> statement-breakpoint+DROP TABLE `document_activity_log`;--> statement-breakpoint+ALTER TABLE `__new_document_activity_log` RENAME TO `document_activity_log`;--> statement-breakpoint+PRAGMA foreign_keys=ON;\ No newline at end of filediff --git a/apps/papra-server/migrations/meta/0007_snapshot.json b/apps/papra-server/migrations/meta/0007_snapshot.jsonnew file mode 100644index 00000000..addd86ad--- /dev/null+++ b/apps/papra-server/migrations/meta/0007_snapshot.json@@ -0,0 +1,1970 @@+{+ "version": "6",+ "dialect": "sqlite",+ "id": "7fb3b6cf-299a-430f-84be-9050d2ff9a65",+ "prevId": "2033ceb9-a1e6-4b1a-972d-84922f2ed9b0",+ "tables": {+ "document_activity_log": {+ "name": "document_activity_log",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "document_id": {+ "name": "document_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "event": {+ "name": "event",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "event_data": {+ "name": "event_data",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "tag_id": {+ "name": "tag_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "document_activity_log_document_id_documents_id_fk": {+ "name": "document_activity_log_document_id_documents_id_fk",+ "tableFrom": "document_activity_log",+ "tableTo": "documents",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ },+ "document_activity_log_user_id_users_id_fk": {+ "name": "document_activity_log_user_id_users_id_fk",+ "tableFrom": "document_activity_log",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "cascade"+ },+ "document_activity_log_tag_id_tags_id_fk": {+ "name": "document_activity_log_tag_id_tags_id_fk",+ "tableFrom": "document_activity_log",+ "tableTo": "tags",+ "columnsFrom": [+ "tag_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "documents": {+ "name": "documents",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "is_deleted": {+ "name": "is_deleted",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "organization_id": {+ "name": "organization_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_by": {+ "name": "created_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "deleted_by": {+ "name": "deleted_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "original_name": {+ "name": "original_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "original_size": {+ "name": "original_size",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "original_storage_key": {+ "name": "original_storage_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "original_sha256_hash": {+ "name": "original_sha256_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "mime_type": {+ "name": "mime_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "''"+ }+ },+ "indexes": {+ "documents_organization_id_is_deleted_created_at_index": {+ "name": "documents_organization_id_is_deleted_created_at_index",+ "columns": [+ "organization_id",+ "is_deleted",+ "created_at"+ ],+ "isUnique": false+ },+ "documents_organization_id_is_deleted_index": {+ "name": "documents_organization_id_is_deleted_index",+ "columns": [+ "organization_id",+ "is_deleted"+ ],+ "isUnique": false+ },+ "documents_organization_id_original_sha256_hash_unique": {+ "name": "documents_organization_id_original_sha256_hash_unique",+ "columns": [+ "organization_id",+ "original_sha256_hash"+ ],+ "isUnique": true+ },+ "documents_original_sha256_hash_index": {+ "name": "documents_original_sha256_hash_index",+ "columns": [+ "original_sha256_hash"+ ],+ "isUnique": false+ },+ "documents_organization_id_size_index": {+ "name": "documents_organization_id_size_index",+ "columns": [+ "organization_id",+ "original_size"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "documents_organization_id_organizations_id_fk": {+ "name": "documents_organization_id_organizations_id_fk",+ "tableFrom": "documents",+ "tableTo": "organizations",+ "columnsFrom": [+ "organization_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ },+ "documents_created_by_users_id_fk": {+ "name": "documents_created_by_users_id_fk",+ "tableFrom": "documents",+ "tableTo": "users",+ "columnsFrom": [+ "created_by"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "cascade"+ },+ "documents_deleted_by_users_id_fk": {+ "name": "documents_deleted_by_users_id_fk",+ "tableFrom": "documents",+ "tableTo": "users",+ "columnsFrom": [+ "deleted_by"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "organization_invitations": {+ "name": "organization_invitations",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "organization_id": {+ "name": "organization_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'pending'"+ },+ "expires_at": {+ "name": "expires_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "inviter_id": {+ "name": "inviter_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "organization_invitations_organization_email_unique": {+ "name": "organization_invitations_organization_email_unique",+ "columns": [+ "organization_id",+ "email"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "organization_invitations_organization_id_organizations_id_fk": {+ "name": "organization_invitations_organization_id_organizations_id_fk",+ "tableFrom": "organization_invitations",+ "tableTo": "organizations",+ "columnsFrom": [+ "organization_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ },+ "organization_invitations_inviter_id_users_id_fk": {+ "name": "organization_invitations_inviter_id_users_id_fk",+ "tableFrom": "organization_invitations",+ "tableTo": "users",+ "columnsFrom": [+ "inviter_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "organization_members": {+ "name": "organization_members",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "organization_id": {+ "name": "organization_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "organization_members_user_organization_unique": {+ "name": "organization_members_user_organization_unique",+ "columns": [+ "organization_id",+ "user_id"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "organization_members_organization_id_organizations_id_fk": {+ "name": "organization_members_organization_id_organizations_id_fk",+ "tableFrom": "organization_members",+ "tableTo": "organizations",+ "columnsFrom": [+ "organization_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ },+ "organization_members_user_id_users_id_fk": {+ "name": "organization_members_user_id_users_id_fk",+ "tableFrom": "organization_members",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "organizations": {+ "name": "organizations",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "customer_id": {+ "name": "customer_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "user_roles": {+ "name": "user_roles",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "user_roles_role_index": {+ "name": "user_roles_role_index",+ "columns": [+ "role"+ ],+ "isUnique": false+ },+ "user_roles_user_id_role_unique_index": {+ "name": "user_roles_user_id_role_unique_index",+ "columns": [+ "user_id",+ "role"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "user_roles_user_id_users_id_fk": {+ "name": "user_roles_user_id_users_id_fk",+ "tableFrom": "user_roles",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "documents_tags": {+ "name": "documents_tags",+ "columns": {+ "document_id": {+ "name": "document_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "tag_id": {+ "name": "tag_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "documents_tags_document_id_documents_id_fk": {+ "name": "documents_tags_document_id_documents_id_fk",+ "tableFrom": "documents_tags",+ "tableTo": "documents",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ },+ "documents_tags_tag_id_tags_id_fk": {+ "name": "documents_tags_tag_id_tags_id_fk",+ "tableFrom": "documents_tags",+ "tableTo": "tags",+ "columnsFrom": [+ "tag_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "documents_tags_pkey": {+ "columns": [+ "document_id",+ "tag_id"+ ],+ "name": "documents_tags_pkey"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "tags": {+ "name": "tags",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "organization_id": {+ "name": "organization_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "tags_organization_id_name_unique": {+ "name": "tags_organization_id_name_unique",+ "columns": [+ "organization_id",+ "name"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "tags_organization_id_organizations_id_fk": {+ "name": "tags_organization_id_organizations_id_fk",+ "tableFrom": "tags",+ "tableTo": "organizations",+ "columnsFrom": [+ "organization_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "users": {+ "name": "users",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "email_verified": {+ "name": "email_verified",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "image": {+ "name": "image",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "max_organization_count": {+ "name": "max_organization_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "users_email_unique": {+ "name": "users_email_unique",+ "columns": [+ "email"+ ],+ "isUnique": true+ },+ "users_email_index": {+ "name": "users_email_index",+ "columns": [+ "email"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "api_key_organizations": {+ "name": "api_key_organizations",+ "columns": {+ "api_key_id": {+ "name": "api_key_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "organization_member_id": {+ "name": "organization_member_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "api_key_organizations_api_key_id_api_keys_id_fk": {+ "name": "api_key_organizations_api_key_id_api_keys_id_fk",+ "tableFrom": "api_key_organizations",+ "tableTo": "api_keys",+ "columnsFrom": [+ "api_key_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ },+ "api_key_organizations_organization_member_id_organization_members_id_fk": {+ "name": "api_key_organizations_organization_member_id_organization_members_id_fk",+ "tableFrom": "api_key_organizations",+ "tableTo": "organization_members",+ "columnsFrom": [+ "organization_member_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "api_keys": {+ "name": "api_keys",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "key_hash": {+ "name": "key_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "prefix": {+ "name": "prefix",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "last_used_at": {+ "name": "last_used_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "permissions": {+ "name": "permissions",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'[]'"+ },+ "all_organizations": {+ "name": "all_organizations",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ }+ },+ "indexes": {+ "api_keys_key_hash_unique": {+ "name": "api_keys_key_hash_unique",+ "columns": [+ "key_hash"+ ],+ "isUnique": true+ },+ "key_hash_index": {+ "name": "key_hash_index",+ "columns": [+ "key_hash"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "api_keys_user_id_users_id_fk": {+ "name": "api_keys_user_id_users_id_fk",+ "tableFrom": "api_keys",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "auth_accounts": {+ "name": "auth_accounts",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "account_id": {+ "name": "account_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "provider_id": {+ "name": "provider_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "access_token": {+ "name": "access_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "refresh_token": {+ "name": "refresh_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "access_token_expires_at": {+ "name": "access_token_expires_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "refresh_token_expires_at": {+ "name": "refresh_token_expires_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "id_token": {+ "name": "id_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "password": {+ "name": "password",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "auth_accounts_user_id_users_id_fk": {+ "name": "auth_accounts_user_id_users_id_fk",+ "tableFrom": "auth_accounts",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "auth_sessions": {+ "name": "auth_sessions",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "ip_address": {+ "name": "ip_address",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "user_agent": {+ "name": "user_agent",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "active_organization_id": {+ "name": "active_organization_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "auth_sessions_token_index": {+ "name": "auth_sessions_token_index",+ "columns": [+ "token"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "auth_sessions_user_id_users_id_fk": {+ "name": "auth_sessions_user_id_users_id_fk",+ "tableFrom": "auth_sessions",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ },+ "auth_sessions_active_organization_id_organizations_id_fk": {+ "name": "auth_sessions_active_organization_id_organizations_id_fk",+ "tableFrom": "auth_sessions",+ "tableTo": "organizations",+ "columnsFrom": [+ "active_organization_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "auth_verifications": {+ "name": "auth_verifications",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "auth_verifications_identifier_index": {+ "name": "auth_verifications_identifier_index",+ "columns": [+ "identifier"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "intake_emails": {+ "name": "intake_emails",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "email_address": {+ "name": "email_address",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "organization_id": {+ "name": "organization_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "allowed_origins": {+ "name": "allowed_origins",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'[]'"+ },+ "is_enabled": {+ "name": "is_enabled",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": true+ }+ },+ "indexes": {+ "intake_emails_email_address_unique": {+ "name": "intake_emails_email_address_unique",+ "columns": [+ "email_address"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "intake_emails_organization_id_organizations_id_fk": {+ "name": "intake_emails_organization_id_organizations_id_fk",+ "tableFrom": "intake_emails",+ "tableTo": "organizations",+ "columnsFrom": [+ "organization_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "organization_subscriptions": {+ "name": "organization_subscriptions",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "customer_id": {+ "name": "customer_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "organization_id": {+ "name": "organization_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "plan_id": {+ "name": "plan_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "seats_count": {+ "name": "seats_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "current_period_end": {+ "name": "current_period_end",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "current_period_start": {+ "name": "current_period_start",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "cancel_at_period_end": {+ "name": "cancel_at_period_end",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "organization_subscriptions_organization_id_organizations_id_fk": {+ "name": "organization_subscriptions_organization_id_organizations_id_fk",+ "tableFrom": "organization_subscriptions",+ "tableTo": "organizations",+ "columnsFrom": [+ "organization_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "tagging_rule_actions": {+ "name": "tagging_rule_actions",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "tagging_rule_id": {+ "name": "tagging_rule_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "tag_id": {+ "name": "tag_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "tagging_rule_actions_tagging_rule_id_tagging_rules_id_fk": {+ "name": "tagging_rule_actions_tagging_rule_id_tagging_rules_id_fk",+ "tableFrom": "tagging_rule_actions",+ "tableTo": "tagging_rules",+ "columnsFrom": [+ "tagging_rule_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ },+ "tagging_rule_actions_tag_id_tags_id_fk": {+ "name": "tagging_rule_actions_tag_id_tags_id_fk",+ "tableFrom": "tagging_rule_actions",+ "tableTo": "tags",+ "columnsFrom": [+ "tag_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "tagging_rule_conditions": {+ "name": "tagging_rule_conditions",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "tagging_rule_id": {+ "name": "tagging_rule_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "field": {+ "name": "field",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "operator": {+ "name": "operator",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "is_case_sensitive": {+ "name": "is_case_sensitive",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "tagging_rule_conditions_tagging_rule_id_tagging_rules_id_fk": {+ "name": "tagging_rule_conditions_tagging_rule_id_tagging_rules_id_fk",+ "tableFrom": "tagging_rule_conditions",+ "tableTo": "tagging_rules",+ "columnsFrom": [+ "tagging_rule_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "tagging_rules": {+ "name": "tagging_rules",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "organization_id": {+ "name": "organization_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "enabled": {+ "name": "enabled",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "tagging_rules_organization_id_organizations_id_fk": {+ "name": "tagging_rules_organization_id_organizations_id_fk",+ "tableFrom": "tagging_rules",+ "tableTo": "organizations",+ "columnsFrom": [+ "organization_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "webhook_deliveries": {+ "name": "webhook_deliveries",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "webhook_id": {+ "name": "webhook_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "event_name": {+ "name": "event_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "request_payload": {+ "name": "request_payload",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "response_payload": {+ "name": "response_payload",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "response_status": {+ "name": "response_status",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "webhook_deliveries_webhook_id_webhooks_id_fk": {+ "name": "webhook_deliveries_webhook_id_webhooks_id_fk",+ "tableFrom": "webhook_deliveries",+ "tableTo": "webhooks",+ "columnsFrom": [+ "webhook_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "webhook_events": {+ "name": "webhook_events",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "webhook_id": {+ "name": "webhook_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "event_name": {+ "name": "event_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "webhook_events_webhook_id_event_name_unique": {+ "name": "webhook_events_webhook_id_event_name_unique",+ "columns": [+ "webhook_id",+ "event_name"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "webhook_events_webhook_id_webhooks_id_fk": {+ "name": "webhook_events_webhook_id_webhooks_id_fk",+ "tableFrom": "webhook_events",+ "tableTo": "webhooks",+ "columnsFrom": [+ "webhook_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "webhooks": {+ "name": "webhooks",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "secret": {+ "name": "secret",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "enabled": {+ "name": "enabled",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": true+ },+ "created_by": {+ "name": "created_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "organization_id": {+ "name": "organization_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "webhooks_created_by_users_id_fk": {+ "name": "webhooks_created_by_users_id_fk",+ "tableFrom": "webhooks",+ "tableTo": "users",+ "columnsFrom": [+ "created_by"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "cascade"+ },+ "webhooks_organization_id_organizations_id_fk": {+ "name": "webhooks_organization_id_organizations_id_fk",+ "tableFrom": "webhooks",+ "tableTo": "organizations",+ "columnsFrom": [+ "organization_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ }+ },+ "views": {},+ "enums": {},+ "_meta": {+ "schemas": {},+ "tables": {},+ "columns": {}+ },+ "internal": {+ "indexes": {}+ }+}diff --git a/apps/papra-server/migrations/meta/_journal.json b/apps/papra-server/migrations/meta/_journal.jsonindex 9fa4aaa3..59d95ce3 100644--- a/apps/papra-server/migrations/meta/_journal.json+++ b/apps/papra-server/migrations/meta/_journal.json@@ -50,6 +50,13 @@"when": 1748554484124,"tag": "0006_document-activity-log","breakpoints": true+ },+ {+ "idx": 7,+ "version": "6",+ "when": 1754086182584,+ "tag": "0007_document-activity-log-on-delete-set-null",+ "breakpoints": true}]}diff --git a/apps/papra-server/src/modules/documents/document-activity/document-activity.table.ts b/apps/papra-server/src/modules/documents/document-activity/document-activity.table.tsindex 9a8a1921..bd484e46 100644--- a/apps/papra-server/src/modules/documents/document-activity/document-activity.table.ts+++ b/apps/papra-server/src/modules/documents/document-activity/document-activity.table.ts@@ -15,6 +15,6 @@ export const documentActivityLogTable = sqliteTable('document_activity_log', {event: text('event', { enum: DOCUMENT_ACTIVITY_EVENT_LIST as NonEmptyArray<DocumentActivityEvent> }).notNull(),eventData: text('event_data', { mode: 'json' }).$type<Record<string, unknown>>(),- userId: text('user_id').references(() => usersTable.id, { onDelete: 'no action', onUpdate: 'cascade' }),- tagId: text('tag_id').references(() => tagsTable.id, { onDelete: 'no action', onUpdate: 'cascade' }),+ userId: text('user_id').references(() => usersTable.id, { onDelete: 'set null', onUpdate: 'cascade' }),+ tagId: text('tag_id').references(() => tagsTable.id, { onDelete: 'set null', onUpdate: 'cascade' }),});