diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..126419d --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +node_modules +# Keep environment variables out of version control +.env + +/src/generated/prisma diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..499db90 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,18 @@ +before_script: + - docker info + +stages: + - build + +build-backend: + stage: build + tags: + - shell + - docker-daemon + variables: + IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG + script: + - echo $IMAGE_TAG + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - docker build -t $IMAGE_TAG . + - docker push $IMAGE_TAG diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..015f7ec --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM node:20-alpine +WORKDIR /usr/src/app + +# Package-Dateien +COPY package*.json ./ + +# Dev + Prod Dependencies (für TS-Build nötig) +RUN npm install + +# Restlicher Sourcecode +COPY . . + +# TypeScript Build +RUN npm run build + +# Port freigeben +EXPOSE 3100 + +# Start der App +CMD ["node", "dist/src/index.js"] diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..da98877 --- /dev/null +++ b/TODO.md @@ -0,0 +1,32 @@ +# Projekt To-Do Liste + +## ✅ Erledigt +- JWT-basierte Authentifizierung mit Cookie +- Prefix für Auth-Tabellen (`auth_users`, `auth_roles`, …) +- `/me` liefert User + Rechte (via `auth_get_user_permissions`) +- Basis-Seed für Standardrollen + Rechte eingespielt +- Auth Middleware im Frontend korrigiert (Login-Redirects) +- Nuxt API Plugin unterstützt JWT im Header +- Login-Seite an Nuxt UI Pro (v2) anpassen +- `usePermission()` Composable im Frontend vorbereitet + +--- + +## 🔄 Offene Punkte + +### Backend +- [ ] `/me` erweitern: Rollen + deren Rechte strukturiert zurückgeben (`{ role: "manager", permissions: [...] }`) +- [ ] Loading Flag im Auth-Flow berücksichtigen (damit `me` nicht doppelt feuert) +- [ ] Gemeinsames Schema für Entities (Backend stellt per Endpoint bereit) +- [ ] Soft Delete vereinheitlichen (`archived = true` statt DELETE) +- [ ] Swagger-Doku verbessern (Schemas, Beispiele) + +### Frontend +- [ ] Loading Flag in Middleware/Store einbauen +- [ ] Einheitliches Laden des Schemas beim Start +- [ ] Pinia-Store für Auth/User/Tenant konsolidieren +- [ ] Composable `usePermission(key)` implementieren, um Rechte einfach im Template zu prüfen +- [ ] Entity-Seiten schrittweise auf API-Routen umstellen +- [ ] Page Guards für Routen einbauen (z. B. `/projects/create` nur bei `projects-create`) + +--- \ No newline at end of file diff --git a/db/index.ts b/db/index.ts new file mode 100644 index 0000000..eeb9f5b --- /dev/null +++ b/db/index.ts @@ -0,0 +1,10 @@ +import { drizzle } from "drizzle-orm/node-postgres" +import { Pool } from "pg" +import {secrets} from "../src/utils/secrets"; + +const pool = new Pool({ + connectionString: secrets.DATABASE_URL, + max: 10, // je nach Last +}) + +export const db = drizzle(pool) \ No newline at end of file diff --git a/db/migrations/0000_brief_dark_beast.sql b/db/migrations/0000_brief_dark_beast.sql new file mode 100644 index 0000000..adfe24f --- /dev/null +++ b/db/migrations/0000_brief_dark_beast.sql @@ -0,0 +1,1312 @@ +CREATE TYPE "public"."credential_types" AS ENUM('mail', 'm365');--> statement-breakpoint +CREATE TYPE "public"."folderfunctions" AS ENUM('none', 'yearSubCategory', 'incomingInvoices', 'invoices', 'quotes', 'confirmationOrders', 'deliveryNotes', 'vehicleData', 'reminders', 'taxData', 'deposit', 'timeEvaluations');--> statement-breakpoint +CREATE TYPE "public"."locked_tenant" AS ENUM('maintenance_tenant', 'maintenance', 'general', 'no_subscription');--> statement-breakpoint +CREATE TYPE "public"."notification_channel" AS ENUM('email', 'inapp', 'sms', 'push', 'webhook');--> statement-breakpoint +CREATE TYPE "public"."notification_severity" AS ENUM('info', 'success', 'warning', 'error');--> statement-breakpoint +CREATE TYPE "public"."notification_status" AS ENUM('queued', 'sent', 'failed', 'read');--> statement-breakpoint +CREATE TYPE "public"."payment_types" AS ENUM('transfer', 'direct_debit');--> statement-breakpoint +CREATE TYPE "public"."texttemplatepositions" AS ENUM('startText', 'endText');--> statement-breakpoint +CREATE TYPE "public"."times_state" AS ENUM('submitted', 'approved', 'draft');--> statement-breakpoint +CREATE TABLE "accounts" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "accounts_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "number" text NOT NULL, + "label" text NOT NULL, + "description" text +); +--> statement-breakpoint +CREATE TABLE "auth_profiles" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "user_id" uuid, + "tenant_id" bigint NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "first_name" text NOT NULL, + "last_name" text NOT NULL, + "full_name" text GENERATED ALWAYS AS (((first_name || ' ') || last_name)) STORED, + "mobile_tel" text, + "fixed_tel" text, + "salutation" text, + "employee_number" text, + "weekly_working_hours" double precision DEFAULT 0, + "annual_paid_leave_days" bigint, + "weekly_regular_working_hours" jsonb DEFAULT '{}', + "clothing_size_top" text, + "clothing_size_bottom" text, + "clothing_size_shoe" text, + "email_signature" text DEFAULT '
Mit freundlichen Grüßen
', + "birthday" date, + "entry_date" date DEFAULT now(), + "automatic_hour_corrections" jsonb DEFAULT '[]', + "recreation_days_compensation" boolean DEFAULT true NOT NULL, + "customer_for_portal" bigint, + "pinned_on_navigation" jsonb DEFAULT '[]' NOT NULL, + "email" text, + "token_id" text, + "weekly_working_days" double precision, + "old_profile_id" uuid, + "temp_config" jsonb, + "state_code" text DEFAULT 'DE-NI', + "contract_type" text, + "position" text, + "qualification" text, + "address_street" text, + "address_zip" text, + "address_city" text, + "active" boolean DEFAULT true NOT NULL +); +--> statement-breakpoint +CREATE TABLE "auth_role_permissions" ( + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "role_id" uuid NOT NULL, + "permission" text NOT NULL +); +--> statement-breakpoint +CREATE TABLE "auth_roles" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "name" text NOT NULL, + "description" text, + "created_by" uuid, + "tenant_id" bigint +); +--> statement-breakpoint +CREATE TABLE "auth_tenant_users" ( + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "tenant_id" bigint NOT NULL, + "user_id" uuid NOT NULL, + "created_by" uuid +); +--> statement-breakpoint +CREATE TABLE "auth_user_roles" ( + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "user_id" uuid NOT NULL, + "role_id" uuid NOT NULL, + "tenant_id" bigint NOT NULL, + "created_by" uuid +); +--> statement-breakpoint +CREATE TABLE "auth_users" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "email" text NOT NULL, + "password_hash" text NOT NULL, + "multi_tenant" boolean DEFAULT true NOT NULL, + "must_change_password" boolean DEFAULT false NOT NULL, + "updated_at" timestamp with time zone, + "ported" boolean DEFAULT true NOT NULL +); +--> statement-breakpoint +CREATE TABLE "bankaccounts" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "bankaccounts_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "name" text, + "iban" text NOT NULL, + "tenant" bigint NOT NULL, + "bankId" text NOT NULL, + "ownerName" text, + "accountId" text NOT NULL, + "balance" double precision, + "expired" boolean DEFAULT false NOT NULL, + "datevNumber" text, + "synced_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone, + "updated_by" uuid, + "archived" boolean DEFAULT false NOT NULL +); +--> statement-breakpoint +CREATE TABLE "bankrequisitions" ( + "id" uuid PRIMARY KEY NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "institutionId" text, + "tenant" bigint, + "status" text, + "updated_at" timestamp with time zone, + "updated_by" uuid +); +--> statement-breakpoint +CREATE TABLE "bankstatements" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "bankstatements_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "account" bigint NOT NULL, + "date" text NOT NULL, + "credIban" text, + "credName" text, + "text" text, + "amount" double precision NOT NULL, + "tenant" bigint NOT NULL, + "debIban" text, + "debName" text, + "gocardlessId" text, + "currency" text, + "valueDate" text, + "incomingInvoice" bigint, + "mandateId" text, + "contract" bigint, + "createdDocument" bigint, + "archived" boolean DEFAULT false NOT NULL, + "updated_at" timestamp with time zone, + "updated_by" uuid +); +--> statement-breakpoint +CREATE TABLE "checkexecutions" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "check" uuid, + "executed_at" timestamp, + "description" text +); +--> statement-breakpoint +CREATE TABLE "checks" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "vehicle" bigint, + "inventoryitem" bigint, + "tenant" bigint, + "name" text, + "type" text, + "distance" bigint DEFAULT 1, + "distanceUnit" text DEFAULT 'days', + "description" text, + "profiles" jsonb DEFAULT '[]'::jsonb NOT NULL, + "archived" boolean DEFAULT false NOT NULL, + "updated_at" timestamp with time zone, + "updated_by" uuid +); +--> statement-breakpoint +CREATE TABLE "citys" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "citys_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "name" text, + "short" text, + "long" text, + "geometry" jsonb, + "zip" bigint, + "districtCode" bigint, + "countryName" text, + "countryCode" bigint, + "districtName" text, + "geopoint" text +); +--> statement-breakpoint +CREATE TABLE "contacts" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "contacts_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "firstName" text, + "lastName" text, + "email" text, + "customer" bigint, + "tenant" bigint NOT NULL, + "phoneMobile" text, + "phoneHome" text, + "heroId" text, + "role" text, + "fullName" text, + "salutation" text, + "vendor" bigint, + "active" boolean DEFAULT true NOT NULL, + "birthday" date, + "notes" text, + "profiles" jsonb DEFAULT '[]'::jsonb NOT NULL, + "archived" boolean DEFAULT false NOT NULL, + "title" text, + "updated_at" timestamp with time zone, + "updated_by" uuid +); +--> statement-breakpoint +CREATE TABLE "contracts" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "contracts_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "tenant" bigint NOT NULL, + "name" text NOT NULL, + "customer" bigint NOT NULL, + "notes" text, + "active" boolean DEFAULT true NOT NULL, + "recurring" boolean DEFAULT false NOT NULL, + "rhythm" jsonb, + "startDate" timestamp with time zone, + "endDate" timestamp with time zone, + "signDate" timestamp with time zone, + "duration" text, + "contact" bigint, + "bankingIban" text, + "bankingBIC" text, + "bankingName" text, + "bankingOwner" text, + "sepaRef" text, + "sepaDate" timestamp with time zone, + "paymentType" text, + "invoiceDispatch" text, + "ownFields" jsonb DEFAULT '{}'::jsonb NOT NULL, + "profiles" jsonb DEFAULT '[]'::jsonb NOT NULL, + "archived" boolean DEFAULT false NOT NULL, + "contractNumber" text, + "updated_at" timestamp with time zone, + "updated_by" uuid +); +--> statement-breakpoint +CREATE TABLE "costcentres" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "tenant" bigint NOT NULL, + "number" text NOT NULL, + "name" text NOT NULL, + "vehicle" bigint, + "project" bigint, + "inventoryitem" bigint, + "description" text, + "archived" boolean DEFAULT false NOT NULL, + "profiles" jsonb DEFAULT '[]'::jsonb NOT NULL, + "updated_at" timestamp with time zone, + "updated_by" uuid +); +--> statement-breakpoint +CREATE TABLE "countrys" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "countrys_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "name" text NOT NULL +); +--> statement-breakpoint +CREATE TABLE "createddocuments" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "createddocuments_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "tenant" bigint NOT NULL, + "type" text DEFAULT 'INVOICE' NOT NULL, + "customer" bigint, + "contact" bigint, + "address" jsonb, + "project" bigint, + "documentNumber" text, + "documentDate" text, + "state" text DEFAULT 'Entwurf' NOT NULL, + "info" jsonb, + "createdBy" uuid, + "title" text, + "description" text, + "startText" text, + "endText" text, + "rows" jsonb DEFAULT '[]'::jsonb, + "deliveryDateType" text, + "paymentDays" smallint, + "deliveryDate" text, + "contactPerson" uuid, + "serialConfig" jsonb DEFAULT '{}'::jsonb, + "linkedDocument" bigint, + "agriculture" jsonb, + "letterhead" bigint, + "advanceInvoiceResolved" boolean DEFAULT false NOT NULL, + "usedAdvanceInvoices" jsonb DEFAULT '[]'::jsonb NOT NULL, + "archived" boolean DEFAULT false NOT NULL, + "deliveryDateEnd" text, + "plant" bigint, + "taxType" text, + "customSurchargePercentage" smallint DEFAULT 0 NOT NULL, + "report" jsonb DEFAULT '{}'::jsonb NOT NULL, + "availableInPortal" boolean DEFAULT false NOT NULL, + "updated_at" timestamp with time zone, + "updated_by" uuid, + "created_by" uuid, + "payment_type" text DEFAULT 'transfer', + "contract" bigint +); +--> statement-breakpoint +CREATE TABLE "createdletters" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "tenant" bigint, + "customer" bigint, + "vendor" bigint, + "content_json" jsonb DEFAULT '[]'::jsonb, + "content_text" text, + "updated_at" timestamp with time zone, + "updated_by" uuid, + "archived" boolean DEFAULT false NOT NULL +); +--> statement-breakpoint +CREATE TABLE "customers" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "customers_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "customerNumber" text NOT NULL, + "name" text NOT NULL, + "tenant" bigint NOT NULL, + "infoData" jsonb DEFAULT '{}'::jsonb, + "active" boolean DEFAULT true NOT NULL, + "notes" text, + "type" text DEFAULT 'Privat', + "heroId" text, + "isCompany" boolean DEFAULT false NOT NULL, + "profiles" jsonb DEFAULT '[]'::jsonb NOT NULL, + "customPaymentDays" smallint, + "firstname" text, + "lastname" text, + "archived" boolean DEFAULT false NOT NULL, + "customSurchargePercentage" smallint DEFAULT 0 NOT NULL, + "salutation" text, + "title" text, + "nameAddition" text, + "availableInPortal" boolean DEFAULT false NOT NULL, + "updated_at" timestamp with time zone, + "updated_by" uuid, + "custom_payment_type" text +); +--> statement-breakpoint +CREATE TABLE "devices" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "name" text NOT NULL, + "type" text NOT NULL, + "tenant" bigint, + "password" text, + "externalId" text +); +--> statement-breakpoint +CREATE TABLE "documentboxes" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "space" bigint, + "key" text NOT NULL, + "tenant" bigint NOT NULL, + "archived" boolean DEFAULT false NOT NULL, + "updated_at" timestamp with time zone, + "updated_by" uuid +); +--> statement-breakpoint +CREATE TABLE "events" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "events_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "tenant" bigint NOT NULL, + "name" text NOT NULL, + "startDate" timestamp with time zone NOT NULL, + "endDate" timestamp with time zone, + "eventtype" text DEFAULT 'Umsetzung', + "project" bigint, + "resources" jsonb DEFAULT '[]'::jsonb, + "notes" text, + "link" text, + "profiles" jsonb DEFAULT '[]'::jsonb NOT NULL, + "archived" boolean DEFAULT false NOT NULL, + "vehicles" jsonb DEFAULT '[]'::jsonb NOT NULL, + "inventoryitems" jsonb DEFAULT '[]'::jsonb NOT NULL, + "inventoryitemgroups" jsonb DEFAULT '[]'::jsonb NOT NULL, + "customer" bigint, + "vendor" bigint, + "updated_at" timestamp with time zone, + "updated_by" uuid +); +--> statement-breakpoint +CREATE TABLE "files" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "path" text, + "tenant" bigint NOT NULL, + "project" bigint, + "customer" bigint, + "contract" bigint, + "vendor" bigint, + "incominginvoice" bigint, + "plant" bigint, + "createddocument" bigint, + "vehicle" bigint, + "product" bigint, + "check" uuid, + "inventoryitem" bigint, + "folder" uuid, + "mimeType" text, + "archived" boolean DEFAULT false NOT NULL, + "space" bigint, + "type" uuid, + "documentbox" uuid, + "name" text, + "updated_at" timestamp with time zone, + "updated_by" uuid, + "created_by" uuid, + "auth_profile" uuid +); +--> statement-breakpoint +CREATE TABLE "filetags" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "name" text NOT NULL, + "color" text, + "tenant" bigint NOT NULL, + "createddocumenttype" text DEFAULT '', + "incomingDocumentType" text, + "archived" boolean DEFAULT false NOT NULL +); +--> statement-breakpoint +CREATE TABLE "folders" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "tenant" bigint NOT NULL, + "name" text NOT NULL, + "icon" text, + "parent" uuid, + "isSystemUsed" boolean DEFAULT false NOT NULL, + "function" "folderfunctions", + "year" integer, + "standardFiletype" uuid, + "standardFiletypeIsOptional" boolean DEFAULT true NOT NULL, + "updated_at" timestamp with time zone, + "updated_by" uuid, + "archived" boolean DEFAULT false NOT NULL +); +--> statement-breakpoint +CREATE TABLE "exports" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "exports_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "tenant_id" bigint NOT NULL, + "start_date" timestamp with time zone NOT NULL, + "end_date" timestamp with time zone NOT NULL, + "valid_until" timestamp with time zone, + "type" text DEFAULT 'datev' NOT NULL, + "url" text NOT NULL, + "file_path" text +); +--> statement-breakpoint +CREATE TABLE "globalmessages" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "globalmessages_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "title" text, + "description" text +); +--> statement-breakpoint +CREATE TABLE "globalmessagesseen" ( + "message" bigint NOT NULL, + "seen_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "helpdesk_channel_instances" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "tenant_id" bigint NOT NULL, + "type_id" text NOT NULL, + "name" text NOT NULL, + "is_active" boolean DEFAULT true NOT NULL, + "config" jsonb NOT NULL, + "public_config" jsonb DEFAULT '{}'::jsonb NOT NULL, + "public_token" text, + "secret_token" text, + "created_by" uuid, + "created_at" timestamp with time zone DEFAULT now(), + CONSTRAINT "helpdesk_channel_instances_public_token_unique" UNIQUE("public_token") +); +--> statement-breakpoint +CREATE TABLE "helpdesk_channel_types" ( + "id" text PRIMARY KEY NOT NULL, + "description" text NOT NULL +); +--> statement-breakpoint +CREATE TABLE "helpdesk_contacts" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "tenant_id" bigint NOT NULL, + "customer_id" bigint, + "email" text, + "phone" text, + "external_ref" jsonb, + "display_name" text, + "created_at" timestamp with time zone DEFAULT now(), + "source_channel_id" uuid, + "contact_id" bigint +); +--> statement-breakpoint +CREATE TABLE "helpdesk_conversation_participants" ( + "conversation_id" uuid NOT NULL, + "user_id" uuid NOT NULL, + "role" text +); +--> statement-breakpoint +CREATE TABLE "helpdesk_conversations" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "tenant_id" bigint NOT NULL, + "channel_instance_id" uuid NOT NULL, + "contact_id" uuid, + "subject" text, + "status" text DEFAULT 'open' NOT NULL, + "priority" text DEFAULT 'normal', + "assignee_user_id" uuid, + "last_message_at" timestamp with time zone, + "created_at" timestamp with time zone DEFAULT now(), + "customer_id" bigint, + "contact_person_id" bigint, + "ticket_number" text +); +--> statement-breakpoint +CREATE TABLE "helpdesk_messages" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "tenant_id" bigint NOT NULL, + "conversation_id" uuid NOT NULL, + "direction" text NOT NULL, + "author_user_id" uuid, + "payload" jsonb NOT NULL, + "raw_meta" jsonb, + "created_at" timestamp with time zone DEFAULT now(), + "contact_id" uuid, + "external_message_id" text, + "received_at" timestamp with time zone DEFAULT now(), + CONSTRAINT "helpdesk_messages_external_message_id_unique" UNIQUE("external_message_id") +); +--> statement-breakpoint +CREATE TABLE "helpdesk_routing_rules" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "tenant_id" bigint NOT NULL, + "name" text NOT NULL, + "condition" jsonb NOT NULL, + "action" jsonb NOT NULL, + "created_by" uuid, + "created_at" timestamp with time zone DEFAULT now() +); +--> statement-breakpoint +CREATE TABLE "historyitems" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "historyitems_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "text" text NOT NULL, + "customer" bigint, + "tenant" bigint NOT NULL, + "vendor" bigint, + "project" bigint, + "plant" bigint, + "incomingInvoice" bigint, + "contact" bigint, + "inventoryitem" bigint, + "product" bigint, + "event" bigint, + "newVal" text, + "oldVal" text, + "task" bigint, + "vehicle" bigint, + "bankstatement" bigint, + "space" bigint, + "config" jsonb, + "projecttype" bigint, + "check" uuid, + "service" bigint, + "createddocument" bigint, + "file" uuid, + "inventoryitemgroup" uuid, + "source" text DEFAULT 'Software', + "costcentre" uuid, + "ownaccount" uuid, + "documentbox" uuid, + "hourrate" uuid, + "created_by" uuid, + "action" text +); +--> statement-breakpoint +CREATE TABLE "holidays" ( + "id" bigint PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "holidays_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "date" date NOT NULL, + "name" text NOT NULL, + "state_code" text NOT NULL, + "created_at" timestamp with time zone DEFAULT now() +); +--> statement-breakpoint +CREATE TABLE "hourrates" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "tenant" bigint NOT NULL, + "name" text NOT NULL, + "purchasePrice" double precision NOT NULL, + "sellingPrice" double precision NOT NULL, + "archived" boolean DEFAULT false NOT NULL, + "updated_at" timestamp with time zone, + "updated_by" uuid +); +--> statement-breakpoint +CREATE TABLE "incominginvoices" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "incominginvoices_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "tenant" bigint NOT NULL, + "state" text DEFAULT 'Entwurf' NOT NULL, + "vendor" bigint, + "reference" text, + "date" text, + "document" bigint, + "dueDate" text, + "description" text, + "paymentType" text, + "accounts" jsonb DEFAULT '[{"account":null,"taxType":null,"amountNet":null,"amountTax":19,"costCentre":null}]'::jsonb NOT NULL, + "paid" boolean DEFAULT false NOT NULL, + "expense" boolean DEFAULT true NOT NULL, + "updated_at" timestamp with time zone, + "updated_by" uuid, + "archived" boolean DEFAULT false NOT NULL +); +--> statement-breakpoint +CREATE TABLE "inventoryitemgroups" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "tenant" bigint NOT NULL, + "name" text NOT NULL, + "inventoryitems" jsonb DEFAULT '[]'::jsonb NOT NULL, + "description" text, + "archived" boolean DEFAULT false NOT NULL, + "profiles" jsonb DEFAULT '[]'::jsonb NOT NULL, + "usePlanning" boolean DEFAULT false NOT NULL, + "updated_at" timestamp with time zone, + "updated_by" uuid +); +--> statement-breakpoint +CREATE TABLE "inventoryitems" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "inventoryitems_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "name" text NOT NULL, + "usePlanning" boolean DEFAULT false NOT NULL, + "description" text, + "tenant" bigint NOT NULL, + "currentSpace" bigint, + "articleNumber" text, + "serialNumber" text, + "purchaseDate" date, + "vendor" bigint, + "quantity" bigint DEFAULT 0 NOT NULL, + "purchasePrice" double precision DEFAULT 0, + "manufacturer" text, + "manufacturerNumber" text, + "currentValue" double precision, + "archived" boolean DEFAULT false NOT NULL, + "profiles" jsonb DEFAULT '[]'::jsonb NOT NULL, + "updated_at" timestamp with time zone, + "updated_by" uuid +); +--> statement-breakpoint +CREATE TABLE "letterheads" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "letterheads_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "tenant" bigint NOT NULL, + "name" text DEFAULT 'Standard', + "path" text NOT NULL, + "documentTypes" text[] DEFAULT '{}' NOT NULL, + "updated_at" timestamp with time zone, + "updated_by" uuid, + "archived" boolean DEFAULT false NOT NULL +); +--> statement-breakpoint +CREATE TABLE "movements" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "movements_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "quantity" bigint NOT NULL, + "productId" bigint NOT NULL, + "spaceId" bigint, + "tenant" bigint NOT NULL, + "projectId" bigint, + "notes" text, + "serials" text[], + "updated_at" timestamp with time zone, + "updated_by" uuid +); +--> statement-breakpoint +CREATE TABLE "notifications_event_types" ( + "event_key" text PRIMARY KEY NOT NULL, + "display_name" text NOT NULL, + "description" text, + "category" text, + "severity" "notification_severity" DEFAULT 'info' NOT NULL, + "allowed_channels" jsonb DEFAULT '["inapp","email"]'::jsonb NOT NULL, + "payload_schema" jsonb, + "is_active" boolean DEFAULT true NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "notifications_items" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "tenant_id" bigint NOT NULL, + "user_id" uuid NOT NULL, + "event_type" text NOT NULL, + "title" text NOT NULL, + "message" text NOT NULL, + "payload" jsonb, + "channel" "notification_channel" NOT NULL, + "status" "notification_status" DEFAULT 'queued' NOT NULL, + "error" text, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "sent_at" timestamp with time zone, + "read_at" timestamp with time zone +); +--> statement-breakpoint +CREATE TABLE "notifications_preferences" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "tenant_id" bigint NOT NULL, + "user_id" uuid NOT NULL, + "event_type" text NOT NULL, + "channel" "notification_channel" NOT NULL, + "enabled" boolean DEFAULT true NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "notifications_preferences_defaults" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "tenant_id" bigint NOT NULL, + "event_key" text NOT NULL, + "channel" "notification_channel" NOT NULL, + "enabled" boolean DEFAULT true NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "ownaccounts" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "tenant" bigint NOT NULL, + "number" text NOT NULL, + "name" text NOT NULL, + "description" text, + "archived" boolean DEFAULT false NOT NULL, + "profiles" jsonb DEFAULT '[]'::jsonb NOT NULL, + "updated_at" timestamp with time zone, + "updated_by" uuid +); +--> statement-breakpoint +CREATE TABLE "plants" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "plants_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "tenant" bigint NOT NULL, + "name" text NOT NULL, + "customer" bigint, + "infoData" jsonb, + "contract" bigint, + "description" jsonb DEFAULT '{"html":"","json":[],"text":""}'::jsonb, + "archived" boolean DEFAULT false NOT NULL, + "profiles" jsonb DEFAULT '[]'::jsonb NOT NULL, + "updated_at" timestamp with time zone, + "updated_by" uuid +); +--> statement-breakpoint +CREATE TABLE "productcategories" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "productcategories_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "tenant" bigint NOT NULL, + "name" text NOT NULL, + "description" text, + "archived" boolean DEFAULT false NOT NULL, + "updated_at" timestamp with time zone, + "updated_by" uuid +); +--> statement-breakpoint +CREATE TABLE "products" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "products_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "name" text NOT NULL, + "manufacturer" text, + "unit" bigint NOT NULL, + "tags" json DEFAULT '[]'::json NOT NULL, + "tenant" bigint NOT NULL, + "ean" text, + "barcode" text, + "purchasePrice" double precision, + "sellingPrice" double precision, + "description" text, + "manufacturerNumber" text, + "vendorAllocation" jsonb DEFAULT '[]'::jsonb, + "articleNumber" text, + "barcodes" text[] DEFAULT '{}' NOT NULL, + "productcategories" jsonb DEFAULT '[]'::jsonb, + "archived" boolean DEFAULT false NOT NULL, + "taxPercentage" smallint DEFAULT 19 NOT NULL, + "markupPercentage" double precision, + "updated_at" timestamp with time zone, + "updated_by" uuid +); +--> statement-breakpoint +CREATE TABLE "projects" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "projects_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "tenant" bigint NOT NULL, + "name" text NOT NULL, + "notes" text, + "customer" bigint, + "phases" jsonb DEFAULT '[]'::jsonb, + "description" json, + "forms" jsonb DEFAULT '[]'::jsonb, + "heroId" text, + "measure" text, + "material" jsonb, + "plant" bigint, + "profiles" uuid[] DEFAULT '{}' NOT NULL, + "projectNumber" text, + "contract" bigint, + "projectType" text DEFAULT 'Projekt', + "projecttype" bigint, + "archived" boolean DEFAULT false NOT NULL, + "customerRef" text, + "updated_at" timestamp with time zone, + "updated_by" uuid, + "active_phase" text +); +--> statement-breakpoint +CREATE TABLE "projecttypes" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "projecttypes_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "name" text NOT NULL, + "initialPhases" jsonb, + "addablePhases" jsonb, + "icon" text, + "tenant" bigint NOT NULL, + "archived" boolean DEFAULT false NOT NULL, + "updated_at" timestamp with time zone, + "updated_by" uuid +); +--> statement-breakpoint +CREATE TABLE "servicecategories" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "servicecategories_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "tenant" bigint NOT NULL, + "name" text NOT NULL, + "description" text, + "discount" double precision DEFAULT 0, + "archived" boolean DEFAULT false NOT NULL, + "updated_at" timestamp with time zone, + "updated_by" uuid +); +--> statement-breakpoint +CREATE TABLE "services" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "services_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "name" text NOT NULL, + "sellingPrice" double precision, + "description" text, + "tenant" bigint NOT NULL, + "unit" bigint, + "serviceNumber" bigint, + "tags" jsonb DEFAULT '[]'::jsonb, + "servicecategories" jsonb DEFAULT '[]'::jsonb NOT NULL, + "archived" boolean DEFAULT false NOT NULL, + "purchasePriceComposed" jsonb DEFAULT '{"total":0}'::jsonb NOT NULL, + "sellingPriceComposed" jsonb DEFAULT '{"total":0}'::jsonb NOT NULL, + "taxPercentage" smallint DEFAULT 19 NOT NULL, + "materialComposition" jsonb DEFAULT '[]'::jsonb NOT NULL, + "personalComposition" jsonb DEFAULT '[]'::jsonb NOT NULL, + "updated_at" timestamp with time zone, + "updated_by" uuid +); +--> statement-breakpoint +CREATE TABLE "spaces" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "spaces_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "name" text, + "type" text NOT NULL, + "tenant" bigint NOT NULL, + "spaceNumber" text NOT NULL, + "parentSpace" bigint, + "infoData" jsonb DEFAULT '{"zip":"","city":"","streetNumber":""}'::jsonb NOT NULL, + "description" text, + "archived" boolean DEFAULT false NOT NULL, + "updated_at" timestamp with time zone, + "updated_by" uuid +); +--> statement-breakpoint +CREATE TABLE "staff_time_entries" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "tenant_id" bigint NOT NULL, + "user_id" uuid NOT NULL, + "started_at" timestamp with time zone NOT NULL, + "stopped_at" timestamp with time zone, + "duration_minutes" integer GENERATED ALWAYS AS (CASE + WHEN stopped_at IS NOT NULL + THEN (EXTRACT(epoch FROM (stopped_at - started_at)) / 60) + ELSE NULL + END) STORED, + "type" text DEFAULT 'work', + "description" text, + "created_at" timestamp with time zone DEFAULT now(), + "updated_at" timestamp with time zone DEFAULT now(), + "archived" boolean DEFAULT false NOT NULL, + "updated_by" uuid, + "source" text, + "state" times_state DEFAULT 'draft' NOT NULL, + "device" uuid, + "internal_note" text, + "vacation_reason" text, + "vacation_days" numeric(5, 2), + "approved_by" uuid, + "approved_at" timestamp with time zone, + "sick_reason" text +); +--> statement-breakpoint +CREATE TABLE "staff_time_entry_connects" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "time_entry_id" uuid NOT NULL, + "project_id" bigint, + "started_at" timestamp with time zone NOT NULL, + "stopped_at" timestamp with time zone NOT NULL, + "duration_minutes" integer GENERATED ALWAYS AS ((EXTRACT(epoch FROM (stopped_at - started_at)) / 60)) STORED, + "notes" text, + "created_at" timestamp with time zone DEFAULT now(), + "updated_at" timestamp with time zone DEFAULT now() +); +--> statement-breakpoint +CREATE TABLE "staff_zeitstromtimestamps" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "tenant" bigint NOT NULL, + "profile" uuid NOT NULL, + "key" text NOT NULL, + "intent" text NOT NULL, + "time" timestamp with time zone NOT NULL, + "staff_time_entry" uuid, + "internal_note" text +); +--> statement-breakpoint +CREATE TABLE "statementallocations" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "bs_id" integer NOT NULL, + "cd_id" integer, + "amount" double precision DEFAULT 0 NOT NULL, + "ii_id" bigint, + "tenant" bigint NOT NULL, + "account" bigint, + "created_at" timestamp DEFAULT now(), + "ownaccount" uuid, + "description" text, + "customer" bigint, + "vendor" bigint, + "updated_at" timestamp with time zone, + "updated_by" uuid, + "archived" boolean DEFAULT false NOT NULL +); +--> statement-breakpoint +CREATE TABLE "tasks" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "tasks_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "name" text NOT NULL, + "description" text, + "categorie" text, + "tenant" bigint NOT NULL, + "user_id" uuid, + "project" bigint, + "plant" bigint, + "customer" bigint, + "profiles" jsonb DEFAULT '[]'::jsonb NOT NULL, + "archived" boolean DEFAULT false NOT NULL, + "updated_at" timestamp with time zone, + "updated_by" uuid +); +--> statement-breakpoint +CREATE TABLE "taxtypes" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "taxtypes_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "label" text NOT NULL, + "percentage" bigint NOT NULL, + "updated_at" timestamp with time zone, + "updated_by" uuid +); +--> statement-breakpoint +CREATE TABLE "tenants" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "tenants_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "name" text NOT NULL, + "short" text NOT NULL, + "calendarConfig" jsonb DEFAULT '{"eventTypes":[{"color":"blue","label":"Büro"},{"color":"yellow","label":"Besprechung"},{"color":"green","label":"Umsetzung"},{"color":"red","label":"Vor Ort Termin"}]}'::jsonb, + "timeConfig" jsonb DEFAULT '{}'::jsonb NOT NULL, + "tags" jsonb DEFAULT '{"products":[],"documents":[]}'::jsonb NOT NULL, + "measures" jsonb DEFAULT '[{"name":"Netzwerktechnik","short":"NWT"},{"name":"Elektrotechnik","short":"ELT"},{"name":"Photovoltaik","short":"PV"},{"name":"Videüberwachung","short":"VÜA"},{"name":"Projekt","short":"PRJ"},{"name":"Smart Home","short":"SHO"}]'::jsonb NOT NULL, + "businessInfo" jsonb DEFAULT '{"zip":"","city":"","name":"","street":""}'::jsonb, + "features" jsonb DEFAULT '{"objects":true,"calendar":true,"contacts":true,"projects":true,"vehicles":true,"contracts":true,"inventory":true,"accounting":true,"timeTracking":true,"planningBoard":true,"workingTimeTracking":true}'::jsonb, + "ownFields" jsonb, + "numberRanges" jsonb DEFAULT '{"vendors":{"prefix":"","suffix":"","nextNumber":10000},"customers":{"prefix":"","suffix":"","nextNumber":10000},"products":{"prefix":"AT-","suffix":"","nextNumber":1000},"quotes":{"prefix":"AN-","suffix":"","nextNumber":1000},"confirmationOrders":{"prefix":"AB-","suffix":"","nextNumber":1000},"invoices":{"prefix":"RE-","suffix":"","nextNumber":1000},"spaces":{"prefix":"LP-","suffix":"","nextNumber":1000},"inventoryitems":{"prefix":"IA-","suffix":"","nextNumber":1000},"projects":{"prefix":"PRJ-","suffix":"","nextNumber":1000},"costcentres":{"prefix":"KST-","suffix":"","nextNumber":1000}}'::jsonb NOT NULL, + "standardEmailForInvoices" text, + "extraModules" jsonb DEFAULT '[]'::jsonb NOT NULL, + "isInTrial" boolean DEFAULT false, + "trialEndDate" date, + "stripeCustomerId" text, + "hasActiveLicense" boolean DEFAULT false NOT NULL, + "userLicenseCount" integer DEFAULT 0 NOT NULL, + "workstationLicenseCount" integer DEFAULT 0 NOT NULL, + "standardPaymentDays" smallint DEFAULT 14 NOT NULL, + "dokuboxEmailAddresses" jsonb DEFAULT '[]'::jsonb, + "dokuboxkey" uuid DEFAULT gen_random_uuid() NOT NULL, + "autoPrepareIncomingInvoices" boolean DEFAULT true, + "portalDomain" text, + "portalConfig" jsonb DEFAULT '{"primayColor":"#69c350"}'::jsonb NOT NULL, + "updated_at" timestamp with time zone, + "updated_by" uuid, + "locked" "locked_tenant" +); +--> statement-breakpoint +CREATE TABLE "texttemplates" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "texttemplates_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "tenant" bigint NOT NULL, + "name" text NOT NULL, + "text" text NOT NULL, + "documentType" text DEFAULT '', + "default" boolean DEFAULT false NOT NULL, + "pos" texttemplatepositions NOT NULL, + "archived" boolean DEFAULT false NOT NULL, + "updated_at" timestamp with time zone, + "updated_by" uuid +); +--> statement-breakpoint +CREATE TABLE "units" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "units_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "name" text NOT NULL, + "single" text NOT NULL, + "multiple" text, + "short" text, + "step" text DEFAULT '1' NOT NULL +); +--> statement-breakpoint +CREATE TABLE "user_credentials" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "user_id" uuid NOT NULL, + "updated_at" timestamp with time zone, + "tenant_id" bigint NOT NULL, + "smtp_port" numeric, + "smtp_ssl" boolean, + "type" "credential_types" NOT NULL, + "imap_port" numeric, + "imap_ssl" boolean, + "email_encrypted" jsonb, + "password_encrypted" jsonb, + "smtp_host_encrypted" jsonb, + "imap_host_encrypted" jsonb, + "access_token_encrypted" jsonb, + "refresh_token_encrypted" jsonb +); +--> statement-breakpoint +CREATE TABLE "vehicles" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "vehicles_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "tenant" bigint NOT NULL, + "licensePlate" text, + "name" text, + "type" text, + "active" boolean DEFAULT true, + "driver" uuid, + "vin" text, + "tankSize" double precision DEFAULT 0 NOT NULL, + "archived" boolean DEFAULT false NOT NULL, + "buildYear" text, + "towingCapacity" bigint, + "powerInKW" bigint, + "color" text, + "profiles" jsonb DEFAULT '[]'::jsonb NOT NULL, + "updated_at" timestamp with time zone, + "updated_by" uuid +); +--> statement-breakpoint +CREATE TABLE "vendors" ( + "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "vendors_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "name" text NOT NULL, + "vendorNumber" text NOT NULL, + "tenant" bigint NOT NULL, + "infoData" jsonb DEFAULT '{}'::jsonb NOT NULL, + "notes" text, + "hasSEPA" boolean DEFAULT false NOT NULL, + "profiles" jsonb DEFAULT '[]'::jsonb NOT NULL, + "archived" boolean DEFAULT false NOT NULL, + "defaultPaymentMethod" text, + "updated_at" timestamp with time zone, + "updated_by" uuid +); +--> statement-breakpoint +ALTER TABLE "auth_profiles" ADD CONSTRAINT "auth_profiles_user_id_auth_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "auth_role_permissions" ADD CONSTRAINT "auth_role_permissions_role_id_auth_roles_id_fk" FOREIGN KEY ("role_id") REFERENCES "public"."auth_roles"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "auth_roles" ADD CONSTRAINT "auth_roles_created_by_auth_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "auth_tenant_users" ADD CONSTRAINT "auth_tenant_users_created_by_auth_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "auth_user_roles" ADD CONSTRAINT "auth_user_roles_user_id_auth_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "auth_user_roles" ADD CONSTRAINT "auth_user_roles_role_id_auth_roles_id_fk" FOREIGN KEY ("role_id") REFERENCES "public"."auth_roles"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "auth_user_roles" ADD CONSTRAINT "auth_user_roles_created_by_auth_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "bankaccounts" ADD CONSTRAINT "bankaccounts_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "bankaccounts" ADD CONSTRAINT "bankaccounts_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "bankrequisitions" ADD CONSTRAINT "bankrequisitions_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "bankrequisitions" ADD CONSTRAINT "bankrequisitions_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "bankstatements" ADD CONSTRAINT "bankstatements_account_bankaccounts_id_fk" FOREIGN KEY ("account") REFERENCES "public"."bankaccounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "bankstatements" ADD CONSTRAINT "bankstatements_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "bankstatements" ADD CONSTRAINT "bankstatements_incomingInvoice_incominginvoices_id_fk" FOREIGN KEY ("incomingInvoice") REFERENCES "public"."incominginvoices"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "bankstatements" ADD CONSTRAINT "bankstatements_contract_contracts_id_fk" FOREIGN KEY ("contract") REFERENCES "public"."contracts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "bankstatements" ADD CONSTRAINT "bankstatements_createdDocument_createddocuments_id_fk" FOREIGN KEY ("createdDocument") REFERENCES "public"."createddocuments"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "bankstatements" ADD CONSTRAINT "bankstatements_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "checkexecutions" ADD CONSTRAINT "checkexecutions_check_checks_id_fk" FOREIGN KEY ("check") REFERENCES "public"."checks"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "checks" ADD CONSTRAINT "checks_vehicle_vehicles_id_fk" FOREIGN KEY ("vehicle") REFERENCES "public"."vehicles"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "checks" ADD CONSTRAINT "checks_inventoryitem_inventoryitems_id_fk" FOREIGN KEY ("inventoryitem") REFERENCES "public"."inventoryitems"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "checks" ADD CONSTRAINT "checks_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "checks" ADD CONSTRAINT "checks_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "contacts" ADD CONSTRAINT "contacts_customer_customers_id_fk" FOREIGN KEY ("customer") REFERENCES "public"."customers"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "contacts" ADD CONSTRAINT "contacts_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "contracts" ADD CONSTRAINT "contracts_customer_customers_id_fk" FOREIGN KEY ("customer") REFERENCES "public"."customers"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "contracts" ADD CONSTRAINT "contracts_contact_contacts_id_fk" FOREIGN KEY ("contact") REFERENCES "public"."contacts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "contracts" ADD CONSTRAINT "contracts_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "costcentres" ADD CONSTRAINT "costcentres_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "costcentres" ADD CONSTRAINT "costcentres_vehicle_vehicles_id_fk" FOREIGN KEY ("vehicle") REFERENCES "public"."vehicles"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "costcentres" ADD CONSTRAINT "costcentres_project_projects_id_fk" FOREIGN KEY ("project") REFERENCES "public"."projects"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "costcentres" ADD CONSTRAINT "costcentres_inventoryitem_inventoryitems_id_fk" FOREIGN KEY ("inventoryitem") REFERENCES "public"."inventoryitems"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "costcentres" ADD CONSTRAINT "costcentres_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "createddocuments" ADD CONSTRAINT "createddocuments_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "createddocuments" ADD CONSTRAINT "createddocuments_customer_customers_id_fk" FOREIGN KEY ("customer") REFERENCES "public"."customers"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "createddocuments" ADD CONSTRAINT "createddocuments_contact_contacts_id_fk" FOREIGN KEY ("contact") REFERENCES "public"."contacts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "createddocuments" ADD CONSTRAINT "createddocuments_project_projects_id_fk" FOREIGN KEY ("project") REFERENCES "public"."projects"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "createddocuments" ADD CONSTRAINT "createddocuments_createdBy_auth_users_id_fk" FOREIGN KEY ("createdBy") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "createddocuments" ADD CONSTRAINT "createddocuments_linkedDocument_createddocuments_id_fk" FOREIGN KEY ("linkedDocument") REFERENCES "public"."createddocuments"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "createddocuments" ADD CONSTRAINT "createddocuments_letterhead_letterheads_id_fk" FOREIGN KEY ("letterhead") REFERENCES "public"."letterheads"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "createddocuments" ADD CONSTRAINT "createddocuments_plant_plants_id_fk" FOREIGN KEY ("plant") REFERENCES "public"."plants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "createddocuments" ADD CONSTRAINT "createddocuments_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "createddocuments" ADD CONSTRAINT "createddocuments_created_by_auth_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "createddocuments" ADD CONSTRAINT "createddocuments_contract_contracts_id_fk" FOREIGN KEY ("contract") REFERENCES "public"."contracts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "createdletters" ADD CONSTRAINT "createdletters_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "createdletters" ADD CONSTRAINT "createdletters_customer_customers_id_fk" FOREIGN KEY ("customer") REFERENCES "public"."customers"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "createdletters" ADD CONSTRAINT "createdletters_vendor_vendors_id_fk" FOREIGN KEY ("vendor") REFERENCES "public"."vendors"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "createdletters" ADD CONSTRAINT "createdletters_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "customers" ADD CONSTRAINT "customers_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "devices" ADD CONSTRAINT "devices_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "documentboxes" ADD CONSTRAINT "documentboxes_space_spaces_id_fk" FOREIGN KEY ("space") REFERENCES "public"."spaces"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "documentboxes" ADD CONSTRAINT "documentboxes_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "documentboxes" ADD CONSTRAINT "documentboxes_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "events" ADD CONSTRAINT "events_customer_customers_id_fk" FOREIGN KEY ("customer") REFERENCES "public"."customers"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "events" ADD CONSTRAINT "events_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "files" ADD CONSTRAINT "files_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "files" ADD CONSTRAINT "files_project_projects_id_fk" FOREIGN KEY ("project") REFERENCES "public"."projects"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "files" ADD CONSTRAINT "files_customer_customers_id_fk" FOREIGN KEY ("customer") REFERENCES "public"."customers"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "files" ADD CONSTRAINT "files_contract_contracts_id_fk" FOREIGN KEY ("contract") REFERENCES "public"."contracts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "files" ADD CONSTRAINT "files_vendor_vendors_id_fk" FOREIGN KEY ("vendor") REFERENCES "public"."vendors"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "files" ADD CONSTRAINT "files_incominginvoice_incominginvoices_id_fk" FOREIGN KEY ("incominginvoice") REFERENCES "public"."incominginvoices"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "files" ADD CONSTRAINT "files_plant_plants_id_fk" FOREIGN KEY ("plant") REFERENCES "public"."plants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "files" ADD CONSTRAINT "files_createddocument_createddocuments_id_fk" FOREIGN KEY ("createddocument") REFERENCES "public"."createddocuments"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "files" ADD CONSTRAINT "files_vehicle_vehicles_id_fk" FOREIGN KEY ("vehicle") REFERENCES "public"."vehicles"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "files" ADD CONSTRAINT "files_product_products_id_fk" FOREIGN KEY ("product") REFERENCES "public"."products"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "files" ADD CONSTRAINT "files_check_checks_id_fk" FOREIGN KEY ("check") REFERENCES "public"."checks"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "files" ADD CONSTRAINT "files_inventoryitem_inventoryitems_id_fk" FOREIGN KEY ("inventoryitem") REFERENCES "public"."inventoryitems"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "files" ADD CONSTRAINT "files_folder_folders_id_fk" FOREIGN KEY ("folder") REFERENCES "public"."folders"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "files" ADD CONSTRAINT "files_space_spaces_id_fk" FOREIGN KEY ("space") REFERENCES "public"."spaces"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "files" ADD CONSTRAINT "files_type_filetags_id_fk" FOREIGN KEY ("type") REFERENCES "public"."filetags"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "files" ADD CONSTRAINT "files_documentbox_documentboxes_id_fk" FOREIGN KEY ("documentbox") REFERENCES "public"."documentboxes"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "files" ADD CONSTRAINT "files_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "files" ADD CONSTRAINT "files_created_by_auth_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "files" ADD CONSTRAINT "files_auth_profile_auth_profiles_id_fk" FOREIGN KEY ("auth_profile") REFERENCES "public"."auth_profiles"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "filetags" ADD CONSTRAINT "filetags_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "folders" ADD CONSTRAINT "folders_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "folders" ADD CONSTRAINT "folders_parent_folders_id_fk" FOREIGN KEY ("parent") REFERENCES "public"."folders"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "folders" ADD CONSTRAINT "folders_standardFiletype_filetags_id_fk" FOREIGN KEY ("standardFiletype") REFERENCES "public"."filetags"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "folders" ADD CONSTRAINT "folders_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "exports" ADD CONSTRAINT "exports_tenant_id_tenants_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "globalmessagesseen" ADD CONSTRAINT "globalmessagesseen_message_globalmessages_id_fk" FOREIGN KEY ("message") REFERENCES "public"."globalmessages"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "helpdesk_channel_instances" ADD CONSTRAINT "helpdesk_channel_instances_tenant_id_tenants_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "public"."tenants"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "helpdesk_channel_instances" ADD CONSTRAINT "helpdesk_channel_instances_type_id_helpdesk_channel_types_id_fk" FOREIGN KEY ("type_id") REFERENCES "public"."helpdesk_channel_types"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "helpdesk_channel_instances" ADD CONSTRAINT "helpdesk_channel_instances_created_by_auth_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "helpdesk_contacts" ADD CONSTRAINT "helpdesk_contacts_tenant_id_tenants_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "public"."tenants"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "helpdesk_contacts" ADD CONSTRAINT "helpdesk_contacts_customer_id_customers_id_fk" FOREIGN KEY ("customer_id") REFERENCES "public"."customers"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "helpdesk_contacts" ADD CONSTRAINT "helpdesk_contacts_source_channel_id_helpdesk_channel_instances_id_fk" FOREIGN KEY ("source_channel_id") REFERENCES "public"."helpdesk_channel_instances"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "helpdesk_contacts" ADD CONSTRAINT "helpdesk_contacts_contact_id_contacts_id_fk" FOREIGN KEY ("contact_id") REFERENCES "public"."contacts"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "helpdesk_conversation_participants" ADD CONSTRAINT "helpdesk_conversation_participants_conversation_id_helpdesk_conversations_id_fk" FOREIGN KEY ("conversation_id") REFERENCES "public"."helpdesk_conversations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "helpdesk_conversation_participants" ADD CONSTRAINT "helpdesk_conversation_participants_user_id_auth_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."auth_users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "helpdesk_conversations" ADD CONSTRAINT "helpdesk_conversations_tenant_id_tenants_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "public"."tenants"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "helpdesk_conversations" ADD CONSTRAINT "helpdesk_conversations_channel_instance_id_helpdesk_channel_instances_id_fk" FOREIGN KEY ("channel_instance_id") REFERENCES "public"."helpdesk_channel_instances"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "helpdesk_conversations" ADD CONSTRAINT "helpdesk_conversations_contact_id_helpdesk_contacts_id_fk" FOREIGN KEY ("contact_id") REFERENCES "public"."helpdesk_contacts"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "helpdesk_conversations" ADD CONSTRAINT "helpdesk_conversations_assignee_user_id_auth_users_id_fk" FOREIGN KEY ("assignee_user_id") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "helpdesk_conversations" ADD CONSTRAINT "helpdesk_conversations_customer_id_customers_id_fk" FOREIGN KEY ("customer_id") REFERENCES "public"."customers"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "helpdesk_conversations" ADD CONSTRAINT "helpdesk_conversations_contact_person_id_contacts_id_fk" FOREIGN KEY ("contact_person_id") REFERENCES "public"."contacts"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "helpdesk_messages" ADD CONSTRAINT "helpdesk_messages_tenant_id_tenants_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "public"."tenants"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "helpdesk_messages" ADD CONSTRAINT "helpdesk_messages_conversation_id_helpdesk_conversations_id_fk" FOREIGN KEY ("conversation_id") REFERENCES "public"."helpdesk_conversations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "helpdesk_messages" ADD CONSTRAINT "helpdesk_messages_author_user_id_auth_users_id_fk" FOREIGN KEY ("author_user_id") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "helpdesk_messages" ADD CONSTRAINT "helpdesk_messages_contact_id_helpdesk_contacts_id_fk" FOREIGN KEY ("contact_id") REFERENCES "public"."helpdesk_contacts"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "helpdesk_routing_rules" ADD CONSTRAINT "helpdesk_routing_rules_tenant_id_tenants_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "public"."tenants"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "helpdesk_routing_rules" ADD CONSTRAINT "helpdesk_routing_rules_created_by_auth_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "historyitems" ADD CONSTRAINT "historyitems_customer_customers_id_fk" FOREIGN KEY ("customer") REFERENCES "public"."customers"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "historyitems" ADD CONSTRAINT "historyitems_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "historyitems" ADD CONSTRAINT "historyitems_vendor_vendors_id_fk" FOREIGN KEY ("vendor") REFERENCES "public"."vendors"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "historyitems" ADD CONSTRAINT "historyitems_project_projects_id_fk" FOREIGN KEY ("project") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "historyitems" ADD CONSTRAINT "historyitems_plant_plants_id_fk" FOREIGN KEY ("plant") REFERENCES "public"."plants"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "historyitems" ADD CONSTRAINT "historyitems_incomingInvoice_incominginvoices_id_fk" FOREIGN KEY ("incomingInvoice") REFERENCES "public"."incominginvoices"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "historyitems" ADD CONSTRAINT "historyitems_contact_contacts_id_fk" FOREIGN KEY ("contact") REFERENCES "public"."contacts"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "historyitems" ADD CONSTRAINT "historyitems_inventoryitem_inventoryitems_id_fk" FOREIGN KEY ("inventoryitem") REFERENCES "public"."inventoryitems"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "historyitems" ADD CONSTRAINT "historyitems_product_products_id_fk" FOREIGN KEY ("product") REFERENCES "public"."products"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "historyitems" ADD CONSTRAINT "historyitems_event_events_id_fk" FOREIGN KEY ("event") REFERENCES "public"."events"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "historyitems" ADD CONSTRAINT "historyitems_task_tasks_id_fk" FOREIGN KEY ("task") REFERENCES "public"."tasks"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "historyitems" ADD CONSTRAINT "historyitems_vehicle_vehicles_id_fk" FOREIGN KEY ("vehicle") REFERENCES "public"."vehicles"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "historyitems" ADD CONSTRAINT "historyitems_bankstatement_bankstatements_id_fk" FOREIGN KEY ("bankstatement") REFERENCES "public"."bankstatements"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "historyitems" ADD CONSTRAINT "historyitems_space_spaces_id_fk" FOREIGN KEY ("space") REFERENCES "public"."spaces"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "historyitems" ADD CONSTRAINT "historyitems_projecttype_projecttypes_id_fk" FOREIGN KEY ("projecttype") REFERENCES "public"."projecttypes"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "historyitems" ADD CONSTRAINT "historyitems_check_checks_id_fk" FOREIGN KEY ("check") REFERENCES "public"."checks"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "historyitems" ADD CONSTRAINT "historyitems_service_services_id_fk" FOREIGN KEY ("service") REFERENCES "public"."services"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "historyitems" ADD CONSTRAINT "historyitems_createddocument_createddocuments_id_fk" FOREIGN KEY ("createddocument") REFERENCES "public"."createddocuments"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "historyitems" ADD CONSTRAINT "historyitems_file_files_id_fk" FOREIGN KEY ("file") REFERENCES "public"."files"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "historyitems" ADD CONSTRAINT "historyitems_inventoryitemgroup_inventoryitemgroups_id_fk" FOREIGN KEY ("inventoryitemgroup") REFERENCES "public"."inventoryitemgroups"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "historyitems" ADD CONSTRAINT "historyitems_costcentre_costcentres_id_fk" FOREIGN KEY ("costcentre") REFERENCES "public"."costcentres"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "historyitems" ADD CONSTRAINT "historyitems_ownaccount_ownaccounts_id_fk" FOREIGN KEY ("ownaccount") REFERENCES "public"."ownaccounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "historyitems" ADD CONSTRAINT "historyitems_documentbox_documentboxes_id_fk" FOREIGN KEY ("documentbox") REFERENCES "public"."documentboxes"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "historyitems" ADD CONSTRAINT "historyitems_hourrate_hourrates_id_fk" FOREIGN KEY ("hourrate") REFERENCES "public"."hourrates"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "historyitems" ADD CONSTRAINT "historyitems_created_by_auth_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hourrates" ADD CONSTRAINT "hourrates_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hourrates" ADD CONSTRAINT "hourrates_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "incominginvoices" ADD CONSTRAINT "incominginvoices_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "incominginvoices" ADD CONSTRAINT "incominginvoices_vendor_vendors_id_fk" FOREIGN KEY ("vendor") REFERENCES "public"."vendors"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "incominginvoices" ADD CONSTRAINT "incominginvoices_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "inventoryitemgroups" ADD CONSTRAINT "inventoryitemgroups_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "inventoryitemgroups" ADD CONSTRAINT "inventoryitemgroups_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "inventoryitems" ADD CONSTRAINT "inventoryitems_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "inventoryitems" ADD CONSTRAINT "inventoryitems_currentSpace_spaces_id_fk" FOREIGN KEY ("currentSpace") REFERENCES "public"."spaces"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "inventoryitems" ADD CONSTRAINT "inventoryitems_vendor_vendors_id_fk" FOREIGN KEY ("vendor") REFERENCES "public"."vendors"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "inventoryitems" ADD CONSTRAINT "inventoryitems_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "letterheads" ADD CONSTRAINT "letterheads_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "letterheads" ADD CONSTRAINT "letterheads_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "movements" ADD CONSTRAINT "movements_productId_products_id_fk" FOREIGN KEY ("productId") REFERENCES "public"."products"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "movements" ADD CONSTRAINT "movements_spaceId_spaces_id_fk" FOREIGN KEY ("spaceId") REFERENCES "public"."spaces"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "movements" ADD CONSTRAINT "movements_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "movements" ADD CONSTRAINT "movements_projectId_projects_id_fk" FOREIGN KEY ("projectId") REFERENCES "public"."projects"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "movements" ADD CONSTRAINT "movements_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "notifications_items" ADD CONSTRAINT "notifications_items_tenant_id_tenants_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "public"."tenants"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint +ALTER TABLE "notifications_items" ADD CONSTRAINT "notifications_items_user_id_auth_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."auth_users"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint +ALTER TABLE "notifications_items" ADD CONSTRAINT "notifications_items_event_type_notifications_event_types_event_key_fk" FOREIGN KEY ("event_type") REFERENCES "public"."notifications_event_types"("event_key") ON DELETE restrict ON UPDATE cascade;--> statement-breakpoint +ALTER TABLE "notifications_preferences" ADD CONSTRAINT "notifications_preferences_tenant_id_tenants_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "public"."tenants"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint +ALTER TABLE "notifications_preferences" ADD CONSTRAINT "notifications_preferences_user_id_auth_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."auth_users"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint +ALTER TABLE "notifications_preferences" ADD CONSTRAINT "notifications_preferences_event_type_notifications_event_types_event_key_fk" FOREIGN KEY ("event_type") REFERENCES "public"."notifications_event_types"("event_key") ON DELETE restrict ON UPDATE cascade;--> statement-breakpoint +ALTER TABLE "notifications_preferences_defaults" ADD CONSTRAINT "notifications_preferences_defaults_tenant_id_tenants_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "public"."tenants"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint +ALTER TABLE "notifications_preferences_defaults" ADD CONSTRAINT "notifications_preferences_defaults_event_key_notifications_event_types_event_key_fk" FOREIGN KEY ("event_key") REFERENCES "public"."notifications_event_types"("event_key") ON DELETE restrict ON UPDATE cascade;--> statement-breakpoint +ALTER TABLE "ownaccounts" ADD CONSTRAINT "ownaccounts_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "ownaccounts" ADD CONSTRAINT "ownaccounts_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "plants" ADD CONSTRAINT "plants_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "plants" ADD CONSTRAINT "plants_customer_customers_id_fk" FOREIGN KEY ("customer") REFERENCES "public"."customers"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "plants" ADD CONSTRAINT "plants_contract_contracts_id_fk" FOREIGN KEY ("contract") REFERENCES "public"."contracts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "plants" ADD CONSTRAINT "plants_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "productcategories" ADD CONSTRAINT "productcategories_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "productcategories" ADD CONSTRAINT "productcategories_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "products" ADD CONSTRAINT "products_unit_units_id_fk" FOREIGN KEY ("unit") REFERENCES "public"."units"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "products" ADD CONSTRAINT "products_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "products" ADD CONSTRAINT "products_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "projects" ADD CONSTRAINT "projects_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "projects" ADD CONSTRAINT "projects_customer_customers_id_fk" FOREIGN KEY ("customer") REFERENCES "public"."customers"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "projects" ADD CONSTRAINT "projects_contract_contracts_id_fk" FOREIGN KEY ("contract") REFERENCES "public"."contracts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "projects" ADD CONSTRAINT "projects_projecttype_projecttypes_id_fk" FOREIGN KEY ("projecttype") REFERENCES "public"."projecttypes"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "projects" ADD CONSTRAINT "projects_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "projecttypes" ADD CONSTRAINT "projecttypes_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "projecttypes" ADD CONSTRAINT "projecttypes_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "servicecategories" ADD CONSTRAINT "servicecategories_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "servicecategories" ADD CONSTRAINT "servicecategories_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "services" ADD CONSTRAINT "services_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "services" ADD CONSTRAINT "services_unit_units_id_fk" FOREIGN KEY ("unit") REFERENCES "public"."units"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "services" ADD CONSTRAINT "services_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "spaces" ADD CONSTRAINT "spaces_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "spaces" ADD CONSTRAINT "spaces_parentSpace_spaces_id_fk" FOREIGN KEY ("parentSpace") REFERENCES "public"."spaces"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "spaces" ADD CONSTRAINT "spaces_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "staff_time_entries" ADD CONSTRAINT "staff_time_entries_tenant_id_tenants_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "staff_time_entries" ADD CONSTRAINT "staff_time_entries_user_id_auth_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."auth_users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "staff_time_entries" ADD CONSTRAINT "staff_time_entries_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "staff_time_entries" ADD CONSTRAINT "staff_time_entries_approved_by_auth_users_id_fk" FOREIGN KEY ("approved_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "staff_time_entry_connects" ADD CONSTRAINT "staff_time_entry_connects_time_entry_id_staff_time_entries_id_fk" FOREIGN KEY ("time_entry_id") REFERENCES "public"."staff_time_entries"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "staff_zeitstromtimestamps" ADD CONSTRAINT "staff_zeitstromtimestamps_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "staff_zeitstromtimestamps" ADD CONSTRAINT "staff_zeitstromtimestamps_profile_auth_profiles_id_fk" FOREIGN KEY ("profile") REFERENCES "public"."auth_profiles"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "staff_zeitstromtimestamps" ADD CONSTRAINT "staff_zeitstromtimestamps_staff_time_entry_staff_time_entries_id_fk" FOREIGN KEY ("staff_time_entry") REFERENCES "public"."staff_time_entries"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "statementallocations" ADD CONSTRAINT "statementallocations_bs_id_bankstatements_id_fk" FOREIGN KEY ("bs_id") REFERENCES "public"."bankstatements"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "statementallocations" ADD CONSTRAINT "statementallocations_cd_id_createddocuments_id_fk" FOREIGN KEY ("cd_id") REFERENCES "public"."createddocuments"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "statementallocations" ADD CONSTRAINT "statementallocations_ii_id_incominginvoices_id_fk" FOREIGN KEY ("ii_id") REFERENCES "public"."incominginvoices"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "statementallocations" ADD CONSTRAINT "statementallocations_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "statementallocations" ADD CONSTRAINT "statementallocations_account_accounts_id_fk" FOREIGN KEY ("account") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "statementallocations" ADD CONSTRAINT "statementallocations_ownaccount_ownaccounts_id_fk" FOREIGN KEY ("ownaccount") REFERENCES "public"."ownaccounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "statementallocations" ADD CONSTRAINT "statementallocations_customer_customers_id_fk" FOREIGN KEY ("customer") REFERENCES "public"."customers"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "statementallocations" ADD CONSTRAINT "statementallocations_vendor_vendors_id_fk" FOREIGN KEY ("vendor") REFERENCES "public"."vendors"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "statementallocations" ADD CONSTRAINT "statementallocations_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "tasks" ADD CONSTRAINT "tasks_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "tasks" ADD CONSTRAINT "tasks_user_id_auth_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "tasks" ADD CONSTRAINT "tasks_customer_customers_id_fk" FOREIGN KEY ("customer") REFERENCES "public"."customers"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "tasks" ADD CONSTRAINT "tasks_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "taxtypes" ADD CONSTRAINT "taxtypes_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "tenants" ADD CONSTRAINT "tenants_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "texttemplates" ADD CONSTRAINT "texttemplates_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "texttemplates" ADD CONSTRAINT "texttemplates_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "user_credentials" ADD CONSTRAINT "user_credentials_user_id_auth_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "user_credentials" ADD CONSTRAINT "user_credentials_tenant_id_tenants_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "vehicles" ADD CONSTRAINT "vehicles_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "vehicles" ADD CONSTRAINT "vehicles_driver_auth_users_id_fk" FOREIGN KEY ("driver") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "vehicles" ADD CONSTRAINT "vehicles_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "vendors" ADD CONSTRAINT "vendors_tenant_tenants_id_fk" FOREIGN KEY ("tenant") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "vendors" ADD CONSTRAINT "vendors_updated_by_auth_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +CREATE UNIQUE INDEX "notifications_preferences_tenant_id_user_id_event_type_chan_key" ON "notifications_preferences" USING btree ("tenant_id","user_id","event_type","channel");--> statement-breakpoint +CREATE UNIQUE INDEX "notifications_preferences_defau_tenant_id_event_key_channel_key" ON "notifications_preferences_defaults" USING btree ("tenant_id","event_key","channel"); \ No newline at end of file diff --git a/db/migrations/0001_medical_big_bertha.sql b/db/migrations/0001_medical_big_bertha.sql new file mode 100644 index 0000000..5ff60a1 --- /dev/null +++ b/db/migrations/0001_medical_big_bertha.sql @@ -0,0 +1,32 @@ +CREATE TABLE "time_events" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "tenant_id" bigint NOT NULL, + "user_id" uuid NOT NULL, + "actor_type" text NOT NULL, + "actor_user_id" uuid, + "event_time" timestamp with time zone NOT NULL, + "event_type" text NOT NULL, + "source" text NOT NULL, + "invalidates_event_id" uuid, + "metadata" jsonb, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "time_events_actor_user_check" CHECK ( + (actor_type = 'system' AND actor_user_id IS NULL) + OR + (actor_type = 'user' AND actor_user_id IS NOT NULL) + ) +); +--> statement-breakpoint +ALTER TABLE "bankstatements" DROP CONSTRAINT "bankstatements_incomingInvoice_incominginvoices_id_fk"; +--> statement-breakpoint +ALTER TABLE "bankstatements" DROP CONSTRAINT "bankstatements_createdDocument_createddocuments_id_fk"; +--> statement-breakpoint +ALTER TABLE "time_events" ADD CONSTRAINT "time_events_tenant_id_tenants_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "time_events" ADD CONSTRAINT "time_events_user_id_auth_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "time_events" ADD CONSTRAINT "time_events_actor_user_id_auth_users_id_fk" FOREIGN KEY ("actor_user_id") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "time_events" ADD CONSTRAINT "time_events_invalidates_event_id_time_events_id_fk" FOREIGN KEY ("invalidates_event_id") REFERENCES "public"."time_events"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +CREATE INDEX "idx_time_events_tenant_user_time" ON "time_events" USING btree ("tenant_id","user_id","event_time");--> statement-breakpoint +CREATE INDEX "idx_time_events_created_at" ON "time_events" USING btree ("created_at");--> statement-breakpoint +CREATE INDEX "idx_time_events_invalidates" ON "time_events" USING btree ("invalidates_event_id");--> statement-breakpoint +ALTER TABLE "bankstatements" DROP COLUMN "incomingInvoice";--> statement-breakpoint +ALTER TABLE "bankstatements" DROP COLUMN "createdDocument"; \ No newline at end of file diff --git a/db/migrations/0002_silent_christian_walker.sql b/db/migrations/0002_silent_christian_walker.sql new file mode 100644 index 0000000..bd4a372 --- /dev/null +++ b/db/migrations/0002_silent_christian_walker.sql @@ -0,0 +1,13 @@ +ALTER TABLE "time_events" RENAME TO "staff_time_events";--> statement-breakpoint +ALTER TABLE "staff_time_events" DROP CONSTRAINT "time_events_tenant_id_tenants_id_fk"; +--> statement-breakpoint +ALTER TABLE "staff_time_events" DROP CONSTRAINT "time_events_user_id_auth_users_id_fk"; +--> statement-breakpoint +ALTER TABLE "staff_time_events" DROP CONSTRAINT "time_events_actor_user_id_auth_users_id_fk"; +--> statement-breakpoint +ALTER TABLE "staff_time_events" DROP CONSTRAINT "time_events_invalidates_event_id_time_events_id_fk"; +--> statement-breakpoint +ALTER TABLE "staff_time_events" ADD CONSTRAINT "staff_time_events_tenant_id_tenants_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "staff_time_events" ADD CONSTRAINT "staff_time_events_user_id_auth_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "staff_time_events" ADD CONSTRAINT "staff_time_events_actor_user_id_auth_users_id_fk" FOREIGN KEY ("actor_user_id") REFERENCES "public"."auth_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "staff_time_events" ADD CONSTRAINT "staff_time_events_invalidates_event_id_staff_time_events_id_fk" FOREIGN KEY ("invalidates_event_id") REFERENCES "public"."staff_time_events"("id") ON DELETE no action ON UPDATE no action; \ No newline at end of file diff --git a/db/migrations/meta/0000_snapshot.json b/db/migrations/meta/0000_snapshot.json new file mode 100644 index 0000000..3fff43c --- /dev/null +++ b/db/migrations/meta/0000_snapshot.json @@ -0,0 +1,9788 @@ +{ + "id": "c74cefc4-5ae7-408c-b7f3-09093efb52b5", + "prevId": "00000000-0000-0000-0000-000000000000", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.accounts": { + "name": "accounts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "accounts_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_profiles": { + "name": "auth_profiles", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "generated": { + "as": "((first_name || ' ') || last_name)", + "type": "stored" + } + }, + "mobile_tel": { + "name": "mobile_tel", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "fixed_tel": { + "name": "fixed_tel", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "salutation": { + "name": "salutation", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "employee_number": { + "name": "employee_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "weekly_working_hours": { + "name": "weekly_working_hours", + "type": "double precision", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "annual_paid_leave_days": { + "name": "annual_paid_leave_days", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "weekly_regular_working_hours": { + "name": "weekly_regular_working_hours", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'" + }, + "clothing_size_top": { + "name": "clothing_size_top", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "clothing_size_bottom": { + "name": "clothing_size_bottom", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "clothing_size_shoe": { + "name": "clothing_size_shoe", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email_signature": { + "name": "email_signature", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'Mit freundlichen Grüßen
'" + }, + "birthday": { + "name": "birthday", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "entry_date": { + "name": "entry_date", + "type": "date", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "automatic_hour_corrections": { + "name": "automatic_hour_corrections", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'" + }, + "recreation_days_compensation": { + "name": "recreation_days_compensation", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "customer_for_portal": { + "name": "customer_for_portal", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "pinned_on_navigation": { + "name": "pinned_on_navigation", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'" + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "token_id": { + "name": "token_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "weekly_working_days": { + "name": "weekly_working_days", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "old_profile_id": { + "name": "old_profile_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "temp_config": { + "name": "temp_config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "state_code": { + "name": "state_code", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'DE-NI'" + }, + "contract_type": { + "name": "contract_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "qualification": { + "name": "qualification", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "address_street": { + "name": "address_street", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "address_zip": { + "name": "address_zip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "address_city": { + "name": "address_city", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + } + }, + "indexes": {}, + "foreignKeys": { + "auth_profiles_user_id_auth_users_id_fk": { + "name": "auth_profiles_user_id_auth_users_id_fk", + "tableFrom": "auth_profiles", + "tableTo": "auth_users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_role_permissions": { + "name": "auth_role_permissions", + "schema": "", + "columns": { + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "role_id": { + "name": "role_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "permission": { + "name": "permission", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "auth_role_permissions_role_id_auth_roles_id_fk": { + "name": "auth_role_permissions_role_id_auth_roles_id_fk", + "tableFrom": "auth_role_permissions", + "tableTo": "auth_roles", + "columnsFrom": [ + "role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_roles": { + "name": "auth_roles", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "auth_roles_created_by_auth_users_id_fk": { + "name": "auth_roles_created_by_auth_users_id_fk", + "tableFrom": "auth_roles", + "tableTo": "auth_users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_tenant_users": { + "name": "auth_tenant_users", + "schema": "", + "columns": { + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "auth_tenant_users_created_by_auth_users_id_fk": { + "name": "auth_tenant_users_created_by_auth_users_id_fk", + "tableFrom": "auth_tenant_users", + "tableTo": "auth_users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_user_roles": { + "name": "auth_user_roles", + "schema": "", + "columns": { + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role_id": { + "name": "role_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "auth_user_roles_user_id_auth_users_id_fk": { + "name": "auth_user_roles_user_id_auth_users_id_fk", + "tableFrom": "auth_user_roles", + "tableTo": "auth_users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "auth_user_roles_role_id_auth_roles_id_fk": { + "name": "auth_user_roles_role_id_auth_roles_id_fk", + "tableFrom": "auth_user_roles", + "tableTo": "auth_roles", + "columnsFrom": [ + "role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "auth_user_roles_created_by_auth_users_id_fk": { + "name": "auth_user_roles_created_by_auth_users_id_fk", + "tableFrom": "auth_user_roles", + "tableTo": "auth_users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_users": { + "name": "auth_users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "password_hash": { + "name": "password_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "multi_tenant": { + "name": "multi_tenant", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "must_change_password": { + "name": "must_change_password", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "ported": { + "name": "ported", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.bankaccounts": { + "name": "bankaccounts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "bankaccounts_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "iban": { + "name": "iban", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "bankId": { + "name": "bankId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ownerName": { + "name": "ownerName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "accountId": { + "name": "accountId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "balance": { + "name": "balance", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "expired": { + "name": "expired", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "datevNumber": { + "name": "datevNumber", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "synced_at": { + "name": "synced_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "bankaccounts_tenant_tenants_id_fk": { + "name": "bankaccounts_tenant_tenants_id_fk", + "tableFrom": "bankaccounts", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "bankaccounts_updated_by_auth_users_id_fk": { + "name": "bankaccounts_updated_by_auth_users_id_fk", + "tableFrom": "bankaccounts", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.bankrequisitions": { + "name": "bankrequisitions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "institutionId": { + "name": "institutionId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "bankrequisitions_tenant_tenants_id_fk": { + "name": "bankrequisitions_tenant_tenants_id_fk", + "tableFrom": "bankrequisitions", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "bankrequisitions_updated_by_auth_users_id_fk": { + "name": "bankrequisitions_updated_by_auth_users_id_fk", + "tableFrom": "bankrequisitions", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.bankstatements": { + "name": "bankstatements", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "bankstatements_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "account": { + "name": "account", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "credIban": { + "name": "credIban", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "credName": { + "name": "credName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "amount": { + "name": "amount", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "debIban": { + "name": "debIban", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "debName": { + "name": "debName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "gocardlessId": { + "name": "gocardlessId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "valueDate": { + "name": "valueDate", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "incomingInvoice": { + "name": "incomingInvoice", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "mandateId": { + "name": "mandateId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contract": { + "name": "contract", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "createdDocument": { + "name": "createdDocument", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "bankstatements_account_bankaccounts_id_fk": { + "name": "bankstatements_account_bankaccounts_id_fk", + "tableFrom": "bankstatements", + "tableTo": "bankaccounts", + "columnsFrom": [ + "account" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "bankstatements_tenant_tenants_id_fk": { + "name": "bankstatements_tenant_tenants_id_fk", + "tableFrom": "bankstatements", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "bankstatements_incomingInvoice_incominginvoices_id_fk": { + "name": "bankstatements_incomingInvoice_incominginvoices_id_fk", + "tableFrom": "bankstatements", + "tableTo": "incominginvoices", + "columnsFrom": [ + "incomingInvoice" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "bankstatements_contract_contracts_id_fk": { + "name": "bankstatements_contract_contracts_id_fk", + "tableFrom": "bankstatements", + "tableTo": "contracts", + "columnsFrom": [ + "contract" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "bankstatements_createdDocument_createddocuments_id_fk": { + "name": "bankstatements_createdDocument_createddocuments_id_fk", + "tableFrom": "bankstatements", + "tableTo": "createddocuments", + "columnsFrom": [ + "createdDocument" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "bankstatements_updated_by_auth_users_id_fk": { + "name": "bankstatements_updated_by_auth_users_id_fk", + "tableFrom": "bankstatements", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.checkexecutions": { + "name": "checkexecutions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "check": { + "name": "check", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "executed_at": { + "name": "executed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "checkexecutions_check_checks_id_fk": { + "name": "checkexecutions_check_checks_id_fk", + "tableFrom": "checkexecutions", + "tableTo": "checks", + "columnsFrom": [ + "check" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.checks": { + "name": "checks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "vehicle": { + "name": "vehicle", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "inventoryitem": { + "name": "inventoryitem", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "distance": { + "name": "distance", + "type": "bigint", + "primaryKey": false, + "notNull": false, + "default": 1 + }, + "distanceUnit": { + "name": "distanceUnit", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'days'" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "profiles": { + "name": "profiles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "checks_vehicle_vehicles_id_fk": { + "name": "checks_vehicle_vehicles_id_fk", + "tableFrom": "checks", + "tableTo": "vehicles", + "columnsFrom": [ + "vehicle" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "checks_inventoryitem_inventoryitems_id_fk": { + "name": "checks_inventoryitem_inventoryitems_id_fk", + "tableFrom": "checks", + "tableTo": "inventoryitems", + "columnsFrom": [ + "inventoryitem" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "checks_tenant_tenants_id_fk": { + "name": "checks_tenant_tenants_id_fk", + "tableFrom": "checks", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "checks_updated_by_auth_users_id_fk": { + "name": "checks_updated_by_auth_users_id_fk", + "tableFrom": "checks", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.citys": { + "name": "citys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "citys_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "short": { + "name": "short", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "long": { + "name": "long", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "geometry": { + "name": "geometry", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "zip": { + "name": "zip", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "districtCode": { + "name": "districtCode", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "countryName": { + "name": "countryName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "countryCode": { + "name": "countryCode", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "districtName": { + "name": "districtName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "geopoint": { + "name": "geopoint", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.contacts": { + "name": "contacts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "contacts_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "firstName": { + "name": "firstName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lastName": { + "name": "lastName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "customer": { + "name": "customer", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "phoneMobile": { + "name": "phoneMobile", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phoneHome": { + "name": "phoneHome", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "heroId": { + "name": "heroId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "fullName": { + "name": "fullName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "salutation": { + "name": "salutation", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vendor": { + "name": "vendor", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "birthday": { + "name": "birthday", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "profiles": { + "name": "profiles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "contacts_customer_customers_id_fk": { + "name": "contacts_customer_customers_id_fk", + "tableFrom": "contacts", + "tableTo": "customers", + "columnsFrom": [ + "customer" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "contacts_updated_by_auth_users_id_fk": { + "name": "contacts_updated_by_auth_users_id_fk", + "tableFrom": "contacts", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.contracts": { + "name": "contracts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "contracts_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "customer": { + "name": "customer", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "recurring": { + "name": "recurring", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "rhythm": { + "name": "rhythm", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "startDate": { + "name": "startDate", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "endDate": { + "name": "endDate", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "signDate": { + "name": "signDate", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "duration": { + "name": "duration", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contact": { + "name": "contact", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "bankingIban": { + "name": "bankingIban", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "bankingBIC": { + "name": "bankingBIC", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "bankingName": { + "name": "bankingName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "bankingOwner": { + "name": "bankingOwner", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sepaRef": { + "name": "sepaRef", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sepaDate": { + "name": "sepaDate", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "paymentType": { + "name": "paymentType", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "invoiceDispatch": { + "name": "invoiceDispatch", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ownFields": { + "name": "ownFields", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "profiles": { + "name": "profiles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "contractNumber": { + "name": "contractNumber", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "contracts_customer_customers_id_fk": { + "name": "contracts_customer_customers_id_fk", + "tableFrom": "contracts", + "tableTo": "customers", + "columnsFrom": [ + "customer" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "contracts_contact_contacts_id_fk": { + "name": "contracts_contact_contacts_id_fk", + "tableFrom": "contracts", + "tableTo": "contacts", + "columnsFrom": [ + "contact" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "contracts_updated_by_auth_users_id_fk": { + "name": "contracts_updated_by_auth_users_id_fk", + "tableFrom": "contracts", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.costcentres": { + "name": "costcentres", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "vehicle": { + "name": "vehicle", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "project": { + "name": "project", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "inventoryitem": { + "name": "inventoryitem", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "profiles": { + "name": "profiles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "costcentres_tenant_tenants_id_fk": { + "name": "costcentres_tenant_tenants_id_fk", + "tableFrom": "costcentres", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "costcentres_vehicle_vehicles_id_fk": { + "name": "costcentres_vehicle_vehicles_id_fk", + "tableFrom": "costcentres", + "tableTo": "vehicles", + "columnsFrom": [ + "vehicle" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "costcentres_project_projects_id_fk": { + "name": "costcentres_project_projects_id_fk", + "tableFrom": "costcentres", + "tableTo": "projects", + "columnsFrom": [ + "project" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "costcentres_inventoryitem_inventoryitems_id_fk": { + "name": "costcentres_inventoryitem_inventoryitems_id_fk", + "tableFrom": "costcentres", + "tableTo": "inventoryitems", + "columnsFrom": [ + "inventoryitem" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "costcentres_updated_by_auth_users_id_fk": { + "name": "costcentres_updated_by_auth_users_id_fk", + "tableFrom": "costcentres", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.countrys": { + "name": "countrys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "countrys_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.createddocuments": { + "name": "createddocuments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "createddocuments_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'INVOICE'" + }, + "customer": { + "name": "customer", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "contact": { + "name": "contact", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "address": { + "name": "address", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "project": { + "name": "project", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "documentNumber": { + "name": "documentNumber", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "documentDate": { + "name": "documentDate", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'Entwurf'" + }, + "info": { + "name": "info", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "createdBy": { + "name": "createdBy", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "startText": { + "name": "startText", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "endText": { + "name": "endText", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "rows": { + "name": "rows", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "deliveryDateType": { + "name": "deliveryDateType", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "paymentDays": { + "name": "paymentDays", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "deliveryDate": { + "name": "deliveryDate", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contactPerson": { + "name": "contactPerson", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "serialConfig": { + "name": "serialConfig", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "linkedDocument": { + "name": "linkedDocument", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "agriculture": { + "name": "agriculture", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "letterhead": { + "name": "letterhead", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "advanceInvoiceResolved": { + "name": "advanceInvoiceResolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "usedAdvanceInvoices": { + "name": "usedAdvanceInvoices", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "deliveryDateEnd": { + "name": "deliveryDateEnd", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "plant": { + "name": "plant", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "taxType": { + "name": "taxType", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "customSurchargePercentage": { + "name": "customSurchargePercentage", + "type": "smallint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "report": { + "name": "report", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "availableInPortal": { + "name": "availableInPortal", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "payment_type": { + "name": "payment_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'transfer'" + }, + "contract": { + "name": "contract", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "createddocuments_tenant_tenants_id_fk": { + "name": "createddocuments_tenant_tenants_id_fk", + "tableFrom": "createddocuments", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "createddocuments_customer_customers_id_fk": { + "name": "createddocuments_customer_customers_id_fk", + "tableFrom": "createddocuments", + "tableTo": "customers", + "columnsFrom": [ + "customer" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "createddocuments_contact_contacts_id_fk": { + "name": "createddocuments_contact_contacts_id_fk", + "tableFrom": "createddocuments", + "tableTo": "contacts", + "columnsFrom": [ + "contact" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "createddocuments_project_projects_id_fk": { + "name": "createddocuments_project_projects_id_fk", + "tableFrom": "createddocuments", + "tableTo": "projects", + "columnsFrom": [ + "project" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "createddocuments_createdBy_auth_users_id_fk": { + "name": "createddocuments_createdBy_auth_users_id_fk", + "tableFrom": "createddocuments", + "tableTo": "auth_users", + "columnsFrom": [ + "createdBy" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "createddocuments_linkedDocument_createddocuments_id_fk": { + "name": "createddocuments_linkedDocument_createddocuments_id_fk", + "tableFrom": "createddocuments", + "tableTo": "createddocuments", + "columnsFrom": [ + "linkedDocument" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "createddocuments_letterhead_letterheads_id_fk": { + "name": "createddocuments_letterhead_letterheads_id_fk", + "tableFrom": "createddocuments", + "tableTo": "letterheads", + "columnsFrom": [ + "letterhead" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "createddocuments_plant_plants_id_fk": { + "name": "createddocuments_plant_plants_id_fk", + "tableFrom": "createddocuments", + "tableTo": "plants", + "columnsFrom": [ + "plant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "createddocuments_updated_by_auth_users_id_fk": { + "name": "createddocuments_updated_by_auth_users_id_fk", + "tableFrom": "createddocuments", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "createddocuments_created_by_auth_users_id_fk": { + "name": "createddocuments_created_by_auth_users_id_fk", + "tableFrom": "createddocuments", + "tableTo": "auth_users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "createddocuments_contract_contracts_id_fk": { + "name": "createddocuments_contract_contracts_id_fk", + "tableFrom": "createddocuments", + "tableTo": "contracts", + "columnsFrom": [ + "contract" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.createdletters": { + "name": "createdletters", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "customer": { + "name": "customer", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "vendor": { + "name": "vendor", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "content_json": { + "name": "content_json", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "content_text": { + "name": "content_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "createdletters_tenant_tenants_id_fk": { + "name": "createdletters_tenant_tenants_id_fk", + "tableFrom": "createdletters", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "createdletters_customer_customers_id_fk": { + "name": "createdletters_customer_customers_id_fk", + "tableFrom": "createdletters", + "tableTo": "customers", + "columnsFrom": [ + "customer" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "createdletters_vendor_vendors_id_fk": { + "name": "createdletters_vendor_vendors_id_fk", + "tableFrom": "createdletters", + "tableTo": "vendors", + "columnsFrom": [ + "vendor" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "createdletters_updated_by_auth_users_id_fk": { + "name": "createdletters_updated_by_auth_users_id_fk", + "tableFrom": "createdletters", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.customers": { + "name": "customers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "customers_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "customerNumber": { + "name": "customerNumber", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "infoData": { + "name": "infoData", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'Privat'" + }, + "heroId": { + "name": "heroId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "isCompany": { + "name": "isCompany", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "profiles": { + "name": "profiles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "customPaymentDays": { + "name": "customPaymentDays", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "firstname": { + "name": "firstname", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lastname": { + "name": "lastname", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "customSurchargePercentage": { + "name": "customSurchargePercentage", + "type": "smallint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "salutation": { + "name": "salutation", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "nameAddition": { + "name": "nameAddition", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "availableInPortal": { + "name": "availableInPortal", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "custom_payment_type": { + "name": "custom_payment_type", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "customers_updated_by_auth_users_id_fk": { + "name": "customers_updated_by_auth_users_id_fk", + "tableFrom": "customers", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.devices": { + "name": "devices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "externalId": { + "name": "externalId", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "devices_tenant_tenants_id_fk": { + "name": "devices_tenant_tenants_id_fk", + "tableFrom": "devices", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.documentboxes": { + "name": "documentboxes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "space": { + "name": "space", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "documentboxes_space_spaces_id_fk": { + "name": "documentboxes_space_spaces_id_fk", + "tableFrom": "documentboxes", + "tableTo": "spaces", + "columnsFrom": [ + "space" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "documentboxes_tenant_tenants_id_fk": { + "name": "documentboxes_tenant_tenants_id_fk", + "tableFrom": "documentboxes", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "documentboxes_updated_by_auth_users_id_fk": { + "name": "documentboxes_updated_by_auth_users_id_fk", + "tableFrom": "documentboxes", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.events": { + "name": "events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "events_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "startDate": { + "name": "startDate", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "endDate": { + "name": "endDate", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "eventtype": { + "name": "eventtype", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'Umsetzung'" + }, + "project": { + "name": "project", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "resources": { + "name": "resources", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "link": { + "name": "link", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "profiles": { + "name": "profiles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "vehicles": { + "name": "vehicles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "inventoryitems": { + "name": "inventoryitems", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "inventoryitemgroups": { + "name": "inventoryitemgroups", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "customer": { + "name": "customer", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "vendor": { + "name": "vendor", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "events_customer_customers_id_fk": { + "name": "events_customer_customers_id_fk", + "tableFrom": "events", + "tableTo": "customers", + "columnsFrom": [ + "customer" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "events_updated_by_auth_users_id_fk": { + "name": "events_updated_by_auth_users_id_fk", + "tableFrom": "events", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.files": { + "name": "files", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "project": { + "name": "project", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "customer": { + "name": "customer", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "contract": { + "name": "contract", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "vendor": { + "name": "vendor", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "incominginvoice": { + "name": "incominginvoice", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "plant": { + "name": "plant", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "createddocument": { + "name": "createddocument", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "vehicle": { + "name": "vehicle", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "product": { + "name": "product", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "check": { + "name": "check", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "inventoryitem": { + "name": "inventoryitem", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "folder": { + "name": "folder", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "mimeType": { + "name": "mimeType", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "space": { + "name": "space", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "documentbox": { + "name": "documentbox", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "auth_profile": { + "name": "auth_profile", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "files_tenant_tenants_id_fk": { + "name": "files_tenant_tenants_id_fk", + "tableFrom": "files", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_project_projects_id_fk": { + "name": "files_project_projects_id_fk", + "tableFrom": "files", + "tableTo": "projects", + "columnsFrom": [ + "project" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_customer_customers_id_fk": { + "name": "files_customer_customers_id_fk", + "tableFrom": "files", + "tableTo": "customers", + "columnsFrom": [ + "customer" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_contract_contracts_id_fk": { + "name": "files_contract_contracts_id_fk", + "tableFrom": "files", + "tableTo": "contracts", + "columnsFrom": [ + "contract" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_vendor_vendors_id_fk": { + "name": "files_vendor_vendors_id_fk", + "tableFrom": "files", + "tableTo": "vendors", + "columnsFrom": [ + "vendor" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_incominginvoice_incominginvoices_id_fk": { + "name": "files_incominginvoice_incominginvoices_id_fk", + "tableFrom": "files", + "tableTo": "incominginvoices", + "columnsFrom": [ + "incominginvoice" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_plant_plants_id_fk": { + "name": "files_plant_plants_id_fk", + "tableFrom": "files", + "tableTo": "plants", + "columnsFrom": [ + "plant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_createddocument_createddocuments_id_fk": { + "name": "files_createddocument_createddocuments_id_fk", + "tableFrom": "files", + "tableTo": "createddocuments", + "columnsFrom": [ + "createddocument" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_vehicle_vehicles_id_fk": { + "name": "files_vehicle_vehicles_id_fk", + "tableFrom": "files", + "tableTo": "vehicles", + "columnsFrom": [ + "vehicle" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_product_products_id_fk": { + "name": "files_product_products_id_fk", + "tableFrom": "files", + "tableTo": "products", + "columnsFrom": [ + "product" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_check_checks_id_fk": { + "name": "files_check_checks_id_fk", + "tableFrom": "files", + "tableTo": "checks", + "columnsFrom": [ + "check" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_inventoryitem_inventoryitems_id_fk": { + "name": "files_inventoryitem_inventoryitems_id_fk", + "tableFrom": "files", + "tableTo": "inventoryitems", + "columnsFrom": [ + "inventoryitem" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_folder_folders_id_fk": { + "name": "files_folder_folders_id_fk", + "tableFrom": "files", + "tableTo": "folders", + "columnsFrom": [ + "folder" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_space_spaces_id_fk": { + "name": "files_space_spaces_id_fk", + "tableFrom": "files", + "tableTo": "spaces", + "columnsFrom": [ + "space" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_type_filetags_id_fk": { + "name": "files_type_filetags_id_fk", + "tableFrom": "files", + "tableTo": "filetags", + "columnsFrom": [ + "type" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_documentbox_documentboxes_id_fk": { + "name": "files_documentbox_documentboxes_id_fk", + "tableFrom": "files", + "tableTo": "documentboxes", + "columnsFrom": [ + "documentbox" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_updated_by_auth_users_id_fk": { + "name": "files_updated_by_auth_users_id_fk", + "tableFrom": "files", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_created_by_auth_users_id_fk": { + "name": "files_created_by_auth_users_id_fk", + "tableFrom": "files", + "tableTo": "auth_users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_auth_profile_auth_profiles_id_fk": { + "name": "files_auth_profile_auth_profiles_id_fk", + "tableFrom": "files", + "tableTo": "auth_profiles", + "columnsFrom": [ + "auth_profile" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.filetags": { + "name": "filetags", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "createddocumenttype": { + "name": "createddocumenttype", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "''" + }, + "incomingDocumentType": { + "name": "incomingDocumentType", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "filetags_tenant_tenants_id_fk": { + "name": "filetags_tenant_tenants_id_fk", + "tableFrom": "filetags", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.folders": { + "name": "folders", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "parent": { + "name": "parent", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "isSystemUsed": { + "name": "isSystemUsed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "function": { + "name": "function", + "type": "folderfunctions", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "year": { + "name": "year", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "standardFiletype": { + "name": "standardFiletype", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "standardFiletypeIsOptional": { + "name": "standardFiletypeIsOptional", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "folders_tenant_tenants_id_fk": { + "name": "folders_tenant_tenants_id_fk", + "tableFrom": "folders", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "folders_parent_folders_id_fk": { + "name": "folders_parent_folders_id_fk", + "tableFrom": "folders", + "tableTo": "folders", + "columnsFrom": [ + "parent" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "folders_standardFiletype_filetags_id_fk": { + "name": "folders_standardFiletype_filetags_id_fk", + "tableFrom": "folders", + "tableTo": "filetags", + "columnsFrom": [ + "standardFiletype" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "folders_updated_by_auth_users_id_fk": { + "name": "folders_updated_by_auth_users_id_fk", + "tableFrom": "folders", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.exports": { + "name": "exports", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "exports_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "start_date": { + "name": "start_date", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "end_date": { + "name": "end_date", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "valid_until": { + "name": "valid_until", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'datev'" + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_path": { + "name": "file_path", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "exports_tenant_id_tenants_id_fk": { + "name": "exports_tenant_id_tenants_id_fk", + "tableFrom": "exports", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.globalmessages": { + "name": "globalmessages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "globalmessages_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.globalmessagesseen": { + "name": "globalmessagesseen", + "schema": "", + "columns": { + "message": { + "name": "message", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "seen_at": { + "name": "seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "globalmessagesseen_message_globalmessages_id_fk": { + "name": "globalmessagesseen_message_globalmessages_id_fk", + "tableFrom": "globalmessagesseen", + "tableTo": "globalmessages", + "columnsFrom": [ + "message" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.helpdesk_channel_instances": { + "name": "helpdesk_channel_instances", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "type_id": { + "name": "type_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "config": { + "name": "config", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "public_config": { + "name": "public_config", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "public_token": { + "name": "public_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "secret_token": { + "name": "secret_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "helpdesk_channel_instances_tenant_id_tenants_id_fk": { + "name": "helpdesk_channel_instances_tenant_id_tenants_id_fk", + "tableFrom": "helpdesk_channel_instances", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "helpdesk_channel_instances_type_id_helpdesk_channel_types_id_fk": { + "name": "helpdesk_channel_instances_type_id_helpdesk_channel_types_id_fk", + "tableFrom": "helpdesk_channel_instances", + "tableTo": "helpdesk_channel_types", + "columnsFrom": [ + "type_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "helpdesk_channel_instances_created_by_auth_users_id_fk": { + "name": "helpdesk_channel_instances_created_by_auth_users_id_fk", + "tableFrom": "helpdesk_channel_instances", + "tableTo": "auth_users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "helpdesk_channel_instances_public_token_unique": { + "name": "helpdesk_channel_instances_public_token_unique", + "nullsNotDistinct": false, + "columns": [ + "public_token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.helpdesk_channel_types": { + "name": "helpdesk_channel_types", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.helpdesk_contacts": { + "name": "helpdesk_contacts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "customer_id": { + "name": "customer_id", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external_ref": { + "name": "external_ref", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "source_channel_id": { + "name": "source_channel_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "contact_id": { + "name": "contact_id", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "helpdesk_contacts_tenant_id_tenants_id_fk": { + "name": "helpdesk_contacts_tenant_id_tenants_id_fk", + "tableFrom": "helpdesk_contacts", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "helpdesk_contacts_customer_id_customers_id_fk": { + "name": "helpdesk_contacts_customer_id_customers_id_fk", + "tableFrom": "helpdesk_contacts", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "helpdesk_contacts_source_channel_id_helpdesk_channel_instances_id_fk": { + "name": "helpdesk_contacts_source_channel_id_helpdesk_channel_instances_id_fk", + "tableFrom": "helpdesk_contacts", + "tableTo": "helpdesk_channel_instances", + "columnsFrom": [ + "source_channel_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "helpdesk_contacts_contact_id_contacts_id_fk": { + "name": "helpdesk_contacts_contact_id_contacts_id_fk", + "tableFrom": "helpdesk_contacts", + "tableTo": "contacts", + "columnsFrom": [ + "contact_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.helpdesk_conversation_participants": { + "name": "helpdesk_conversation_participants", + "schema": "", + "columns": { + "conversation_id": { + "name": "conversation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "helpdesk_conversation_participants_conversation_id_helpdesk_conversations_id_fk": { + "name": "helpdesk_conversation_participants_conversation_id_helpdesk_conversations_id_fk", + "tableFrom": "helpdesk_conversation_participants", + "tableTo": "helpdesk_conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "helpdesk_conversation_participants_user_id_auth_users_id_fk": { + "name": "helpdesk_conversation_participants_user_id_auth_users_id_fk", + "tableFrom": "helpdesk_conversation_participants", + "tableTo": "auth_users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.helpdesk_conversations": { + "name": "helpdesk_conversations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "channel_instance_id": { + "name": "channel_instance_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "contact_id": { + "name": "contact_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'open'" + }, + "priority": { + "name": "priority", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'normal'" + }, + "assignee_user_id": { + "name": "assignee_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "last_message_at": { + "name": "last_message_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "customer_id": { + "name": "customer_id", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "contact_person_id": { + "name": "contact_person_id", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "ticket_number": { + "name": "ticket_number", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "helpdesk_conversations_tenant_id_tenants_id_fk": { + "name": "helpdesk_conversations_tenant_id_tenants_id_fk", + "tableFrom": "helpdesk_conversations", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "helpdesk_conversations_channel_instance_id_helpdesk_channel_instances_id_fk": { + "name": "helpdesk_conversations_channel_instance_id_helpdesk_channel_instances_id_fk", + "tableFrom": "helpdesk_conversations", + "tableTo": "helpdesk_channel_instances", + "columnsFrom": [ + "channel_instance_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "helpdesk_conversations_contact_id_helpdesk_contacts_id_fk": { + "name": "helpdesk_conversations_contact_id_helpdesk_contacts_id_fk", + "tableFrom": "helpdesk_conversations", + "tableTo": "helpdesk_contacts", + "columnsFrom": [ + "contact_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "helpdesk_conversations_assignee_user_id_auth_users_id_fk": { + "name": "helpdesk_conversations_assignee_user_id_auth_users_id_fk", + "tableFrom": "helpdesk_conversations", + "tableTo": "auth_users", + "columnsFrom": [ + "assignee_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "helpdesk_conversations_customer_id_customers_id_fk": { + "name": "helpdesk_conversations_customer_id_customers_id_fk", + "tableFrom": "helpdesk_conversations", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "helpdesk_conversations_contact_person_id_contacts_id_fk": { + "name": "helpdesk_conversations_contact_person_id_contacts_id_fk", + "tableFrom": "helpdesk_conversations", + "tableTo": "contacts", + "columnsFrom": [ + "contact_person_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.helpdesk_messages": { + "name": "helpdesk_messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "conversation_id": { + "name": "conversation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "direction": { + "name": "direction", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "author_user_id": { + "name": "author_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "raw_meta": { + "name": "raw_meta", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "contact_id": { + "name": "contact_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "external_message_id": { + "name": "external_message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "received_at": { + "name": "received_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "helpdesk_messages_tenant_id_tenants_id_fk": { + "name": "helpdesk_messages_tenant_id_tenants_id_fk", + "tableFrom": "helpdesk_messages", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "helpdesk_messages_conversation_id_helpdesk_conversations_id_fk": { + "name": "helpdesk_messages_conversation_id_helpdesk_conversations_id_fk", + "tableFrom": "helpdesk_messages", + "tableTo": "helpdesk_conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "helpdesk_messages_author_user_id_auth_users_id_fk": { + "name": "helpdesk_messages_author_user_id_auth_users_id_fk", + "tableFrom": "helpdesk_messages", + "tableTo": "auth_users", + "columnsFrom": [ + "author_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "helpdesk_messages_contact_id_helpdesk_contacts_id_fk": { + "name": "helpdesk_messages_contact_id_helpdesk_contacts_id_fk", + "tableFrom": "helpdesk_messages", + "tableTo": "helpdesk_contacts", + "columnsFrom": [ + "contact_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "helpdesk_messages_external_message_id_unique": { + "name": "helpdesk_messages_external_message_id_unique", + "nullsNotDistinct": false, + "columns": [ + "external_message_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.helpdesk_routing_rules": { + "name": "helpdesk_routing_rules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "condition": { + "name": "condition", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "action": { + "name": "action", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "helpdesk_routing_rules_tenant_id_tenants_id_fk": { + "name": "helpdesk_routing_rules_tenant_id_tenants_id_fk", + "tableFrom": "helpdesk_routing_rules", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "helpdesk_routing_rules_created_by_auth_users_id_fk": { + "name": "helpdesk_routing_rules_created_by_auth_users_id_fk", + "tableFrom": "helpdesk_routing_rules", + "tableTo": "auth_users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.historyitems": { + "name": "historyitems", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "historyitems_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "customer": { + "name": "customer", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "vendor": { + "name": "vendor", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "project": { + "name": "project", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "plant": { + "name": "plant", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "incomingInvoice": { + "name": "incomingInvoice", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "contact": { + "name": "contact", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "inventoryitem": { + "name": "inventoryitem", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "product": { + "name": "product", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "event": { + "name": "event", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "newVal": { + "name": "newVal", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "oldVal": { + "name": "oldVal", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "task": { + "name": "task", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "vehicle": { + "name": "vehicle", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "bankstatement": { + "name": "bankstatement", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "space": { + "name": "space", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "config": { + "name": "config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "projecttype": { + "name": "projecttype", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "check": { + "name": "check", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "service": { + "name": "service", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "createddocument": { + "name": "createddocument", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "file": { + "name": "file", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "inventoryitemgroup": { + "name": "inventoryitemgroup", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'Software'" + }, + "costcentre": { + "name": "costcentre", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "ownaccount": { + "name": "ownaccount", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "documentbox": { + "name": "documentbox", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "hourrate": { + "name": "hourrate", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "historyitems_customer_customers_id_fk": { + "name": "historyitems_customer_customers_id_fk", + "tableFrom": "historyitems", + "tableTo": "customers", + "columnsFrom": [ + "customer" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "historyitems_tenant_tenants_id_fk": { + "name": "historyitems_tenant_tenants_id_fk", + "tableFrom": "historyitems", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_vendor_vendors_id_fk": { + "name": "historyitems_vendor_vendors_id_fk", + "tableFrom": "historyitems", + "tableTo": "vendors", + "columnsFrom": [ + "vendor" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_project_projects_id_fk": { + "name": "historyitems_project_projects_id_fk", + "tableFrom": "historyitems", + "tableTo": "projects", + "columnsFrom": [ + "project" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "historyitems_plant_plants_id_fk": { + "name": "historyitems_plant_plants_id_fk", + "tableFrom": "historyitems", + "tableTo": "plants", + "columnsFrom": [ + "plant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "historyitems_incomingInvoice_incominginvoices_id_fk": { + "name": "historyitems_incomingInvoice_incominginvoices_id_fk", + "tableFrom": "historyitems", + "tableTo": "incominginvoices", + "columnsFrom": [ + "incomingInvoice" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "historyitems_contact_contacts_id_fk": { + "name": "historyitems_contact_contacts_id_fk", + "tableFrom": "historyitems", + "tableTo": "contacts", + "columnsFrom": [ + "contact" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "historyitems_inventoryitem_inventoryitems_id_fk": { + "name": "historyitems_inventoryitem_inventoryitems_id_fk", + "tableFrom": "historyitems", + "tableTo": "inventoryitems", + "columnsFrom": [ + "inventoryitem" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "historyitems_product_products_id_fk": { + "name": "historyitems_product_products_id_fk", + "tableFrom": "historyitems", + "tableTo": "products", + "columnsFrom": [ + "product" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "historyitems_event_events_id_fk": { + "name": "historyitems_event_events_id_fk", + "tableFrom": "historyitems", + "tableTo": "events", + "columnsFrom": [ + "event" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_task_tasks_id_fk": { + "name": "historyitems_task_tasks_id_fk", + "tableFrom": "historyitems", + "tableTo": "tasks", + "columnsFrom": [ + "task" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_vehicle_vehicles_id_fk": { + "name": "historyitems_vehicle_vehicles_id_fk", + "tableFrom": "historyitems", + "tableTo": "vehicles", + "columnsFrom": [ + "vehicle" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_bankstatement_bankstatements_id_fk": { + "name": "historyitems_bankstatement_bankstatements_id_fk", + "tableFrom": "historyitems", + "tableTo": "bankstatements", + "columnsFrom": [ + "bankstatement" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_space_spaces_id_fk": { + "name": "historyitems_space_spaces_id_fk", + "tableFrom": "historyitems", + "tableTo": "spaces", + "columnsFrom": [ + "space" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_projecttype_projecttypes_id_fk": { + "name": "historyitems_projecttype_projecttypes_id_fk", + "tableFrom": "historyitems", + "tableTo": "projecttypes", + "columnsFrom": [ + "projecttype" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_check_checks_id_fk": { + "name": "historyitems_check_checks_id_fk", + "tableFrom": "historyitems", + "tableTo": "checks", + "columnsFrom": [ + "check" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_service_services_id_fk": { + "name": "historyitems_service_services_id_fk", + "tableFrom": "historyitems", + "tableTo": "services", + "columnsFrom": [ + "service" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_createddocument_createddocuments_id_fk": { + "name": "historyitems_createddocument_createddocuments_id_fk", + "tableFrom": "historyitems", + "tableTo": "createddocuments", + "columnsFrom": [ + "createddocument" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_file_files_id_fk": { + "name": "historyitems_file_files_id_fk", + "tableFrom": "historyitems", + "tableTo": "files", + "columnsFrom": [ + "file" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_inventoryitemgroup_inventoryitemgroups_id_fk": { + "name": "historyitems_inventoryitemgroup_inventoryitemgroups_id_fk", + "tableFrom": "historyitems", + "tableTo": "inventoryitemgroups", + "columnsFrom": [ + "inventoryitemgroup" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_costcentre_costcentres_id_fk": { + "name": "historyitems_costcentre_costcentres_id_fk", + "tableFrom": "historyitems", + "tableTo": "costcentres", + "columnsFrom": [ + "costcentre" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_ownaccount_ownaccounts_id_fk": { + "name": "historyitems_ownaccount_ownaccounts_id_fk", + "tableFrom": "historyitems", + "tableTo": "ownaccounts", + "columnsFrom": [ + "ownaccount" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_documentbox_documentboxes_id_fk": { + "name": "historyitems_documentbox_documentboxes_id_fk", + "tableFrom": "historyitems", + "tableTo": "documentboxes", + "columnsFrom": [ + "documentbox" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_hourrate_hourrates_id_fk": { + "name": "historyitems_hourrate_hourrates_id_fk", + "tableFrom": "historyitems", + "tableTo": "hourrates", + "columnsFrom": [ + "hourrate" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_created_by_auth_users_id_fk": { + "name": "historyitems_created_by_auth_users_id_fk", + "tableFrom": "historyitems", + "tableTo": "auth_users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.holidays": { + "name": "holidays", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "holidays_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "state_code": { + "name": "state_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hourrates": { + "name": "hourrates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "purchasePrice": { + "name": "purchasePrice", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "sellingPrice": { + "name": "sellingPrice", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "hourrates_tenant_tenants_id_fk": { + "name": "hourrates_tenant_tenants_id_fk", + "tableFrom": "hourrates", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "hourrates_updated_by_auth_users_id_fk": { + "name": "hourrates_updated_by_auth_users_id_fk", + "tableFrom": "hourrates", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.incominginvoices": { + "name": "incominginvoices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "incominginvoices_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'Entwurf'" + }, + "vendor": { + "name": "vendor", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "reference": { + "name": "reference", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "date": { + "name": "date", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "document": { + "name": "document", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "dueDate": { + "name": "dueDate", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "paymentType": { + "name": "paymentType", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "accounts": { + "name": "accounts", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[{\"account\":null,\"taxType\":null,\"amountNet\":null,\"amountTax\":19,\"costCentre\":null}]'::jsonb" + }, + "paid": { + "name": "paid", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "expense": { + "name": "expense", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "incominginvoices_tenant_tenants_id_fk": { + "name": "incominginvoices_tenant_tenants_id_fk", + "tableFrom": "incominginvoices", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "incominginvoices_vendor_vendors_id_fk": { + "name": "incominginvoices_vendor_vendors_id_fk", + "tableFrom": "incominginvoices", + "tableTo": "vendors", + "columnsFrom": [ + "vendor" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "incominginvoices_updated_by_auth_users_id_fk": { + "name": "incominginvoices_updated_by_auth_users_id_fk", + "tableFrom": "incominginvoices", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.inventoryitemgroups": { + "name": "inventoryitemgroups", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "inventoryitems": { + "name": "inventoryitems", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "profiles": { + "name": "profiles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "usePlanning": { + "name": "usePlanning", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "inventoryitemgroups_tenant_tenants_id_fk": { + "name": "inventoryitemgroups_tenant_tenants_id_fk", + "tableFrom": "inventoryitemgroups", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "inventoryitemgroups_updated_by_auth_users_id_fk": { + "name": "inventoryitemgroups_updated_by_auth_users_id_fk", + "tableFrom": "inventoryitemgroups", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.inventoryitems": { + "name": "inventoryitems", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "inventoryitems_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "usePlanning": { + "name": "usePlanning", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "currentSpace": { + "name": "currentSpace", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "articleNumber": { + "name": "articleNumber", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "serialNumber": { + "name": "serialNumber", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "purchaseDate": { + "name": "purchaseDate", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "vendor": { + "name": "vendor", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "quantity": { + "name": "quantity", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "purchasePrice": { + "name": "purchasePrice", + "type": "double precision", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "manufacturer": { + "name": "manufacturer", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "manufacturerNumber": { + "name": "manufacturerNumber", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "currentValue": { + "name": "currentValue", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "profiles": { + "name": "profiles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "inventoryitems_tenant_tenants_id_fk": { + "name": "inventoryitems_tenant_tenants_id_fk", + "tableFrom": "inventoryitems", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "inventoryitems_currentSpace_spaces_id_fk": { + "name": "inventoryitems_currentSpace_spaces_id_fk", + "tableFrom": "inventoryitems", + "tableTo": "spaces", + "columnsFrom": [ + "currentSpace" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "inventoryitems_vendor_vendors_id_fk": { + "name": "inventoryitems_vendor_vendors_id_fk", + "tableFrom": "inventoryitems", + "tableTo": "vendors", + "columnsFrom": [ + "vendor" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "inventoryitems_updated_by_auth_users_id_fk": { + "name": "inventoryitems_updated_by_auth_users_id_fk", + "tableFrom": "inventoryitems", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.letterheads": { + "name": "letterheads", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "letterheads_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'Standard'" + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "documentTypes": { + "name": "documentTypes", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "letterheads_tenant_tenants_id_fk": { + "name": "letterheads_tenant_tenants_id_fk", + "tableFrom": "letterheads", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "letterheads_updated_by_auth_users_id_fk": { + "name": "letterheads_updated_by_auth_users_id_fk", + "tableFrom": "letterheads", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.movements": { + "name": "movements", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "movements_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "quantity": { + "name": "quantity", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "productId": { + "name": "productId", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "spaceId": { + "name": "spaceId", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "projectId": { + "name": "projectId", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "serials": { + "name": "serials", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "movements_productId_products_id_fk": { + "name": "movements_productId_products_id_fk", + "tableFrom": "movements", + "tableTo": "products", + "columnsFrom": [ + "productId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "movements_spaceId_spaces_id_fk": { + "name": "movements_spaceId_spaces_id_fk", + "tableFrom": "movements", + "tableTo": "spaces", + "columnsFrom": [ + "spaceId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "movements_tenant_tenants_id_fk": { + "name": "movements_tenant_tenants_id_fk", + "tableFrom": "movements", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "movements_projectId_projects_id_fk": { + "name": "movements_projectId_projects_id_fk", + "tableFrom": "movements", + "tableTo": "projects", + "columnsFrom": [ + "projectId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "movements_updated_by_auth_users_id_fk": { + "name": "movements_updated_by_auth_users_id_fk", + "tableFrom": "movements", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notifications_event_types": { + "name": "notifications_event_types", + "schema": "", + "columns": { + "event_key": { + "name": "event_key", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "severity": { + "name": "severity", + "type": "notification_severity", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'info'" + }, + "allowed_channels": { + "name": "allowed_channels", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[\"inapp\",\"email\"]'::jsonb" + }, + "payload_schema": { + "name": "payload_schema", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notifications_items": { + "name": "notifications_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "channel": { + "name": "channel", + "type": "notification_channel", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "notification_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'queued'" + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "read_at": { + "name": "read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_items_tenant_id_tenants_id_fk": { + "name": "notifications_items_tenant_id_tenants_id_fk", + "tableFrom": "notifications_items", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "notifications_items_user_id_auth_users_id_fk": { + "name": "notifications_items_user_id_auth_users_id_fk", + "tableFrom": "notifications_items", + "tableTo": "auth_users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "notifications_items_event_type_notifications_event_types_event_key_fk": { + "name": "notifications_items_event_type_notifications_event_types_event_key_fk", + "tableFrom": "notifications_items", + "tableTo": "notifications_event_types", + "columnsFrom": [ + "event_type" + ], + "columnsTo": [ + "event_key" + ], + "onDelete": "restrict", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notifications_preferences": { + "name": "notifications_preferences", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "notification_channel", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "notifications_preferences_tenant_id_user_id_event_type_chan_key": { + "name": "notifications_preferences_tenant_id_user_id_event_type_chan_key", + "columns": [ + { + "expression": "tenant_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "event_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "channel", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notifications_preferences_tenant_id_tenants_id_fk": { + "name": "notifications_preferences_tenant_id_tenants_id_fk", + "tableFrom": "notifications_preferences", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "notifications_preferences_user_id_auth_users_id_fk": { + "name": "notifications_preferences_user_id_auth_users_id_fk", + "tableFrom": "notifications_preferences", + "tableTo": "auth_users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "notifications_preferences_event_type_notifications_event_types_event_key_fk": { + "name": "notifications_preferences_event_type_notifications_event_types_event_key_fk", + "tableFrom": "notifications_preferences", + "tableTo": "notifications_event_types", + "columnsFrom": [ + "event_type" + ], + "columnsTo": [ + "event_key" + ], + "onDelete": "restrict", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notifications_preferences_defaults": { + "name": "notifications_preferences_defaults", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "event_key": { + "name": "event_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "notification_channel", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "notifications_preferences_defau_tenant_id_event_key_channel_key": { + "name": "notifications_preferences_defau_tenant_id_event_key_channel_key", + "columns": [ + { + "expression": "tenant_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "event_key", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "channel", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notifications_preferences_defaults_tenant_id_tenants_id_fk": { + "name": "notifications_preferences_defaults_tenant_id_tenants_id_fk", + "tableFrom": "notifications_preferences_defaults", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "notifications_preferences_defaults_event_key_notifications_event_types_event_key_fk": { + "name": "notifications_preferences_defaults_event_key_notifications_event_types_event_key_fk", + "tableFrom": "notifications_preferences_defaults", + "tableTo": "notifications_event_types", + "columnsFrom": [ + "event_key" + ], + "columnsTo": [ + "event_key" + ], + "onDelete": "restrict", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ownaccounts": { + "name": "ownaccounts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "profiles": { + "name": "profiles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "ownaccounts_tenant_tenants_id_fk": { + "name": "ownaccounts_tenant_tenants_id_fk", + "tableFrom": "ownaccounts", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "ownaccounts_updated_by_auth_users_id_fk": { + "name": "ownaccounts_updated_by_auth_users_id_fk", + "tableFrom": "ownaccounts", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.plants": { + "name": "plants", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "plants_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "customer": { + "name": "customer", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "infoData": { + "name": "infoData", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "contract": { + "name": "contract", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{\"html\":\"\",\"json\":[],\"text\":\"\"}'::jsonb" + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "profiles": { + "name": "profiles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "plants_tenant_tenants_id_fk": { + "name": "plants_tenant_tenants_id_fk", + "tableFrom": "plants", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "plants_customer_customers_id_fk": { + "name": "plants_customer_customers_id_fk", + "tableFrom": "plants", + "tableTo": "customers", + "columnsFrom": [ + "customer" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "plants_contract_contracts_id_fk": { + "name": "plants_contract_contracts_id_fk", + "tableFrom": "plants", + "tableTo": "contracts", + "columnsFrom": [ + "contract" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "plants_updated_by_auth_users_id_fk": { + "name": "plants_updated_by_auth_users_id_fk", + "tableFrom": "plants", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.productcategories": { + "name": "productcategories", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "productcategories_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "productcategories_tenant_tenants_id_fk": { + "name": "productcategories_tenant_tenants_id_fk", + "tableFrom": "productcategories", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "productcategories_updated_by_auth_users_id_fk": { + "name": "productcategories_updated_by_auth_users_id_fk", + "tableFrom": "productcategories", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.products": { + "name": "products", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "products_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "manufacturer": { + "name": "manufacturer", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "unit": { + "name": "unit", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "tags": { + "name": "tags", + "type": "json", + "primaryKey": false, + "notNull": true, + "default": "'[]'::json" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "ean": { + "name": "ean", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "barcode": { + "name": "barcode", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "purchasePrice": { + "name": "purchasePrice", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "sellingPrice": { + "name": "sellingPrice", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "manufacturerNumber": { + "name": "manufacturerNumber", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vendorAllocation": { + "name": "vendorAllocation", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "articleNumber": { + "name": "articleNumber", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "barcodes": { + "name": "barcodes", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "productcategories": { + "name": "productcategories", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "taxPercentage": { + "name": "taxPercentage", + "type": "smallint", + "primaryKey": false, + "notNull": true, + "default": 19 + }, + "markupPercentage": { + "name": "markupPercentage", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "products_unit_units_id_fk": { + "name": "products_unit_units_id_fk", + "tableFrom": "products", + "tableTo": "units", + "columnsFrom": [ + "unit" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "products_tenant_tenants_id_fk": { + "name": "products_tenant_tenants_id_fk", + "tableFrom": "products", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "products_updated_by_auth_users_id_fk": { + "name": "products_updated_by_auth_users_id_fk", + "tableFrom": "products", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.projects": { + "name": "projects", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "projects_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "customer": { + "name": "customer", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "phases": { + "name": "phases", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "description": { + "name": "description", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "forms": { + "name": "forms", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "heroId": { + "name": "heroId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "measure": { + "name": "measure", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "material": { + "name": "material", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "plant": { + "name": "plant", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "profiles": { + "name": "profiles", + "type": "uuid[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "projectNumber": { + "name": "projectNumber", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contract": { + "name": "contract", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "projectType": { + "name": "projectType", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'Projekt'" + }, + "projecttype": { + "name": "projecttype", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "customerRef": { + "name": "customerRef", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "active_phase": { + "name": "active_phase", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "projects_tenant_tenants_id_fk": { + "name": "projects_tenant_tenants_id_fk", + "tableFrom": "projects", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "projects_customer_customers_id_fk": { + "name": "projects_customer_customers_id_fk", + "tableFrom": "projects", + "tableTo": "customers", + "columnsFrom": [ + "customer" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "projects_contract_contracts_id_fk": { + "name": "projects_contract_contracts_id_fk", + "tableFrom": "projects", + "tableTo": "contracts", + "columnsFrom": [ + "contract" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "projects_projecttype_projecttypes_id_fk": { + "name": "projects_projecttype_projecttypes_id_fk", + "tableFrom": "projects", + "tableTo": "projecttypes", + "columnsFrom": [ + "projecttype" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "projects_updated_by_auth_users_id_fk": { + "name": "projects_updated_by_auth_users_id_fk", + "tableFrom": "projects", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.projecttypes": { + "name": "projecttypes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "projecttypes_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "initialPhases": { + "name": "initialPhases", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "addablePhases": { + "name": "addablePhases", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "projecttypes_tenant_tenants_id_fk": { + "name": "projecttypes_tenant_tenants_id_fk", + "tableFrom": "projecttypes", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "projecttypes_updated_by_auth_users_id_fk": { + "name": "projecttypes_updated_by_auth_users_id_fk", + "tableFrom": "projecttypes", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.servicecategories": { + "name": "servicecategories", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "servicecategories_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "discount": { + "name": "discount", + "type": "double precision", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "servicecategories_tenant_tenants_id_fk": { + "name": "servicecategories_tenant_tenants_id_fk", + "tableFrom": "servicecategories", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "servicecategories_updated_by_auth_users_id_fk": { + "name": "servicecategories_updated_by_auth_users_id_fk", + "tableFrom": "servicecategories", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.services": { + "name": "services", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "services_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sellingPrice": { + "name": "sellingPrice", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "unit": { + "name": "unit", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "serviceNumber": { + "name": "serviceNumber", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "servicecategories": { + "name": "servicecategories", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "purchasePriceComposed": { + "name": "purchasePriceComposed", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{\"total\":0}'::jsonb" + }, + "sellingPriceComposed": { + "name": "sellingPriceComposed", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{\"total\":0}'::jsonb" + }, + "taxPercentage": { + "name": "taxPercentage", + "type": "smallint", + "primaryKey": false, + "notNull": true, + "default": 19 + }, + "materialComposition": { + "name": "materialComposition", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "personalComposition": { + "name": "personalComposition", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "services_tenant_tenants_id_fk": { + "name": "services_tenant_tenants_id_fk", + "tableFrom": "services", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "services_unit_units_id_fk": { + "name": "services_unit_units_id_fk", + "tableFrom": "services", + "tableTo": "units", + "columnsFrom": [ + "unit" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "services_updated_by_auth_users_id_fk": { + "name": "services_updated_by_auth_users_id_fk", + "tableFrom": "services", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.spaces": { + "name": "spaces", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "spaces_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "spaceNumber": { + "name": "spaceNumber", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "parentSpace": { + "name": "parentSpace", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "infoData": { + "name": "infoData", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{\"zip\":\"\",\"city\":\"\",\"streetNumber\":\"\"}'::jsonb" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "spaces_tenant_tenants_id_fk": { + "name": "spaces_tenant_tenants_id_fk", + "tableFrom": "spaces", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "spaces_parentSpace_spaces_id_fk": { + "name": "spaces_parentSpace_spaces_id_fk", + "tableFrom": "spaces", + "tableTo": "spaces", + "columnsFrom": [ + "parentSpace" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "spaces_updated_by_auth_users_id_fk": { + "name": "spaces_updated_by_auth_users_id_fk", + "tableFrom": "spaces", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.staff_time_entries": { + "name": "staff_time_entries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "stopped_at": { + "name": "stopped_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "duration_minutes": { + "name": "duration_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "generated": { + "as": "CASE \n WHEN stopped_at IS NOT NULL \n THEN (EXTRACT(epoch FROM (stopped_at - started_at)) / 60)\n ELSE NULL\n END", + "type": "stored" + } + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'work'" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "times_state", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "device": { + "name": "device", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "internal_note": { + "name": "internal_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vacation_reason": { + "name": "vacation_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vacation_days": { + "name": "vacation_days", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "approved_by": { + "name": "approved_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "approved_at": { + "name": "approved_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "sick_reason": { + "name": "sick_reason", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "staff_time_entries_tenant_id_tenants_id_fk": { + "name": "staff_time_entries_tenant_id_tenants_id_fk", + "tableFrom": "staff_time_entries", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "staff_time_entries_user_id_auth_users_id_fk": { + "name": "staff_time_entries_user_id_auth_users_id_fk", + "tableFrom": "staff_time_entries", + "tableTo": "auth_users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "staff_time_entries_updated_by_auth_users_id_fk": { + "name": "staff_time_entries_updated_by_auth_users_id_fk", + "tableFrom": "staff_time_entries", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "staff_time_entries_approved_by_auth_users_id_fk": { + "name": "staff_time_entries_approved_by_auth_users_id_fk", + "tableFrom": "staff_time_entries", + "tableTo": "auth_users", + "columnsFrom": [ + "approved_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.staff_time_entry_connects": { + "name": "staff_time_entry_connects", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "time_entry_id": { + "name": "time_entry_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "stopped_at": { + "name": "stopped_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "duration_minutes": { + "name": "duration_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "generated": { + "as": "(EXTRACT(epoch FROM (stopped_at - started_at)) / 60)", + "type": "stored" + } + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "staff_time_entry_connects_time_entry_id_staff_time_entries_id_fk": { + "name": "staff_time_entry_connects_time_entry_id_staff_time_entries_id_fk", + "tableFrom": "staff_time_entry_connects", + "tableTo": "staff_time_entries", + "columnsFrom": [ + "time_entry_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.staff_zeitstromtimestamps": { + "name": "staff_zeitstromtimestamps", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "profile": { + "name": "profile", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "intent": { + "name": "intent", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "time": { + "name": "time", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "staff_time_entry": { + "name": "staff_time_entry", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "internal_note": { + "name": "internal_note", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "staff_zeitstromtimestamps_tenant_tenants_id_fk": { + "name": "staff_zeitstromtimestamps_tenant_tenants_id_fk", + "tableFrom": "staff_zeitstromtimestamps", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "staff_zeitstromtimestamps_profile_auth_profiles_id_fk": { + "name": "staff_zeitstromtimestamps_profile_auth_profiles_id_fk", + "tableFrom": "staff_zeitstromtimestamps", + "tableTo": "auth_profiles", + "columnsFrom": [ + "profile" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "staff_zeitstromtimestamps_staff_time_entry_staff_time_entries_id_fk": { + "name": "staff_zeitstromtimestamps_staff_time_entry_staff_time_entries_id_fk", + "tableFrom": "staff_zeitstromtimestamps", + "tableTo": "staff_time_entries", + "columnsFrom": [ + "staff_time_entry" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.statementallocations": { + "name": "statementallocations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "bs_id": { + "name": "bs_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "cd_id": { + "name": "cd_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "amount": { + "name": "amount", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "ii_id": { + "name": "ii_id", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "account": { + "name": "account", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "ownaccount": { + "name": "ownaccount", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "customer": { + "name": "customer", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "vendor": { + "name": "vendor", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "statementallocations_bs_id_bankstatements_id_fk": { + "name": "statementallocations_bs_id_bankstatements_id_fk", + "tableFrom": "statementallocations", + "tableTo": "bankstatements", + "columnsFrom": [ + "bs_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "statementallocations_cd_id_createddocuments_id_fk": { + "name": "statementallocations_cd_id_createddocuments_id_fk", + "tableFrom": "statementallocations", + "tableTo": "createddocuments", + "columnsFrom": [ + "cd_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "statementallocations_ii_id_incominginvoices_id_fk": { + "name": "statementallocations_ii_id_incominginvoices_id_fk", + "tableFrom": "statementallocations", + "tableTo": "incominginvoices", + "columnsFrom": [ + "ii_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "statementallocations_tenant_tenants_id_fk": { + "name": "statementallocations_tenant_tenants_id_fk", + "tableFrom": "statementallocations", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "statementallocations_account_accounts_id_fk": { + "name": "statementallocations_account_accounts_id_fk", + "tableFrom": "statementallocations", + "tableTo": "accounts", + "columnsFrom": [ + "account" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "statementallocations_ownaccount_ownaccounts_id_fk": { + "name": "statementallocations_ownaccount_ownaccounts_id_fk", + "tableFrom": "statementallocations", + "tableTo": "ownaccounts", + "columnsFrom": [ + "ownaccount" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "statementallocations_customer_customers_id_fk": { + "name": "statementallocations_customer_customers_id_fk", + "tableFrom": "statementallocations", + "tableTo": "customers", + "columnsFrom": [ + "customer" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "statementallocations_vendor_vendors_id_fk": { + "name": "statementallocations_vendor_vendors_id_fk", + "tableFrom": "statementallocations", + "tableTo": "vendors", + "columnsFrom": [ + "vendor" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "statementallocations_updated_by_auth_users_id_fk": { + "name": "statementallocations_updated_by_auth_users_id_fk", + "tableFrom": "statementallocations", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tasks": { + "name": "tasks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "tasks_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "categorie": { + "name": "categorie", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "project": { + "name": "project", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "plant": { + "name": "plant", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "customer": { + "name": "customer", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "profiles": { + "name": "profiles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "tasks_tenant_tenants_id_fk": { + "name": "tasks_tenant_tenants_id_fk", + "tableFrom": "tasks", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "tasks_user_id_auth_users_id_fk": { + "name": "tasks_user_id_auth_users_id_fk", + "tableFrom": "tasks", + "tableTo": "auth_users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "tasks_customer_customers_id_fk": { + "name": "tasks_customer_customers_id_fk", + "tableFrom": "tasks", + "tableTo": "customers", + "columnsFrom": [ + "customer" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "tasks_updated_by_auth_users_id_fk": { + "name": "tasks_updated_by_auth_users_id_fk", + "tableFrom": "tasks", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.taxtypes": { + "name": "taxtypes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "taxtypes_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "percentage": { + "name": "percentage", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "taxtypes_updated_by_auth_users_id_fk": { + "name": "taxtypes_updated_by_auth_users_id_fk", + "tableFrom": "taxtypes", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tenants": { + "name": "tenants", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "tenants_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "short": { + "name": "short", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "calendarConfig": { + "name": "calendarConfig", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{\"eventTypes\":[{\"color\":\"blue\",\"label\":\"Büro\"},{\"color\":\"yellow\",\"label\":\"Besprechung\"},{\"color\":\"green\",\"label\":\"Umsetzung\"},{\"color\":\"red\",\"label\":\"Vor Ort Termin\"}]}'::jsonb" + }, + "timeConfig": { + "name": "timeConfig", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{\"products\":[],\"documents\":[]}'::jsonb" + }, + "measures": { + "name": "measures", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[{\"name\":\"Netzwerktechnik\",\"short\":\"NWT\"},{\"name\":\"Elektrotechnik\",\"short\":\"ELT\"},{\"name\":\"Photovoltaik\",\"short\":\"PV\"},{\"name\":\"Videüberwachung\",\"short\":\"VÜA\"},{\"name\":\"Projekt\",\"short\":\"PRJ\"},{\"name\":\"Smart Home\",\"short\":\"SHO\"}]'::jsonb" + }, + "businessInfo": { + "name": "businessInfo", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{\"zip\":\"\",\"city\":\"\",\"name\":\"\",\"street\":\"\"}'::jsonb" + }, + "features": { + "name": "features", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{\"objects\":true,\"calendar\":true,\"contacts\":true,\"projects\":true,\"vehicles\":true,\"contracts\":true,\"inventory\":true,\"accounting\":true,\"timeTracking\":true,\"planningBoard\":true,\"workingTimeTracking\":true}'::jsonb" + }, + "ownFields": { + "name": "ownFields", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "numberRanges": { + "name": "numberRanges", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{\"vendors\":{\"prefix\":\"\",\"suffix\":\"\",\"nextNumber\":10000},\"customers\":{\"prefix\":\"\",\"suffix\":\"\",\"nextNumber\":10000},\"products\":{\"prefix\":\"AT-\",\"suffix\":\"\",\"nextNumber\":1000},\"quotes\":{\"prefix\":\"AN-\",\"suffix\":\"\",\"nextNumber\":1000},\"confirmationOrders\":{\"prefix\":\"AB-\",\"suffix\":\"\",\"nextNumber\":1000},\"invoices\":{\"prefix\":\"RE-\",\"suffix\":\"\",\"nextNumber\":1000},\"spaces\":{\"prefix\":\"LP-\",\"suffix\":\"\",\"nextNumber\":1000},\"inventoryitems\":{\"prefix\":\"IA-\",\"suffix\":\"\",\"nextNumber\":1000},\"projects\":{\"prefix\":\"PRJ-\",\"suffix\":\"\",\"nextNumber\":1000},\"costcentres\":{\"prefix\":\"KST-\",\"suffix\":\"\",\"nextNumber\":1000}}'::jsonb" + }, + "standardEmailForInvoices": { + "name": "standardEmailForInvoices", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "extraModules": { + "name": "extraModules", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "isInTrial": { + "name": "isInTrial", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "trialEndDate": { + "name": "trialEndDate", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "stripeCustomerId": { + "name": "stripeCustomerId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "hasActiveLicense": { + "name": "hasActiveLicense", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "userLicenseCount": { + "name": "userLicenseCount", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "workstationLicenseCount": { + "name": "workstationLicenseCount", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "standardPaymentDays": { + "name": "standardPaymentDays", + "type": "smallint", + "primaryKey": false, + "notNull": true, + "default": 14 + }, + "dokuboxEmailAddresses": { + "name": "dokuboxEmailAddresses", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "dokuboxkey": { + "name": "dokuboxkey", + "type": "uuid", + "primaryKey": false, + "notNull": true, + "default": "gen_random_uuid()" + }, + "autoPrepareIncomingInvoices": { + "name": "autoPrepareIncomingInvoices", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "portalDomain": { + "name": "portalDomain", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "portalConfig": { + "name": "portalConfig", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{\"primayColor\":\"#69c350\"}'::jsonb" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "locked": { + "name": "locked", + "type": "locked_tenant", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "tenants_updated_by_auth_users_id_fk": { + "name": "tenants_updated_by_auth_users_id_fk", + "tableFrom": "tenants", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.texttemplates": { + "name": "texttemplates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "texttemplates_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "documentType": { + "name": "documentType", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "''" + }, + "default": { + "name": "default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "pos": { + "name": "pos", + "type": "texttemplatepositions", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "texttemplates_tenant_tenants_id_fk": { + "name": "texttemplates_tenant_tenants_id_fk", + "tableFrom": "texttemplates", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "texttemplates_updated_by_auth_users_id_fk": { + "name": "texttemplates_updated_by_auth_users_id_fk", + "tableFrom": "texttemplates", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.units": { + "name": "units", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "units_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "single": { + "name": "single", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "multiple": { + "name": "multiple", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "short": { + "name": "short", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "step": { + "name": "step", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'1'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_credentials": { + "name": "user_credentials", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "smtp_port": { + "name": "smtp_port", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "smtp_ssl": { + "name": "smtp_ssl", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "credential_types", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "imap_port": { + "name": "imap_port", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "imap_ssl": { + "name": "imap_ssl", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "email_encrypted": { + "name": "email_encrypted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "password_encrypted": { + "name": "password_encrypted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "smtp_host_encrypted": { + "name": "smtp_host_encrypted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "imap_host_encrypted": { + "name": "imap_host_encrypted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "access_token_encrypted": { + "name": "access_token_encrypted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "refresh_token_encrypted": { + "name": "refresh_token_encrypted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "user_credentials_user_id_auth_users_id_fk": { + "name": "user_credentials_user_id_auth_users_id_fk", + "tableFrom": "user_credentials", + "tableTo": "auth_users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "user_credentials_tenant_id_tenants_id_fk": { + "name": "user_credentials_tenant_id_tenants_id_fk", + "tableFrom": "user_credentials", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.vehicles": { + "name": "vehicles", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "vehicles_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "licensePlate": { + "name": "licensePlate", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "driver": { + "name": "driver", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "vin": { + "name": "vin", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tankSize": { + "name": "tankSize", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "buildYear": { + "name": "buildYear", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "towingCapacity": { + "name": "towingCapacity", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "powerInKW": { + "name": "powerInKW", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "profiles": { + "name": "profiles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "vehicles_tenant_tenants_id_fk": { + "name": "vehicles_tenant_tenants_id_fk", + "tableFrom": "vehicles", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "vehicles_driver_auth_users_id_fk": { + "name": "vehicles_driver_auth_users_id_fk", + "tableFrom": "vehicles", + "tableTo": "auth_users", + "columnsFrom": [ + "driver" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "vehicles_updated_by_auth_users_id_fk": { + "name": "vehicles_updated_by_auth_users_id_fk", + "tableFrom": "vehicles", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.vendors": { + "name": "vendors", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "vendors_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "vendorNumber": { + "name": "vendorNumber", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "infoData": { + "name": "infoData", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "hasSEPA": { + "name": "hasSEPA", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "profiles": { + "name": "profiles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "defaultPaymentMethod": { + "name": "defaultPaymentMethod", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "vendors_tenant_tenants_id_fk": { + "name": "vendors_tenant_tenants_id_fk", + "tableFrom": "vendors", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "vendors_updated_by_auth_users_id_fk": { + "name": "vendors_updated_by_auth_users_id_fk", + "tableFrom": "vendors", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.credential_types": { + "name": "credential_types", + "schema": "public", + "values": [ + "mail", + "m365" + ] + }, + "public.folderfunctions": { + "name": "folderfunctions", + "schema": "public", + "values": [ + "none", + "yearSubCategory", + "incomingInvoices", + "invoices", + "quotes", + "confirmationOrders", + "deliveryNotes", + "vehicleData", + "reminders", + "taxData", + "deposit", + "timeEvaluations" + ] + }, + "public.locked_tenant": { + "name": "locked_tenant", + "schema": "public", + "values": [ + "maintenance_tenant", + "maintenance", + "general", + "no_subscription" + ] + }, + "public.notification_channel": { + "name": "notification_channel", + "schema": "public", + "values": [ + "email", + "inapp", + "sms", + "push", + "webhook" + ] + }, + "public.notification_severity": { + "name": "notification_severity", + "schema": "public", + "values": [ + "info", + "success", + "warning", + "error" + ] + }, + "public.notification_status": { + "name": "notification_status", + "schema": "public", + "values": [ + "queued", + "sent", + "failed", + "read" + ] + }, + "public.payment_types": { + "name": "payment_types", + "schema": "public", + "values": [ + "transfer", + "direct_debit" + ] + }, + "public.texttemplatepositions": { + "name": "texttemplatepositions", + "schema": "public", + "values": [ + "startText", + "endText" + ] + }, + "public.times_state": { + "name": "times_state", + "schema": "public", + "values": [ + "submitted", + "approved", + "draft" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/db/migrations/meta/0001_snapshot.json b/db/migrations/meta/0001_snapshot.json new file mode 100644 index 0000000..f5a2f32 --- /dev/null +++ b/db/migrations/meta/0001_snapshot.json @@ -0,0 +1,9947 @@ +{ + "id": "91737e8e-9323-4b3f-9c03-13793e3b160c", + "prevId": "c74cefc4-5ae7-408c-b7f3-09093efb52b5", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.accounts": { + "name": "accounts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "accounts_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_profiles": { + "name": "auth_profiles", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "generated": { + "as": "((first_name || ' ') || last_name)", + "type": "stored" + } + }, + "mobile_tel": { + "name": "mobile_tel", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "fixed_tel": { + "name": "fixed_tel", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "salutation": { + "name": "salutation", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "employee_number": { + "name": "employee_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "weekly_working_hours": { + "name": "weekly_working_hours", + "type": "double precision", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "annual_paid_leave_days": { + "name": "annual_paid_leave_days", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "weekly_regular_working_hours": { + "name": "weekly_regular_working_hours", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'" + }, + "clothing_size_top": { + "name": "clothing_size_top", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "clothing_size_bottom": { + "name": "clothing_size_bottom", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "clothing_size_shoe": { + "name": "clothing_size_shoe", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email_signature": { + "name": "email_signature", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'Mit freundlichen Grüßen
'" + }, + "birthday": { + "name": "birthday", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "entry_date": { + "name": "entry_date", + "type": "date", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "automatic_hour_corrections": { + "name": "automatic_hour_corrections", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'" + }, + "recreation_days_compensation": { + "name": "recreation_days_compensation", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "customer_for_portal": { + "name": "customer_for_portal", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "pinned_on_navigation": { + "name": "pinned_on_navigation", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'" + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "token_id": { + "name": "token_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "weekly_working_days": { + "name": "weekly_working_days", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "old_profile_id": { + "name": "old_profile_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "temp_config": { + "name": "temp_config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "state_code": { + "name": "state_code", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'DE-NI'" + }, + "contract_type": { + "name": "contract_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "qualification": { + "name": "qualification", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "address_street": { + "name": "address_street", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "address_zip": { + "name": "address_zip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "address_city": { + "name": "address_city", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + } + }, + "indexes": {}, + "foreignKeys": { + "auth_profiles_user_id_auth_users_id_fk": { + "name": "auth_profiles_user_id_auth_users_id_fk", + "tableFrom": "auth_profiles", + "tableTo": "auth_users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_role_permissions": { + "name": "auth_role_permissions", + "schema": "", + "columns": { + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "role_id": { + "name": "role_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "permission": { + "name": "permission", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "auth_role_permissions_role_id_auth_roles_id_fk": { + "name": "auth_role_permissions_role_id_auth_roles_id_fk", + "tableFrom": "auth_role_permissions", + "tableTo": "auth_roles", + "columnsFrom": [ + "role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_roles": { + "name": "auth_roles", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "auth_roles_created_by_auth_users_id_fk": { + "name": "auth_roles_created_by_auth_users_id_fk", + "tableFrom": "auth_roles", + "tableTo": "auth_users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_tenant_users": { + "name": "auth_tenant_users", + "schema": "", + "columns": { + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "auth_tenant_users_created_by_auth_users_id_fk": { + "name": "auth_tenant_users_created_by_auth_users_id_fk", + "tableFrom": "auth_tenant_users", + "tableTo": "auth_users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_user_roles": { + "name": "auth_user_roles", + "schema": "", + "columns": { + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role_id": { + "name": "role_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "auth_user_roles_user_id_auth_users_id_fk": { + "name": "auth_user_roles_user_id_auth_users_id_fk", + "tableFrom": "auth_user_roles", + "tableTo": "auth_users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "auth_user_roles_role_id_auth_roles_id_fk": { + "name": "auth_user_roles_role_id_auth_roles_id_fk", + "tableFrom": "auth_user_roles", + "tableTo": "auth_roles", + "columnsFrom": [ + "role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "auth_user_roles_created_by_auth_users_id_fk": { + "name": "auth_user_roles_created_by_auth_users_id_fk", + "tableFrom": "auth_user_roles", + "tableTo": "auth_users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_users": { + "name": "auth_users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "password_hash": { + "name": "password_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "multi_tenant": { + "name": "multi_tenant", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "must_change_password": { + "name": "must_change_password", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "ported": { + "name": "ported", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.bankaccounts": { + "name": "bankaccounts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "bankaccounts_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "iban": { + "name": "iban", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "bankId": { + "name": "bankId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ownerName": { + "name": "ownerName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "accountId": { + "name": "accountId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "balance": { + "name": "balance", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "expired": { + "name": "expired", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "datevNumber": { + "name": "datevNumber", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "synced_at": { + "name": "synced_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "bankaccounts_tenant_tenants_id_fk": { + "name": "bankaccounts_tenant_tenants_id_fk", + "tableFrom": "bankaccounts", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "bankaccounts_updated_by_auth_users_id_fk": { + "name": "bankaccounts_updated_by_auth_users_id_fk", + "tableFrom": "bankaccounts", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.bankrequisitions": { + "name": "bankrequisitions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "institutionId": { + "name": "institutionId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "bankrequisitions_tenant_tenants_id_fk": { + "name": "bankrequisitions_tenant_tenants_id_fk", + "tableFrom": "bankrequisitions", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "bankrequisitions_updated_by_auth_users_id_fk": { + "name": "bankrequisitions_updated_by_auth_users_id_fk", + "tableFrom": "bankrequisitions", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.bankstatements": { + "name": "bankstatements", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "bankstatements_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "account": { + "name": "account", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "credIban": { + "name": "credIban", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "credName": { + "name": "credName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "amount": { + "name": "amount", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "debIban": { + "name": "debIban", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "debName": { + "name": "debName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "gocardlessId": { + "name": "gocardlessId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "valueDate": { + "name": "valueDate", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "mandateId": { + "name": "mandateId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contract": { + "name": "contract", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "bankstatements_account_bankaccounts_id_fk": { + "name": "bankstatements_account_bankaccounts_id_fk", + "tableFrom": "bankstatements", + "tableTo": "bankaccounts", + "columnsFrom": [ + "account" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "bankstatements_tenant_tenants_id_fk": { + "name": "bankstatements_tenant_tenants_id_fk", + "tableFrom": "bankstatements", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "bankstatements_contract_contracts_id_fk": { + "name": "bankstatements_contract_contracts_id_fk", + "tableFrom": "bankstatements", + "tableTo": "contracts", + "columnsFrom": [ + "contract" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "bankstatements_updated_by_auth_users_id_fk": { + "name": "bankstatements_updated_by_auth_users_id_fk", + "tableFrom": "bankstatements", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.checkexecutions": { + "name": "checkexecutions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "check": { + "name": "check", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "executed_at": { + "name": "executed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "checkexecutions_check_checks_id_fk": { + "name": "checkexecutions_check_checks_id_fk", + "tableFrom": "checkexecutions", + "tableTo": "checks", + "columnsFrom": [ + "check" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.checks": { + "name": "checks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "vehicle": { + "name": "vehicle", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "inventoryitem": { + "name": "inventoryitem", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "distance": { + "name": "distance", + "type": "bigint", + "primaryKey": false, + "notNull": false, + "default": 1 + }, + "distanceUnit": { + "name": "distanceUnit", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'days'" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "profiles": { + "name": "profiles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "checks_vehicle_vehicles_id_fk": { + "name": "checks_vehicle_vehicles_id_fk", + "tableFrom": "checks", + "tableTo": "vehicles", + "columnsFrom": [ + "vehicle" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "checks_inventoryitem_inventoryitems_id_fk": { + "name": "checks_inventoryitem_inventoryitems_id_fk", + "tableFrom": "checks", + "tableTo": "inventoryitems", + "columnsFrom": [ + "inventoryitem" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "checks_tenant_tenants_id_fk": { + "name": "checks_tenant_tenants_id_fk", + "tableFrom": "checks", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "checks_updated_by_auth_users_id_fk": { + "name": "checks_updated_by_auth_users_id_fk", + "tableFrom": "checks", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.citys": { + "name": "citys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "citys_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "short": { + "name": "short", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "long": { + "name": "long", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "geometry": { + "name": "geometry", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "zip": { + "name": "zip", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "districtCode": { + "name": "districtCode", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "countryName": { + "name": "countryName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "countryCode": { + "name": "countryCode", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "districtName": { + "name": "districtName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "geopoint": { + "name": "geopoint", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.contacts": { + "name": "contacts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "contacts_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "firstName": { + "name": "firstName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lastName": { + "name": "lastName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "customer": { + "name": "customer", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "phoneMobile": { + "name": "phoneMobile", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phoneHome": { + "name": "phoneHome", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "heroId": { + "name": "heroId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "fullName": { + "name": "fullName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "salutation": { + "name": "salutation", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vendor": { + "name": "vendor", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "birthday": { + "name": "birthday", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "profiles": { + "name": "profiles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "contacts_customer_customers_id_fk": { + "name": "contacts_customer_customers_id_fk", + "tableFrom": "contacts", + "tableTo": "customers", + "columnsFrom": [ + "customer" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "contacts_updated_by_auth_users_id_fk": { + "name": "contacts_updated_by_auth_users_id_fk", + "tableFrom": "contacts", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.contracts": { + "name": "contracts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "contracts_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "customer": { + "name": "customer", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "recurring": { + "name": "recurring", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "rhythm": { + "name": "rhythm", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "startDate": { + "name": "startDate", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "endDate": { + "name": "endDate", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "signDate": { + "name": "signDate", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "duration": { + "name": "duration", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contact": { + "name": "contact", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "bankingIban": { + "name": "bankingIban", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "bankingBIC": { + "name": "bankingBIC", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "bankingName": { + "name": "bankingName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "bankingOwner": { + "name": "bankingOwner", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sepaRef": { + "name": "sepaRef", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sepaDate": { + "name": "sepaDate", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "paymentType": { + "name": "paymentType", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "invoiceDispatch": { + "name": "invoiceDispatch", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ownFields": { + "name": "ownFields", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "profiles": { + "name": "profiles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "contractNumber": { + "name": "contractNumber", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "contracts_customer_customers_id_fk": { + "name": "contracts_customer_customers_id_fk", + "tableFrom": "contracts", + "tableTo": "customers", + "columnsFrom": [ + "customer" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "contracts_contact_contacts_id_fk": { + "name": "contracts_contact_contacts_id_fk", + "tableFrom": "contracts", + "tableTo": "contacts", + "columnsFrom": [ + "contact" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "contracts_updated_by_auth_users_id_fk": { + "name": "contracts_updated_by_auth_users_id_fk", + "tableFrom": "contracts", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.costcentres": { + "name": "costcentres", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "vehicle": { + "name": "vehicle", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "project": { + "name": "project", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "inventoryitem": { + "name": "inventoryitem", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "profiles": { + "name": "profiles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "costcentres_tenant_tenants_id_fk": { + "name": "costcentres_tenant_tenants_id_fk", + "tableFrom": "costcentres", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "costcentres_vehicle_vehicles_id_fk": { + "name": "costcentres_vehicle_vehicles_id_fk", + "tableFrom": "costcentres", + "tableTo": "vehicles", + "columnsFrom": [ + "vehicle" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "costcentres_project_projects_id_fk": { + "name": "costcentres_project_projects_id_fk", + "tableFrom": "costcentres", + "tableTo": "projects", + "columnsFrom": [ + "project" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "costcentres_inventoryitem_inventoryitems_id_fk": { + "name": "costcentres_inventoryitem_inventoryitems_id_fk", + "tableFrom": "costcentres", + "tableTo": "inventoryitems", + "columnsFrom": [ + "inventoryitem" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "costcentres_updated_by_auth_users_id_fk": { + "name": "costcentres_updated_by_auth_users_id_fk", + "tableFrom": "costcentres", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.countrys": { + "name": "countrys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "countrys_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.createddocuments": { + "name": "createddocuments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "createddocuments_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'INVOICE'" + }, + "customer": { + "name": "customer", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "contact": { + "name": "contact", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "address": { + "name": "address", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "project": { + "name": "project", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "documentNumber": { + "name": "documentNumber", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "documentDate": { + "name": "documentDate", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'Entwurf'" + }, + "info": { + "name": "info", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "createdBy": { + "name": "createdBy", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "startText": { + "name": "startText", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "endText": { + "name": "endText", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "rows": { + "name": "rows", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "deliveryDateType": { + "name": "deliveryDateType", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "paymentDays": { + "name": "paymentDays", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "deliveryDate": { + "name": "deliveryDate", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contactPerson": { + "name": "contactPerson", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "serialConfig": { + "name": "serialConfig", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "linkedDocument": { + "name": "linkedDocument", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "agriculture": { + "name": "agriculture", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "letterhead": { + "name": "letterhead", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "advanceInvoiceResolved": { + "name": "advanceInvoiceResolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "usedAdvanceInvoices": { + "name": "usedAdvanceInvoices", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "deliveryDateEnd": { + "name": "deliveryDateEnd", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "plant": { + "name": "plant", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "taxType": { + "name": "taxType", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "customSurchargePercentage": { + "name": "customSurchargePercentage", + "type": "smallint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "report": { + "name": "report", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "availableInPortal": { + "name": "availableInPortal", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "payment_type": { + "name": "payment_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'transfer'" + }, + "contract": { + "name": "contract", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "createddocuments_tenant_tenants_id_fk": { + "name": "createddocuments_tenant_tenants_id_fk", + "tableFrom": "createddocuments", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "createddocuments_customer_customers_id_fk": { + "name": "createddocuments_customer_customers_id_fk", + "tableFrom": "createddocuments", + "tableTo": "customers", + "columnsFrom": [ + "customer" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "createddocuments_contact_contacts_id_fk": { + "name": "createddocuments_contact_contacts_id_fk", + "tableFrom": "createddocuments", + "tableTo": "contacts", + "columnsFrom": [ + "contact" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "createddocuments_project_projects_id_fk": { + "name": "createddocuments_project_projects_id_fk", + "tableFrom": "createddocuments", + "tableTo": "projects", + "columnsFrom": [ + "project" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "createddocuments_createdBy_auth_users_id_fk": { + "name": "createddocuments_createdBy_auth_users_id_fk", + "tableFrom": "createddocuments", + "tableTo": "auth_users", + "columnsFrom": [ + "createdBy" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "createddocuments_linkedDocument_createddocuments_id_fk": { + "name": "createddocuments_linkedDocument_createddocuments_id_fk", + "tableFrom": "createddocuments", + "tableTo": "createddocuments", + "columnsFrom": [ + "linkedDocument" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "createddocuments_letterhead_letterheads_id_fk": { + "name": "createddocuments_letterhead_letterheads_id_fk", + "tableFrom": "createddocuments", + "tableTo": "letterheads", + "columnsFrom": [ + "letterhead" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "createddocuments_plant_plants_id_fk": { + "name": "createddocuments_plant_plants_id_fk", + "tableFrom": "createddocuments", + "tableTo": "plants", + "columnsFrom": [ + "plant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "createddocuments_updated_by_auth_users_id_fk": { + "name": "createddocuments_updated_by_auth_users_id_fk", + "tableFrom": "createddocuments", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "createddocuments_created_by_auth_users_id_fk": { + "name": "createddocuments_created_by_auth_users_id_fk", + "tableFrom": "createddocuments", + "tableTo": "auth_users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "createddocuments_contract_contracts_id_fk": { + "name": "createddocuments_contract_contracts_id_fk", + "tableFrom": "createddocuments", + "tableTo": "contracts", + "columnsFrom": [ + "contract" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.createdletters": { + "name": "createdletters", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "customer": { + "name": "customer", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "vendor": { + "name": "vendor", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "content_json": { + "name": "content_json", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "content_text": { + "name": "content_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "createdletters_tenant_tenants_id_fk": { + "name": "createdletters_tenant_tenants_id_fk", + "tableFrom": "createdletters", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "createdletters_customer_customers_id_fk": { + "name": "createdletters_customer_customers_id_fk", + "tableFrom": "createdletters", + "tableTo": "customers", + "columnsFrom": [ + "customer" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "createdletters_vendor_vendors_id_fk": { + "name": "createdletters_vendor_vendors_id_fk", + "tableFrom": "createdletters", + "tableTo": "vendors", + "columnsFrom": [ + "vendor" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "createdletters_updated_by_auth_users_id_fk": { + "name": "createdletters_updated_by_auth_users_id_fk", + "tableFrom": "createdletters", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.customers": { + "name": "customers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "customers_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "customerNumber": { + "name": "customerNumber", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "infoData": { + "name": "infoData", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'Privat'" + }, + "heroId": { + "name": "heroId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "isCompany": { + "name": "isCompany", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "profiles": { + "name": "profiles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "customPaymentDays": { + "name": "customPaymentDays", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "firstname": { + "name": "firstname", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lastname": { + "name": "lastname", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "customSurchargePercentage": { + "name": "customSurchargePercentage", + "type": "smallint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "salutation": { + "name": "salutation", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "nameAddition": { + "name": "nameAddition", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "availableInPortal": { + "name": "availableInPortal", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "custom_payment_type": { + "name": "custom_payment_type", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "customers_updated_by_auth_users_id_fk": { + "name": "customers_updated_by_auth_users_id_fk", + "tableFrom": "customers", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.devices": { + "name": "devices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "externalId": { + "name": "externalId", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "devices_tenant_tenants_id_fk": { + "name": "devices_tenant_tenants_id_fk", + "tableFrom": "devices", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.documentboxes": { + "name": "documentboxes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "space": { + "name": "space", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "documentboxes_space_spaces_id_fk": { + "name": "documentboxes_space_spaces_id_fk", + "tableFrom": "documentboxes", + "tableTo": "spaces", + "columnsFrom": [ + "space" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "documentboxes_tenant_tenants_id_fk": { + "name": "documentboxes_tenant_tenants_id_fk", + "tableFrom": "documentboxes", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "documentboxes_updated_by_auth_users_id_fk": { + "name": "documentboxes_updated_by_auth_users_id_fk", + "tableFrom": "documentboxes", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.events": { + "name": "events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "events_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "startDate": { + "name": "startDate", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "endDate": { + "name": "endDate", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "eventtype": { + "name": "eventtype", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'Umsetzung'" + }, + "project": { + "name": "project", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "resources": { + "name": "resources", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "link": { + "name": "link", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "profiles": { + "name": "profiles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "vehicles": { + "name": "vehicles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "inventoryitems": { + "name": "inventoryitems", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "inventoryitemgroups": { + "name": "inventoryitemgroups", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "customer": { + "name": "customer", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "vendor": { + "name": "vendor", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "events_customer_customers_id_fk": { + "name": "events_customer_customers_id_fk", + "tableFrom": "events", + "tableTo": "customers", + "columnsFrom": [ + "customer" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "events_updated_by_auth_users_id_fk": { + "name": "events_updated_by_auth_users_id_fk", + "tableFrom": "events", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.files": { + "name": "files", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "project": { + "name": "project", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "customer": { + "name": "customer", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "contract": { + "name": "contract", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "vendor": { + "name": "vendor", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "incominginvoice": { + "name": "incominginvoice", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "plant": { + "name": "plant", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "createddocument": { + "name": "createddocument", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "vehicle": { + "name": "vehicle", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "product": { + "name": "product", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "check": { + "name": "check", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "inventoryitem": { + "name": "inventoryitem", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "folder": { + "name": "folder", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "mimeType": { + "name": "mimeType", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "space": { + "name": "space", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "documentbox": { + "name": "documentbox", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "auth_profile": { + "name": "auth_profile", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "files_tenant_tenants_id_fk": { + "name": "files_tenant_tenants_id_fk", + "tableFrom": "files", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_project_projects_id_fk": { + "name": "files_project_projects_id_fk", + "tableFrom": "files", + "tableTo": "projects", + "columnsFrom": [ + "project" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_customer_customers_id_fk": { + "name": "files_customer_customers_id_fk", + "tableFrom": "files", + "tableTo": "customers", + "columnsFrom": [ + "customer" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_contract_contracts_id_fk": { + "name": "files_contract_contracts_id_fk", + "tableFrom": "files", + "tableTo": "contracts", + "columnsFrom": [ + "contract" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_vendor_vendors_id_fk": { + "name": "files_vendor_vendors_id_fk", + "tableFrom": "files", + "tableTo": "vendors", + "columnsFrom": [ + "vendor" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_incominginvoice_incominginvoices_id_fk": { + "name": "files_incominginvoice_incominginvoices_id_fk", + "tableFrom": "files", + "tableTo": "incominginvoices", + "columnsFrom": [ + "incominginvoice" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_plant_plants_id_fk": { + "name": "files_plant_plants_id_fk", + "tableFrom": "files", + "tableTo": "plants", + "columnsFrom": [ + "plant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_createddocument_createddocuments_id_fk": { + "name": "files_createddocument_createddocuments_id_fk", + "tableFrom": "files", + "tableTo": "createddocuments", + "columnsFrom": [ + "createddocument" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_vehicle_vehicles_id_fk": { + "name": "files_vehicle_vehicles_id_fk", + "tableFrom": "files", + "tableTo": "vehicles", + "columnsFrom": [ + "vehicle" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_product_products_id_fk": { + "name": "files_product_products_id_fk", + "tableFrom": "files", + "tableTo": "products", + "columnsFrom": [ + "product" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_check_checks_id_fk": { + "name": "files_check_checks_id_fk", + "tableFrom": "files", + "tableTo": "checks", + "columnsFrom": [ + "check" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_inventoryitem_inventoryitems_id_fk": { + "name": "files_inventoryitem_inventoryitems_id_fk", + "tableFrom": "files", + "tableTo": "inventoryitems", + "columnsFrom": [ + "inventoryitem" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_folder_folders_id_fk": { + "name": "files_folder_folders_id_fk", + "tableFrom": "files", + "tableTo": "folders", + "columnsFrom": [ + "folder" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_space_spaces_id_fk": { + "name": "files_space_spaces_id_fk", + "tableFrom": "files", + "tableTo": "spaces", + "columnsFrom": [ + "space" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_type_filetags_id_fk": { + "name": "files_type_filetags_id_fk", + "tableFrom": "files", + "tableTo": "filetags", + "columnsFrom": [ + "type" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_documentbox_documentboxes_id_fk": { + "name": "files_documentbox_documentboxes_id_fk", + "tableFrom": "files", + "tableTo": "documentboxes", + "columnsFrom": [ + "documentbox" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_updated_by_auth_users_id_fk": { + "name": "files_updated_by_auth_users_id_fk", + "tableFrom": "files", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_created_by_auth_users_id_fk": { + "name": "files_created_by_auth_users_id_fk", + "tableFrom": "files", + "tableTo": "auth_users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "files_auth_profile_auth_profiles_id_fk": { + "name": "files_auth_profile_auth_profiles_id_fk", + "tableFrom": "files", + "tableTo": "auth_profiles", + "columnsFrom": [ + "auth_profile" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.filetags": { + "name": "filetags", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "createddocumenttype": { + "name": "createddocumenttype", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "''" + }, + "incomingDocumentType": { + "name": "incomingDocumentType", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "filetags_tenant_tenants_id_fk": { + "name": "filetags_tenant_tenants_id_fk", + "tableFrom": "filetags", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.folders": { + "name": "folders", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "parent": { + "name": "parent", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "isSystemUsed": { + "name": "isSystemUsed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "function": { + "name": "function", + "type": "folderfunctions", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "year": { + "name": "year", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "standardFiletype": { + "name": "standardFiletype", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "standardFiletypeIsOptional": { + "name": "standardFiletypeIsOptional", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "folders_tenant_tenants_id_fk": { + "name": "folders_tenant_tenants_id_fk", + "tableFrom": "folders", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "folders_parent_folders_id_fk": { + "name": "folders_parent_folders_id_fk", + "tableFrom": "folders", + "tableTo": "folders", + "columnsFrom": [ + "parent" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "folders_standardFiletype_filetags_id_fk": { + "name": "folders_standardFiletype_filetags_id_fk", + "tableFrom": "folders", + "tableTo": "filetags", + "columnsFrom": [ + "standardFiletype" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "folders_updated_by_auth_users_id_fk": { + "name": "folders_updated_by_auth_users_id_fk", + "tableFrom": "folders", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.exports": { + "name": "exports", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "exports_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "start_date": { + "name": "start_date", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "end_date": { + "name": "end_date", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "valid_until": { + "name": "valid_until", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'datev'" + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_path": { + "name": "file_path", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "exports_tenant_id_tenants_id_fk": { + "name": "exports_tenant_id_tenants_id_fk", + "tableFrom": "exports", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.globalmessages": { + "name": "globalmessages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "globalmessages_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.globalmessagesseen": { + "name": "globalmessagesseen", + "schema": "", + "columns": { + "message": { + "name": "message", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "seen_at": { + "name": "seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "globalmessagesseen_message_globalmessages_id_fk": { + "name": "globalmessagesseen_message_globalmessages_id_fk", + "tableFrom": "globalmessagesseen", + "tableTo": "globalmessages", + "columnsFrom": [ + "message" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.helpdesk_channel_instances": { + "name": "helpdesk_channel_instances", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "type_id": { + "name": "type_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "config": { + "name": "config", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "public_config": { + "name": "public_config", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "public_token": { + "name": "public_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "secret_token": { + "name": "secret_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "helpdesk_channel_instances_tenant_id_tenants_id_fk": { + "name": "helpdesk_channel_instances_tenant_id_tenants_id_fk", + "tableFrom": "helpdesk_channel_instances", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "helpdesk_channel_instances_type_id_helpdesk_channel_types_id_fk": { + "name": "helpdesk_channel_instances_type_id_helpdesk_channel_types_id_fk", + "tableFrom": "helpdesk_channel_instances", + "tableTo": "helpdesk_channel_types", + "columnsFrom": [ + "type_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "helpdesk_channel_instances_created_by_auth_users_id_fk": { + "name": "helpdesk_channel_instances_created_by_auth_users_id_fk", + "tableFrom": "helpdesk_channel_instances", + "tableTo": "auth_users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "helpdesk_channel_instances_public_token_unique": { + "name": "helpdesk_channel_instances_public_token_unique", + "nullsNotDistinct": false, + "columns": [ + "public_token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.helpdesk_channel_types": { + "name": "helpdesk_channel_types", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.helpdesk_contacts": { + "name": "helpdesk_contacts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "customer_id": { + "name": "customer_id", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external_ref": { + "name": "external_ref", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "source_channel_id": { + "name": "source_channel_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "contact_id": { + "name": "contact_id", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "helpdesk_contacts_tenant_id_tenants_id_fk": { + "name": "helpdesk_contacts_tenant_id_tenants_id_fk", + "tableFrom": "helpdesk_contacts", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "helpdesk_contacts_customer_id_customers_id_fk": { + "name": "helpdesk_contacts_customer_id_customers_id_fk", + "tableFrom": "helpdesk_contacts", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "helpdesk_contacts_source_channel_id_helpdesk_channel_instances_id_fk": { + "name": "helpdesk_contacts_source_channel_id_helpdesk_channel_instances_id_fk", + "tableFrom": "helpdesk_contacts", + "tableTo": "helpdesk_channel_instances", + "columnsFrom": [ + "source_channel_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "helpdesk_contacts_contact_id_contacts_id_fk": { + "name": "helpdesk_contacts_contact_id_contacts_id_fk", + "tableFrom": "helpdesk_contacts", + "tableTo": "contacts", + "columnsFrom": [ + "contact_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.helpdesk_conversation_participants": { + "name": "helpdesk_conversation_participants", + "schema": "", + "columns": { + "conversation_id": { + "name": "conversation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "helpdesk_conversation_participants_conversation_id_helpdesk_conversations_id_fk": { + "name": "helpdesk_conversation_participants_conversation_id_helpdesk_conversations_id_fk", + "tableFrom": "helpdesk_conversation_participants", + "tableTo": "helpdesk_conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "helpdesk_conversation_participants_user_id_auth_users_id_fk": { + "name": "helpdesk_conversation_participants_user_id_auth_users_id_fk", + "tableFrom": "helpdesk_conversation_participants", + "tableTo": "auth_users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.helpdesk_conversations": { + "name": "helpdesk_conversations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "channel_instance_id": { + "name": "channel_instance_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "contact_id": { + "name": "contact_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'open'" + }, + "priority": { + "name": "priority", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'normal'" + }, + "assignee_user_id": { + "name": "assignee_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "last_message_at": { + "name": "last_message_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "customer_id": { + "name": "customer_id", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "contact_person_id": { + "name": "contact_person_id", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "ticket_number": { + "name": "ticket_number", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "helpdesk_conversations_tenant_id_tenants_id_fk": { + "name": "helpdesk_conversations_tenant_id_tenants_id_fk", + "tableFrom": "helpdesk_conversations", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "helpdesk_conversations_channel_instance_id_helpdesk_channel_instances_id_fk": { + "name": "helpdesk_conversations_channel_instance_id_helpdesk_channel_instances_id_fk", + "tableFrom": "helpdesk_conversations", + "tableTo": "helpdesk_channel_instances", + "columnsFrom": [ + "channel_instance_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "helpdesk_conversations_contact_id_helpdesk_contacts_id_fk": { + "name": "helpdesk_conversations_contact_id_helpdesk_contacts_id_fk", + "tableFrom": "helpdesk_conversations", + "tableTo": "helpdesk_contacts", + "columnsFrom": [ + "contact_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "helpdesk_conversations_assignee_user_id_auth_users_id_fk": { + "name": "helpdesk_conversations_assignee_user_id_auth_users_id_fk", + "tableFrom": "helpdesk_conversations", + "tableTo": "auth_users", + "columnsFrom": [ + "assignee_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "helpdesk_conversations_customer_id_customers_id_fk": { + "name": "helpdesk_conversations_customer_id_customers_id_fk", + "tableFrom": "helpdesk_conversations", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "helpdesk_conversations_contact_person_id_contacts_id_fk": { + "name": "helpdesk_conversations_contact_person_id_contacts_id_fk", + "tableFrom": "helpdesk_conversations", + "tableTo": "contacts", + "columnsFrom": [ + "contact_person_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.helpdesk_messages": { + "name": "helpdesk_messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "conversation_id": { + "name": "conversation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "direction": { + "name": "direction", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "author_user_id": { + "name": "author_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "raw_meta": { + "name": "raw_meta", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "contact_id": { + "name": "contact_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "external_message_id": { + "name": "external_message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "received_at": { + "name": "received_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "helpdesk_messages_tenant_id_tenants_id_fk": { + "name": "helpdesk_messages_tenant_id_tenants_id_fk", + "tableFrom": "helpdesk_messages", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "helpdesk_messages_conversation_id_helpdesk_conversations_id_fk": { + "name": "helpdesk_messages_conversation_id_helpdesk_conversations_id_fk", + "tableFrom": "helpdesk_messages", + "tableTo": "helpdesk_conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "helpdesk_messages_author_user_id_auth_users_id_fk": { + "name": "helpdesk_messages_author_user_id_auth_users_id_fk", + "tableFrom": "helpdesk_messages", + "tableTo": "auth_users", + "columnsFrom": [ + "author_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "helpdesk_messages_contact_id_helpdesk_contacts_id_fk": { + "name": "helpdesk_messages_contact_id_helpdesk_contacts_id_fk", + "tableFrom": "helpdesk_messages", + "tableTo": "helpdesk_contacts", + "columnsFrom": [ + "contact_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "helpdesk_messages_external_message_id_unique": { + "name": "helpdesk_messages_external_message_id_unique", + "nullsNotDistinct": false, + "columns": [ + "external_message_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.helpdesk_routing_rules": { + "name": "helpdesk_routing_rules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "condition": { + "name": "condition", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "action": { + "name": "action", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "helpdesk_routing_rules_tenant_id_tenants_id_fk": { + "name": "helpdesk_routing_rules_tenant_id_tenants_id_fk", + "tableFrom": "helpdesk_routing_rules", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "helpdesk_routing_rules_created_by_auth_users_id_fk": { + "name": "helpdesk_routing_rules_created_by_auth_users_id_fk", + "tableFrom": "helpdesk_routing_rules", + "tableTo": "auth_users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.historyitems": { + "name": "historyitems", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "historyitems_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "customer": { + "name": "customer", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "vendor": { + "name": "vendor", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "project": { + "name": "project", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "plant": { + "name": "plant", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "incomingInvoice": { + "name": "incomingInvoice", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "contact": { + "name": "contact", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "inventoryitem": { + "name": "inventoryitem", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "product": { + "name": "product", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "event": { + "name": "event", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "newVal": { + "name": "newVal", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "oldVal": { + "name": "oldVal", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "task": { + "name": "task", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "vehicle": { + "name": "vehicle", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "bankstatement": { + "name": "bankstatement", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "space": { + "name": "space", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "config": { + "name": "config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "projecttype": { + "name": "projecttype", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "check": { + "name": "check", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "service": { + "name": "service", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "createddocument": { + "name": "createddocument", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "file": { + "name": "file", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "inventoryitemgroup": { + "name": "inventoryitemgroup", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'Software'" + }, + "costcentre": { + "name": "costcentre", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "ownaccount": { + "name": "ownaccount", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "documentbox": { + "name": "documentbox", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "hourrate": { + "name": "hourrate", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "historyitems_customer_customers_id_fk": { + "name": "historyitems_customer_customers_id_fk", + "tableFrom": "historyitems", + "tableTo": "customers", + "columnsFrom": [ + "customer" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "historyitems_tenant_tenants_id_fk": { + "name": "historyitems_tenant_tenants_id_fk", + "tableFrom": "historyitems", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_vendor_vendors_id_fk": { + "name": "historyitems_vendor_vendors_id_fk", + "tableFrom": "historyitems", + "tableTo": "vendors", + "columnsFrom": [ + "vendor" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_project_projects_id_fk": { + "name": "historyitems_project_projects_id_fk", + "tableFrom": "historyitems", + "tableTo": "projects", + "columnsFrom": [ + "project" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "historyitems_plant_plants_id_fk": { + "name": "historyitems_plant_plants_id_fk", + "tableFrom": "historyitems", + "tableTo": "plants", + "columnsFrom": [ + "plant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "historyitems_incomingInvoice_incominginvoices_id_fk": { + "name": "historyitems_incomingInvoice_incominginvoices_id_fk", + "tableFrom": "historyitems", + "tableTo": "incominginvoices", + "columnsFrom": [ + "incomingInvoice" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "historyitems_contact_contacts_id_fk": { + "name": "historyitems_contact_contacts_id_fk", + "tableFrom": "historyitems", + "tableTo": "contacts", + "columnsFrom": [ + "contact" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "historyitems_inventoryitem_inventoryitems_id_fk": { + "name": "historyitems_inventoryitem_inventoryitems_id_fk", + "tableFrom": "historyitems", + "tableTo": "inventoryitems", + "columnsFrom": [ + "inventoryitem" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "historyitems_product_products_id_fk": { + "name": "historyitems_product_products_id_fk", + "tableFrom": "historyitems", + "tableTo": "products", + "columnsFrom": [ + "product" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "historyitems_event_events_id_fk": { + "name": "historyitems_event_events_id_fk", + "tableFrom": "historyitems", + "tableTo": "events", + "columnsFrom": [ + "event" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_task_tasks_id_fk": { + "name": "historyitems_task_tasks_id_fk", + "tableFrom": "historyitems", + "tableTo": "tasks", + "columnsFrom": [ + "task" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_vehicle_vehicles_id_fk": { + "name": "historyitems_vehicle_vehicles_id_fk", + "tableFrom": "historyitems", + "tableTo": "vehicles", + "columnsFrom": [ + "vehicle" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_bankstatement_bankstatements_id_fk": { + "name": "historyitems_bankstatement_bankstatements_id_fk", + "tableFrom": "historyitems", + "tableTo": "bankstatements", + "columnsFrom": [ + "bankstatement" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_space_spaces_id_fk": { + "name": "historyitems_space_spaces_id_fk", + "tableFrom": "historyitems", + "tableTo": "spaces", + "columnsFrom": [ + "space" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_projecttype_projecttypes_id_fk": { + "name": "historyitems_projecttype_projecttypes_id_fk", + "tableFrom": "historyitems", + "tableTo": "projecttypes", + "columnsFrom": [ + "projecttype" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_check_checks_id_fk": { + "name": "historyitems_check_checks_id_fk", + "tableFrom": "historyitems", + "tableTo": "checks", + "columnsFrom": [ + "check" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_service_services_id_fk": { + "name": "historyitems_service_services_id_fk", + "tableFrom": "historyitems", + "tableTo": "services", + "columnsFrom": [ + "service" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_createddocument_createddocuments_id_fk": { + "name": "historyitems_createddocument_createddocuments_id_fk", + "tableFrom": "historyitems", + "tableTo": "createddocuments", + "columnsFrom": [ + "createddocument" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_file_files_id_fk": { + "name": "historyitems_file_files_id_fk", + "tableFrom": "historyitems", + "tableTo": "files", + "columnsFrom": [ + "file" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_inventoryitemgroup_inventoryitemgroups_id_fk": { + "name": "historyitems_inventoryitemgroup_inventoryitemgroups_id_fk", + "tableFrom": "historyitems", + "tableTo": "inventoryitemgroups", + "columnsFrom": [ + "inventoryitemgroup" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_costcentre_costcentres_id_fk": { + "name": "historyitems_costcentre_costcentres_id_fk", + "tableFrom": "historyitems", + "tableTo": "costcentres", + "columnsFrom": [ + "costcentre" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_ownaccount_ownaccounts_id_fk": { + "name": "historyitems_ownaccount_ownaccounts_id_fk", + "tableFrom": "historyitems", + "tableTo": "ownaccounts", + "columnsFrom": [ + "ownaccount" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_documentbox_documentboxes_id_fk": { + "name": "historyitems_documentbox_documentboxes_id_fk", + "tableFrom": "historyitems", + "tableTo": "documentboxes", + "columnsFrom": [ + "documentbox" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_hourrate_hourrates_id_fk": { + "name": "historyitems_hourrate_hourrates_id_fk", + "tableFrom": "historyitems", + "tableTo": "hourrates", + "columnsFrom": [ + "hourrate" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "historyitems_created_by_auth_users_id_fk": { + "name": "historyitems_created_by_auth_users_id_fk", + "tableFrom": "historyitems", + "tableTo": "auth_users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.holidays": { + "name": "holidays", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "holidays_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "state_code": { + "name": "state_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hourrates": { + "name": "hourrates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "purchasePrice": { + "name": "purchasePrice", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "sellingPrice": { + "name": "sellingPrice", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "hourrates_tenant_tenants_id_fk": { + "name": "hourrates_tenant_tenants_id_fk", + "tableFrom": "hourrates", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "hourrates_updated_by_auth_users_id_fk": { + "name": "hourrates_updated_by_auth_users_id_fk", + "tableFrom": "hourrates", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.incominginvoices": { + "name": "incominginvoices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "incominginvoices_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'Entwurf'" + }, + "vendor": { + "name": "vendor", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "reference": { + "name": "reference", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "date": { + "name": "date", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "document": { + "name": "document", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "dueDate": { + "name": "dueDate", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "paymentType": { + "name": "paymentType", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "accounts": { + "name": "accounts", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[{\"account\":null,\"taxType\":null,\"amountNet\":null,\"amountTax\":19,\"costCentre\":null}]'::jsonb" + }, + "paid": { + "name": "paid", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "expense": { + "name": "expense", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "incominginvoices_tenant_tenants_id_fk": { + "name": "incominginvoices_tenant_tenants_id_fk", + "tableFrom": "incominginvoices", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "incominginvoices_vendor_vendors_id_fk": { + "name": "incominginvoices_vendor_vendors_id_fk", + "tableFrom": "incominginvoices", + "tableTo": "vendors", + "columnsFrom": [ + "vendor" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "incominginvoices_updated_by_auth_users_id_fk": { + "name": "incominginvoices_updated_by_auth_users_id_fk", + "tableFrom": "incominginvoices", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.inventoryitemgroups": { + "name": "inventoryitemgroups", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "inventoryitems": { + "name": "inventoryitems", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "profiles": { + "name": "profiles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "usePlanning": { + "name": "usePlanning", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "inventoryitemgroups_tenant_tenants_id_fk": { + "name": "inventoryitemgroups_tenant_tenants_id_fk", + "tableFrom": "inventoryitemgroups", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "inventoryitemgroups_updated_by_auth_users_id_fk": { + "name": "inventoryitemgroups_updated_by_auth_users_id_fk", + "tableFrom": "inventoryitemgroups", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.inventoryitems": { + "name": "inventoryitems", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "inventoryitems_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "usePlanning": { + "name": "usePlanning", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "currentSpace": { + "name": "currentSpace", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "articleNumber": { + "name": "articleNumber", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "serialNumber": { + "name": "serialNumber", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "purchaseDate": { + "name": "purchaseDate", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "vendor": { + "name": "vendor", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "quantity": { + "name": "quantity", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "purchasePrice": { + "name": "purchasePrice", + "type": "double precision", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "manufacturer": { + "name": "manufacturer", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "manufacturerNumber": { + "name": "manufacturerNumber", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "currentValue": { + "name": "currentValue", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "profiles": { + "name": "profiles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "inventoryitems_tenant_tenants_id_fk": { + "name": "inventoryitems_tenant_tenants_id_fk", + "tableFrom": "inventoryitems", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "inventoryitems_currentSpace_spaces_id_fk": { + "name": "inventoryitems_currentSpace_spaces_id_fk", + "tableFrom": "inventoryitems", + "tableTo": "spaces", + "columnsFrom": [ + "currentSpace" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "inventoryitems_vendor_vendors_id_fk": { + "name": "inventoryitems_vendor_vendors_id_fk", + "tableFrom": "inventoryitems", + "tableTo": "vendors", + "columnsFrom": [ + "vendor" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "inventoryitems_updated_by_auth_users_id_fk": { + "name": "inventoryitems_updated_by_auth_users_id_fk", + "tableFrom": "inventoryitems", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.letterheads": { + "name": "letterheads", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "letterheads_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'Standard'" + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "documentTypes": { + "name": "documentTypes", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "letterheads_tenant_tenants_id_fk": { + "name": "letterheads_tenant_tenants_id_fk", + "tableFrom": "letterheads", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "letterheads_updated_by_auth_users_id_fk": { + "name": "letterheads_updated_by_auth_users_id_fk", + "tableFrom": "letterheads", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.movements": { + "name": "movements", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "movements_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "quantity": { + "name": "quantity", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "productId": { + "name": "productId", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "spaceId": { + "name": "spaceId", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "projectId": { + "name": "projectId", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "serials": { + "name": "serials", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "movements_productId_products_id_fk": { + "name": "movements_productId_products_id_fk", + "tableFrom": "movements", + "tableTo": "products", + "columnsFrom": [ + "productId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "movements_spaceId_spaces_id_fk": { + "name": "movements_spaceId_spaces_id_fk", + "tableFrom": "movements", + "tableTo": "spaces", + "columnsFrom": [ + "spaceId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "movements_tenant_tenants_id_fk": { + "name": "movements_tenant_tenants_id_fk", + "tableFrom": "movements", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "movements_projectId_projects_id_fk": { + "name": "movements_projectId_projects_id_fk", + "tableFrom": "movements", + "tableTo": "projects", + "columnsFrom": [ + "projectId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "movements_updated_by_auth_users_id_fk": { + "name": "movements_updated_by_auth_users_id_fk", + "tableFrom": "movements", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notifications_event_types": { + "name": "notifications_event_types", + "schema": "", + "columns": { + "event_key": { + "name": "event_key", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "severity": { + "name": "severity", + "type": "notification_severity", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'info'" + }, + "allowed_channels": { + "name": "allowed_channels", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[\"inapp\",\"email\"]'::jsonb" + }, + "payload_schema": { + "name": "payload_schema", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notifications_items": { + "name": "notifications_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "channel": { + "name": "channel", + "type": "notification_channel", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "notification_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'queued'" + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "read_at": { + "name": "read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_items_tenant_id_tenants_id_fk": { + "name": "notifications_items_tenant_id_tenants_id_fk", + "tableFrom": "notifications_items", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "notifications_items_user_id_auth_users_id_fk": { + "name": "notifications_items_user_id_auth_users_id_fk", + "tableFrom": "notifications_items", + "tableTo": "auth_users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "notifications_items_event_type_notifications_event_types_event_key_fk": { + "name": "notifications_items_event_type_notifications_event_types_event_key_fk", + "tableFrom": "notifications_items", + "tableTo": "notifications_event_types", + "columnsFrom": [ + "event_type" + ], + "columnsTo": [ + "event_key" + ], + "onDelete": "restrict", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notifications_preferences": { + "name": "notifications_preferences", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "notification_channel", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "notifications_preferences_tenant_id_user_id_event_type_chan_key": { + "name": "notifications_preferences_tenant_id_user_id_event_type_chan_key", + "columns": [ + { + "expression": "tenant_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "event_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "channel", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notifications_preferences_tenant_id_tenants_id_fk": { + "name": "notifications_preferences_tenant_id_tenants_id_fk", + "tableFrom": "notifications_preferences", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "notifications_preferences_user_id_auth_users_id_fk": { + "name": "notifications_preferences_user_id_auth_users_id_fk", + "tableFrom": "notifications_preferences", + "tableTo": "auth_users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "notifications_preferences_event_type_notifications_event_types_event_key_fk": { + "name": "notifications_preferences_event_type_notifications_event_types_event_key_fk", + "tableFrom": "notifications_preferences", + "tableTo": "notifications_event_types", + "columnsFrom": [ + "event_type" + ], + "columnsTo": [ + "event_key" + ], + "onDelete": "restrict", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notifications_preferences_defaults": { + "name": "notifications_preferences_defaults", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "event_key": { + "name": "event_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "notification_channel", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "notifications_preferences_defau_tenant_id_event_key_channel_key": { + "name": "notifications_preferences_defau_tenant_id_event_key_channel_key", + "columns": [ + { + "expression": "tenant_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "event_key", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "channel", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notifications_preferences_defaults_tenant_id_tenants_id_fk": { + "name": "notifications_preferences_defaults_tenant_id_tenants_id_fk", + "tableFrom": "notifications_preferences_defaults", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "notifications_preferences_defaults_event_key_notifications_event_types_event_key_fk": { + "name": "notifications_preferences_defaults_event_key_notifications_event_types_event_key_fk", + "tableFrom": "notifications_preferences_defaults", + "tableTo": "notifications_event_types", + "columnsFrom": [ + "event_key" + ], + "columnsTo": [ + "event_key" + ], + "onDelete": "restrict", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ownaccounts": { + "name": "ownaccounts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "profiles": { + "name": "profiles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "ownaccounts_tenant_tenants_id_fk": { + "name": "ownaccounts_tenant_tenants_id_fk", + "tableFrom": "ownaccounts", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "ownaccounts_updated_by_auth_users_id_fk": { + "name": "ownaccounts_updated_by_auth_users_id_fk", + "tableFrom": "ownaccounts", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.plants": { + "name": "plants", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "plants_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "customer": { + "name": "customer", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "infoData": { + "name": "infoData", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "contract": { + "name": "contract", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{\"html\":\"\",\"json\":[],\"text\":\"\"}'::jsonb" + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "profiles": { + "name": "profiles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "plants_tenant_tenants_id_fk": { + "name": "plants_tenant_tenants_id_fk", + "tableFrom": "plants", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "plants_customer_customers_id_fk": { + "name": "plants_customer_customers_id_fk", + "tableFrom": "plants", + "tableTo": "customers", + "columnsFrom": [ + "customer" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "plants_contract_contracts_id_fk": { + "name": "plants_contract_contracts_id_fk", + "tableFrom": "plants", + "tableTo": "contracts", + "columnsFrom": [ + "contract" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "plants_updated_by_auth_users_id_fk": { + "name": "plants_updated_by_auth_users_id_fk", + "tableFrom": "plants", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.productcategories": { + "name": "productcategories", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "productcategories_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "productcategories_tenant_tenants_id_fk": { + "name": "productcategories_tenant_tenants_id_fk", + "tableFrom": "productcategories", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "productcategories_updated_by_auth_users_id_fk": { + "name": "productcategories_updated_by_auth_users_id_fk", + "tableFrom": "productcategories", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.products": { + "name": "products", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "products_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "manufacturer": { + "name": "manufacturer", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "unit": { + "name": "unit", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "tags": { + "name": "tags", + "type": "json", + "primaryKey": false, + "notNull": true, + "default": "'[]'::json" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "ean": { + "name": "ean", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "barcode": { + "name": "barcode", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "purchasePrice": { + "name": "purchasePrice", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "sellingPrice": { + "name": "sellingPrice", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "manufacturerNumber": { + "name": "manufacturerNumber", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vendorAllocation": { + "name": "vendorAllocation", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "articleNumber": { + "name": "articleNumber", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "barcodes": { + "name": "barcodes", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "productcategories": { + "name": "productcategories", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "taxPercentage": { + "name": "taxPercentage", + "type": "smallint", + "primaryKey": false, + "notNull": true, + "default": 19 + }, + "markupPercentage": { + "name": "markupPercentage", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "products_unit_units_id_fk": { + "name": "products_unit_units_id_fk", + "tableFrom": "products", + "tableTo": "units", + "columnsFrom": [ + "unit" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "products_tenant_tenants_id_fk": { + "name": "products_tenant_tenants_id_fk", + "tableFrom": "products", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "products_updated_by_auth_users_id_fk": { + "name": "products_updated_by_auth_users_id_fk", + "tableFrom": "products", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.projects": { + "name": "projects", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "projects_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "customer": { + "name": "customer", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "phases": { + "name": "phases", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "description": { + "name": "description", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "forms": { + "name": "forms", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "heroId": { + "name": "heroId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "measure": { + "name": "measure", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "material": { + "name": "material", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "plant": { + "name": "plant", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "profiles": { + "name": "profiles", + "type": "uuid[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "projectNumber": { + "name": "projectNumber", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contract": { + "name": "contract", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "projectType": { + "name": "projectType", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'Projekt'" + }, + "projecttype": { + "name": "projecttype", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "customerRef": { + "name": "customerRef", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "active_phase": { + "name": "active_phase", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "projects_tenant_tenants_id_fk": { + "name": "projects_tenant_tenants_id_fk", + "tableFrom": "projects", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "projects_customer_customers_id_fk": { + "name": "projects_customer_customers_id_fk", + "tableFrom": "projects", + "tableTo": "customers", + "columnsFrom": [ + "customer" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "projects_contract_contracts_id_fk": { + "name": "projects_contract_contracts_id_fk", + "tableFrom": "projects", + "tableTo": "contracts", + "columnsFrom": [ + "contract" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "projects_projecttype_projecttypes_id_fk": { + "name": "projects_projecttype_projecttypes_id_fk", + "tableFrom": "projects", + "tableTo": "projecttypes", + "columnsFrom": [ + "projecttype" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "projects_updated_by_auth_users_id_fk": { + "name": "projects_updated_by_auth_users_id_fk", + "tableFrom": "projects", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.projecttypes": { + "name": "projecttypes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "projecttypes_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "initialPhases": { + "name": "initialPhases", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "addablePhases": { + "name": "addablePhases", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "projecttypes_tenant_tenants_id_fk": { + "name": "projecttypes_tenant_tenants_id_fk", + "tableFrom": "projecttypes", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "projecttypes_updated_by_auth_users_id_fk": { + "name": "projecttypes_updated_by_auth_users_id_fk", + "tableFrom": "projecttypes", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.servicecategories": { + "name": "servicecategories", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "servicecategories_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "discount": { + "name": "discount", + "type": "double precision", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "servicecategories_tenant_tenants_id_fk": { + "name": "servicecategories_tenant_tenants_id_fk", + "tableFrom": "servicecategories", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "servicecategories_updated_by_auth_users_id_fk": { + "name": "servicecategories_updated_by_auth_users_id_fk", + "tableFrom": "servicecategories", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.services": { + "name": "services", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "services_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sellingPrice": { + "name": "sellingPrice", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "unit": { + "name": "unit", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "serviceNumber": { + "name": "serviceNumber", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "servicecategories": { + "name": "servicecategories", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "purchasePriceComposed": { + "name": "purchasePriceComposed", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{\"total\":0}'::jsonb" + }, + "sellingPriceComposed": { + "name": "sellingPriceComposed", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{\"total\":0}'::jsonb" + }, + "taxPercentage": { + "name": "taxPercentage", + "type": "smallint", + "primaryKey": false, + "notNull": true, + "default": 19 + }, + "materialComposition": { + "name": "materialComposition", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "personalComposition": { + "name": "personalComposition", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "services_tenant_tenants_id_fk": { + "name": "services_tenant_tenants_id_fk", + "tableFrom": "services", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "services_unit_units_id_fk": { + "name": "services_unit_units_id_fk", + "tableFrom": "services", + "tableTo": "units", + "columnsFrom": [ + "unit" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "services_updated_by_auth_users_id_fk": { + "name": "services_updated_by_auth_users_id_fk", + "tableFrom": "services", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.spaces": { + "name": "spaces", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "spaces_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "spaceNumber": { + "name": "spaceNumber", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "parentSpace": { + "name": "parentSpace", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "infoData": { + "name": "infoData", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{\"zip\":\"\",\"city\":\"\",\"streetNumber\":\"\"}'::jsonb" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "spaces_tenant_tenants_id_fk": { + "name": "spaces_tenant_tenants_id_fk", + "tableFrom": "spaces", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "spaces_parentSpace_spaces_id_fk": { + "name": "spaces_parentSpace_spaces_id_fk", + "tableFrom": "spaces", + "tableTo": "spaces", + "columnsFrom": [ + "parentSpace" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "spaces_updated_by_auth_users_id_fk": { + "name": "spaces_updated_by_auth_users_id_fk", + "tableFrom": "spaces", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.staff_time_entries": { + "name": "staff_time_entries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "stopped_at": { + "name": "stopped_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "duration_minutes": { + "name": "duration_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "generated": { + "as": "CASE \n WHEN stopped_at IS NOT NULL \n THEN (EXTRACT(epoch FROM (stopped_at - started_at)) / 60)\n ELSE NULL\n END", + "type": "stored" + } + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'work'" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "times_state", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "device": { + "name": "device", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "internal_note": { + "name": "internal_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vacation_reason": { + "name": "vacation_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vacation_days": { + "name": "vacation_days", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "approved_by": { + "name": "approved_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "approved_at": { + "name": "approved_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "sick_reason": { + "name": "sick_reason", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "staff_time_entries_tenant_id_tenants_id_fk": { + "name": "staff_time_entries_tenant_id_tenants_id_fk", + "tableFrom": "staff_time_entries", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "staff_time_entries_user_id_auth_users_id_fk": { + "name": "staff_time_entries_user_id_auth_users_id_fk", + "tableFrom": "staff_time_entries", + "tableTo": "auth_users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "staff_time_entries_updated_by_auth_users_id_fk": { + "name": "staff_time_entries_updated_by_auth_users_id_fk", + "tableFrom": "staff_time_entries", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "staff_time_entries_approved_by_auth_users_id_fk": { + "name": "staff_time_entries_approved_by_auth_users_id_fk", + "tableFrom": "staff_time_entries", + "tableTo": "auth_users", + "columnsFrom": [ + "approved_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.staff_time_entry_connects": { + "name": "staff_time_entry_connects", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "time_entry_id": { + "name": "time_entry_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "stopped_at": { + "name": "stopped_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "duration_minutes": { + "name": "duration_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "generated": { + "as": "(EXTRACT(epoch FROM (stopped_at - started_at)) / 60)", + "type": "stored" + } + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "staff_time_entry_connects_time_entry_id_staff_time_entries_id_fk": { + "name": "staff_time_entry_connects_time_entry_id_staff_time_entries_id_fk", + "tableFrom": "staff_time_entry_connects", + "tableTo": "staff_time_entries", + "columnsFrom": [ + "time_entry_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.staff_zeitstromtimestamps": { + "name": "staff_zeitstromtimestamps", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "profile": { + "name": "profile", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "intent": { + "name": "intent", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "time": { + "name": "time", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "staff_time_entry": { + "name": "staff_time_entry", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "internal_note": { + "name": "internal_note", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "staff_zeitstromtimestamps_tenant_tenants_id_fk": { + "name": "staff_zeitstromtimestamps_tenant_tenants_id_fk", + "tableFrom": "staff_zeitstromtimestamps", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "staff_zeitstromtimestamps_profile_auth_profiles_id_fk": { + "name": "staff_zeitstromtimestamps_profile_auth_profiles_id_fk", + "tableFrom": "staff_zeitstromtimestamps", + "tableTo": "auth_profiles", + "columnsFrom": [ + "profile" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "staff_zeitstromtimestamps_staff_time_entry_staff_time_entries_id_fk": { + "name": "staff_zeitstromtimestamps_staff_time_entry_staff_time_entries_id_fk", + "tableFrom": "staff_zeitstromtimestamps", + "tableTo": "staff_time_entries", + "columnsFrom": [ + "staff_time_entry" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.statementallocations": { + "name": "statementallocations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "bs_id": { + "name": "bs_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "cd_id": { + "name": "cd_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "amount": { + "name": "amount", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "ii_id": { + "name": "ii_id", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "account": { + "name": "account", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "ownaccount": { + "name": "ownaccount", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "customer": { + "name": "customer", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "vendor": { + "name": "vendor", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "statementallocations_bs_id_bankstatements_id_fk": { + "name": "statementallocations_bs_id_bankstatements_id_fk", + "tableFrom": "statementallocations", + "tableTo": "bankstatements", + "columnsFrom": [ + "bs_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "statementallocations_cd_id_createddocuments_id_fk": { + "name": "statementallocations_cd_id_createddocuments_id_fk", + "tableFrom": "statementallocations", + "tableTo": "createddocuments", + "columnsFrom": [ + "cd_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "statementallocations_ii_id_incominginvoices_id_fk": { + "name": "statementallocations_ii_id_incominginvoices_id_fk", + "tableFrom": "statementallocations", + "tableTo": "incominginvoices", + "columnsFrom": [ + "ii_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "statementallocations_tenant_tenants_id_fk": { + "name": "statementallocations_tenant_tenants_id_fk", + "tableFrom": "statementallocations", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "statementallocations_account_accounts_id_fk": { + "name": "statementallocations_account_accounts_id_fk", + "tableFrom": "statementallocations", + "tableTo": "accounts", + "columnsFrom": [ + "account" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "statementallocations_ownaccount_ownaccounts_id_fk": { + "name": "statementallocations_ownaccount_ownaccounts_id_fk", + "tableFrom": "statementallocations", + "tableTo": "ownaccounts", + "columnsFrom": [ + "ownaccount" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "statementallocations_customer_customers_id_fk": { + "name": "statementallocations_customer_customers_id_fk", + "tableFrom": "statementallocations", + "tableTo": "customers", + "columnsFrom": [ + "customer" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "statementallocations_vendor_vendors_id_fk": { + "name": "statementallocations_vendor_vendors_id_fk", + "tableFrom": "statementallocations", + "tableTo": "vendors", + "columnsFrom": [ + "vendor" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "statementallocations_updated_by_auth_users_id_fk": { + "name": "statementallocations_updated_by_auth_users_id_fk", + "tableFrom": "statementallocations", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tasks": { + "name": "tasks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "tasks_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "categorie": { + "name": "categorie", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "project": { + "name": "project", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "plant": { + "name": "plant", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "customer": { + "name": "customer", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "profiles": { + "name": "profiles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "tasks_tenant_tenants_id_fk": { + "name": "tasks_tenant_tenants_id_fk", + "tableFrom": "tasks", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "tasks_user_id_auth_users_id_fk": { + "name": "tasks_user_id_auth_users_id_fk", + "tableFrom": "tasks", + "tableTo": "auth_users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "tasks_customer_customers_id_fk": { + "name": "tasks_customer_customers_id_fk", + "tableFrom": "tasks", + "tableTo": "customers", + "columnsFrom": [ + "customer" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "tasks_updated_by_auth_users_id_fk": { + "name": "tasks_updated_by_auth_users_id_fk", + "tableFrom": "tasks", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.taxtypes": { + "name": "taxtypes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "taxtypes_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "percentage": { + "name": "percentage", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "taxtypes_updated_by_auth_users_id_fk": { + "name": "taxtypes_updated_by_auth_users_id_fk", + "tableFrom": "taxtypes", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tenants": { + "name": "tenants", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "tenants_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "short": { + "name": "short", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "calendarConfig": { + "name": "calendarConfig", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{\"eventTypes\":[{\"color\":\"blue\",\"label\":\"Büro\"},{\"color\":\"yellow\",\"label\":\"Besprechung\"},{\"color\":\"green\",\"label\":\"Umsetzung\"},{\"color\":\"red\",\"label\":\"Vor Ort Termin\"}]}'::jsonb" + }, + "timeConfig": { + "name": "timeConfig", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{\"products\":[],\"documents\":[]}'::jsonb" + }, + "measures": { + "name": "measures", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[{\"name\":\"Netzwerktechnik\",\"short\":\"NWT\"},{\"name\":\"Elektrotechnik\",\"short\":\"ELT\"},{\"name\":\"Photovoltaik\",\"short\":\"PV\"},{\"name\":\"Videüberwachung\",\"short\":\"VÜA\"},{\"name\":\"Projekt\",\"short\":\"PRJ\"},{\"name\":\"Smart Home\",\"short\":\"SHO\"}]'::jsonb" + }, + "businessInfo": { + "name": "businessInfo", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{\"zip\":\"\",\"city\":\"\",\"name\":\"\",\"street\":\"\"}'::jsonb" + }, + "features": { + "name": "features", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{\"objects\":true,\"calendar\":true,\"contacts\":true,\"projects\":true,\"vehicles\":true,\"contracts\":true,\"inventory\":true,\"accounting\":true,\"timeTracking\":true,\"planningBoard\":true,\"workingTimeTracking\":true}'::jsonb" + }, + "ownFields": { + "name": "ownFields", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "numberRanges": { + "name": "numberRanges", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{\"vendors\":{\"prefix\":\"\",\"suffix\":\"\",\"nextNumber\":10000},\"customers\":{\"prefix\":\"\",\"suffix\":\"\",\"nextNumber\":10000},\"products\":{\"prefix\":\"AT-\",\"suffix\":\"\",\"nextNumber\":1000},\"quotes\":{\"prefix\":\"AN-\",\"suffix\":\"\",\"nextNumber\":1000},\"confirmationOrders\":{\"prefix\":\"AB-\",\"suffix\":\"\",\"nextNumber\":1000},\"invoices\":{\"prefix\":\"RE-\",\"suffix\":\"\",\"nextNumber\":1000},\"spaces\":{\"prefix\":\"LP-\",\"suffix\":\"\",\"nextNumber\":1000},\"inventoryitems\":{\"prefix\":\"IA-\",\"suffix\":\"\",\"nextNumber\":1000},\"projects\":{\"prefix\":\"PRJ-\",\"suffix\":\"\",\"nextNumber\":1000},\"costcentres\":{\"prefix\":\"KST-\",\"suffix\":\"\",\"nextNumber\":1000}}'::jsonb" + }, + "standardEmailForInvoices": { + "name": "standardEmailForInvoices", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "extraModules": { + "name": "extraModules", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "isInTrial": { + "name": "isInTrial", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "trialEndDate": { + "name": "trialEndDate", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "stripeCustomerId": { + "name": "stripeCustomerId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "hasActiveLicense": { + "name": "hasActiveLicense", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "userLicenseCount": { + "name": "userLicenseCount", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "workstationLicenseCount": { + "name": "workstationLicenseCount", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "standardPaymentDays": { + "name": "standardPaymentDays", + "type": "smallint", + "primaryKey": false, + "notNull": true, + "default": 14 + }, + "dokuboxEmailAddresses": { + "name": "dokuboxEmailAddresses", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "dokuboxkey": { + "name": "dokuboxkey", + "type": "uuid", + "primaryKey": false, + "notNull": true, + "default": "gen_random_uuid()" + }, + "autoPrepareIncomingInvoices": { + "name": "autoPrepareIncomingInvoices", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "portalDomain": { + "name": "portalDomain", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "portalConfig": { + "name": "portalConfig", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{\"primayColor\":\"#69c350\"}'::jsonb" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "locked": { + "name": "locked", + "type": "locked_tenant", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "tenants_updated_by_auth_users_id_fk": { + "name": "tenants_updated_by_auth_users_id_fk", + "tableFrom": "tenants", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.texttemplates": { + "name": "texttemplates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "texttemplates_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "documentType": { + "name": "documentType", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "''" + }, + "default": { + "name": "default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "pos": { + "name": "pos", + "type": "texttemplatepositions", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "texttemplates_tenant_tenants_id_fk": { + "name": "texttemplates_tenant_tenants_id_fk", + "tableFrom": "texttemplates", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "texttemplates_updated_by_auth_users_id_fk": { + "name": "texttemplates_updated_by_auth_users_id_fk", + "tableFrom": "texttemplates", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.units": { + "name": "units", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "units_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "single": { + "name": "single", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "multiple": { + "name": "multiple", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "short": { + "name": "short", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "step": { + "name": "step", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'1'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_credentials": { + "name": "user_credentials", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "smtp_port": { + "name": "smtp_port", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "smtp_ssl": { + "name": "smtp_ssl", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "credential_types", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "imap_port": { + "name": "imap_port", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "imap_ssl": { + "name": "imap_ssl", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "email_encrypted": { + "name": "email_encrypted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "password_encrypted": { + "name": "password_encrypted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "smtp_host_encrypted": { + "name": "smtp_host_encrypted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "imap_host_encrypted": { + "name": "imap_host_encrypted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "access_token_encrypted": { + "name": "access_token_encrypted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "refresh_token_encrypted": { + "name": "refresh_token_encrypted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "user_credentials_user_id_auth_users_id_fk": { + "name": "user_credentials_user_id_auth_users_id_fk", + "tableFrom": "user_credentials", + "tableTo": "auth_users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "user_credentials_tenant_id_tenants_id_fk": { + "name": "user_credentials_tenant_id_tenants_id_fk", + "tableFrom": "user_credentials", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.vehicles": { + "name": "vehicles", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "vehicles_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "licensePlate": { + "name": "licensePlate", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "driver": { + "name": "driver", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "vin": { + "name": "vin", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tankSize": { + "name": "tankSize", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "buildYear": { + "name": "buildYear", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "towingCapacity": { + "name": "towingCapacity", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "powerInKW": { + "name": "powerInKW", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "profiles": { + "name": "profiles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "vehicles_tenant_tenants_id_fk": { + "name": "vehicles_tenant_tenants_id_fk", + "tableFrom": "vehicles", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "vehicles_driver_auth_users_id_fk": { + "name": "vehicles_driver_auth_users_id_fk", + "tableFrom": "vehicles", + "tableTo": "auth_users", + "columnsFrom": [ + "driver" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "vehicles_updated_by_auth_users_id_fk": { + "name": "vehicles_updated_by_auth_users_id_fk", + "tableFrom": "vehicles", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.vendors": { + "name": "vendors", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "vendors_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "vendorNumber": { + "name": "vendorNumber", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tenant": { + "name": "tenant", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "infoData": { + "name": "infoData", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "hasSEPA": { + "name": "hasSEPA", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "profiles": { + "name": "profiles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "defaultPaymentMethod": { + "name": "defaultPaymentMethod", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "vendors_tenant_tenants_id_fk": { + "name": "vendors_tenant_tenants_id_fk", + "tableFrom": "vendors", + "tableTo": "tenants", + "columnsFrom": [ + "tenant" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "vendors_updated_by_auth_users_id_fk": { + "name": "vendors_updated_by_auth_users_id_fk", + "tableFrom": "vendors", + "tableTo": "auth_users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.time_events": { + "name": "time_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "actor_type": { + "name": "actor_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_user_id": { + "name": "actor_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "event_time": { + "name": "event_time", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "invalidates_event_id": { + "name": "invalidates_event_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_time_events_tenant_user_time": { + "name": "idx_time_events_tenant_user_time", + "columns": [ + { + "expression": "tenant_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "event_time", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_time_events_created_at": { + "name": "idx_time_events_created_at", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_time_events_invalidates": { + "name": "idx_time_events_invalidates", + "columns": [ + { + "expression": "invalidates_event_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "time_events_tenant_id_tenants_id_fk": { + "name": "time_events_tenant_id_tenants_id_fk", + "tableFrom": "time_events", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "time_events_user_id_auth_users_id_fk": { + "name": "time_events_user_id_auth_users_id_fk", + "tableFrom": "time_events", + "tableTo": "auth_users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "time_events_actor_user_id_auth_users_id_fk": { + "name": "time_events_actor_user_id_auth_users_id_fk", + "tableFrom": "time_events", + "tableTo": "auth_users", + "columnsFrom": [ + "actor_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "time_events_invalidates_event_id_time_events_id_fk": { + "name": "time_events_invalidates_event_id_time_events_id_fk", + "tableFrom": "time_events", + "tableTo": "time_events", + "columnsFrom": [ + "invalidates_event_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "time_events_actor_user_check": { + "name": "time_events_actor_user_check", + "value": "\n (actor_type = 'system' AND actor_user_id IS NULL)\n OR\n (actor_type = 'user' AND actor_user_id IS NOT NULL)\n " + } + }, + "isRLSEnabled": false + } + }, + "enums": { + "public.credential_types": { + "name": "credential_types", + "schema": "public", + "values": [ + "mail", + "m365" + ] + }, + "public.folderfunctions": { + "name": "folderfunctions", + "schema": "public", + "values": [ + "none", + "yearSubCategory", + "incomingInvoices", + "invoices", + "quotes", + "confirmationOrders", + "deliveryNotes", + "vehicleData", + "reminders", + "taxData", + "deposit", + "timeEvaluations" + ] + }, + "public.locked_tenant": { + "name": "locked_tenant", + "schema": "public", + "values": [ + "maintenance_tenant", + "maintenance", + "general", + "no_subscription" + ] + }, + "public.notification_channel": { + "name": "notification_channel", + "schema": "public", + "values": [ + "email", + "inapp", + "sms", + "push", + "webhook" + ] + }, + "public.notification_severity": { + "name": "notification_severity", + "schema": "public", + "values": [ + "info", + "success", + "warning", + "error" + ] + }, + "public.notification_status": { + "name": "notification_status", + "schema": "public", + "values": [ + "queued", + "sent", + "failed", + "read" + ] + }, + "public.payment_types": { + "name": "payment_types", + "schema": "public", + "values": [ + "transfer", + "direct_debit" + ] + }, + "public.texttemplatepositions": { + "name": "texttemplatepositions", + "schema": "public", + "values": [ + "startText", + "endText" + ] + }, + "public.times_state": { + "name": "times_state", + "schema": "public", + "values": [ + "submitted", + "approved", + "draft" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/db/migrations/meta/_journal.json b/db/migrations/meta/_journal.json new file mode 100644 index 0000000..25a83ac --- /dev/null +++ b/db/migrations/meta/_journal.json @@ -0,0 +1,41 @@ +{ + "version": "7", + "dialect": "postgresql", + "entries": [ + { + "idx": 0, + "version": "7", + "when": 1764947303113, + "tag": "0000_brief_dark_beast", + "breakpoints": true + }, + { + "idx": 1, + "version": "7", + "when": 1765641431341, + "tag": "0001_medical_big_bertha", + "breakpoints": true + }, + { + "idx": 2, + "version": "7", + "when": 1765642446738, + "tag": "0002_silent_christian_walker", + "breakpoints": true + }, + { + "idx": 3, + "version": "7", + "when": 1765716484200, + "tag": "0003_woozy_adam_destine", + "breakpoints": true + }, + { + "idx": 4, + "version": "7", + "when": 1765716877146, + "tag": "0004_stormy_onslaught", + "breakpoints": true + } + ] +} \ No newline at end of file diff --git a/db/schema/accounts.ts b/db/schema/accounts.ts new file mode 100644 index 0000000..cc154de --- /dev/null +++ b/db/schema/accounts.ts @@ -0,0 +1,24 @@ +import { + pgTable, + bigint, + timestamp, + text, +} from "drizzle-orm/pg-core" + +export const accounts = pgTable("accounts", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + number: text("number").notNull(), + label: text("label").notNull(), + + description: text("description"), +}) + +export type Account = typeof accounts.$inferSelect +export type NewAccount = typeof accounts.$inferInsert diff --git a/db/schema/auth_profiles.ts b/db/schema/auth_profiles.ts new file mode 100644 index 0000000..85085e0 --- /dev/null +++ b/db/schema/auth_profiles.ts @@ -0,0 +1,83 @@ +import { + pgTable, + uuid, + text, + timestamp, + date, + boolean, + bigint, + doublePrecision, + jsonb, +} from "drizzle-orm/pg-core" +import { authUsers } from "./auth_users" + +export const authProfiles = pgTable("auth_profiles", { + id: uuid("id").primaryKey().defaultRandom(), + + user_id: uuid("user_id").references(() => authUsers.id), + + tenant_id: bigint("tenant_id", { mode: "number" }).notNull(), + + created_at: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + first_name: text("first_name").notNull(), + last_name: text("last_name").notNull(), + + full_name: text("full_name").generatedAlwaysAs( + `((first_name || ' ') || last_name)` + ), + + mobile_tel: text("mobile_tel"), + fixed_tel: text("fixed_tel"), + salutation: text("salutation"), + employee_number: text("employee_number"), + + weekly_working_hours: doublePrecision("weekly_working_hours").default(0), + annual_paid_leave_days: bigint("annual_paid_leave_days", { mode: "number" }), + + weekly_regular_working_hours: jsonb("weekly_regular_working_hours").default("{}"), + + clothing_size_top: text("clothing_size_top"), + clothing_size_bottom: text("clothing_size_bottom"), + clothing_size_shoe: text("clothing_size_shoe"), + + email_signature: text("email_signature").default("Mit freundlichen Grüßen
"), + + birthday: date("birthday"), + entry_date: date("entry_date").defaultNow(), + + automatic_hour_corrections: jsonb("automatic_hour_corrections").default("[]"), + + recreation_days_compensation: boolean("recreation_days_compensation") + .notNull() + .default(true), + + customer_for_portal: bigint("customer_for_portal", { mode: "number" }), + + pinned_on_navigation: jsonb("pinned_on_navigation").notNull().default("[]"), + + email: text("email"), + token_id: text("token_id"), + + weekly_working_days: doublePrecision("weekly_working_days"), + + old_profile_id: uuid("old_profile_id"), + temp_config: jsonb("temp_config"), + + state_code: text("state_code").default("DE-NI"), + + contract_type: text("contract_type"), + position: text("position"), + qualification: text("qualification"), + + address_street: text("address_street"), + address_zip: text("address_zip"), + address_city: text("address_city"), + + active: boolean("active").notNull().default(true), +}) + +export type AuthProfile = typeof authProfiles.$inferSelect +export type NewAuthProfile = typeof authProfiles.$inferInsert diff --git a/db/schema/auth_role_permisssions.ts b/db/schema/auth_role_permisssions.ts new file mode 100644 index 0000000..fafba53 --- /dev/null +++ b/db/schema/auth_role_permisssions.ts @@ -0,0 +1,23 @@ +import { pgTable, uuid, text, timestamp } from "drizzle-orm/pg-core" +import { authRoles } from "./auth_roles" + +export const authRolePermissions = pgTable( + "auth_role_permissions", + { + created_at: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + role_id: uuid("role_id") + .notNull() + .references(() => authRoles.id), + + permission: text("permission").notNull(), + }, + (table) => ({ + primaryKey: [table.role_id, table.permission], + }) +) + +export type AuthRolePermission = typeof authRolePermissions.$inferSelect +export type NewAuthRolePermission = typeof authRolePermissions.$inferInsert diff --git a/db/schema/auth_roles.ts b/db/schema/auth_roles.ts new file mode 100644 index 0000000..2f8f657 --- /dev/null +++ b/db/schema/auth_roles.ts @@ -0,0 +1,19 @@ +import { pgTable, uuid, text, timestamp, bigint } from "drizzle-orm/pg-core" +import { authUsers } from "./auth_users" + +export const authRoles = pgTable("auth_roles", { + id: uuid("id").primaryKey().defaultRandom(), + + created_at: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + name: text("name").notNull(), + description: text("description"), + + created_by: uuid("created_by").references(() => authUsers.id), + tenant_id: bigint("tenant_id", {mode: "number"}), +}) + +export type AuthRole = typeof authRoles.$inferSelect +export type NewAuthRole = typeof authRoles.$inferInsert diff --git a/db/schema/auth_tenant_users.ts b/db/schema/auth_tenant_users.ts new file mode 100644 index 0000000..4bf5709 --- /dev/null +++ b/db/schema/auth_tenant_users.ts @@ -0,0 +1,22 @@ +import { pgTable, uuid, bigint, timestamp } from "drizzle-orm/pg-core" +import { authUsers } from "./auth_users" + +export const authTenantUsers = pgTable( + "auth_tenant_users", + { + created_at: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + tenant_id: bigint("tenant_id", { mode: "number" }).notNull(), + user_id: uuid("user_id").notNull(), + + created_by: uuid("created_by").references(() => authUsers.id), + }, + (table) => ({ + primaryKey: [table.tenant_id, table.user_id], + }) +) + +export type AuthTenantUser = typeof authTenantUsers.$inferSelect +export type NewAuthTenantUser = typeof authTenantUsers.$inferInsert diff --git a/db/schema/auth_user_roles.ts b/db/schema/auth_user_roles.ts new file mode 100644 index 0000000..4bec35e --- /dev/null +++ b/db/schema/auth_user_roles.ts @@ -0,0 +1,30 @@ +import { pgTable, uuid, bigint, timestamp } from "drizzle-orm/pg-core" +import { authUsers } from "./auth_users" +import { authRoles } from "./auth_roles" + +export const authUserRoles = pgTable( + "auth_user_roles", + { + created_at: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + user_id: uuid("user_id") + .notNull() + .references(() => authUsers.id), + + role_id: uuid("role_id") + .notNull() + .references(() => authRoles.id), + + tenant_id: bigint("tenant_id", { mode: "number" }).notNull(), + + created_by: uuid("created_by").references(() => authUsers.id), + }, + (table) => ({ + primaryKey: [table.user_id, table.role_id, table.tenant_id], + }) +) + +export type AuthUserRole = typeof authUserRoles.$inferSelect +export type NewAuthUserRole = typeof authUserRoles.$inferInsert diff --git a/db/schema/auth_users.ts b/db/schema/auth_users.ts new file mode 100644 index 0000000..224bd74 --- /dev/null +++ b/db/schema/auth_users.ts @@ -0,0 +1,22 @@ +import { pgTable, uuid, text, boolean, timestamp } from "drizzle-orm/pg-core" + +export const authUsers = pgTable("auth_users", { + id: uuid("id").primaryKey().defaultRandom(), + + created_at: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + email: text("email").notNull(), + passwordHash: text("password_hash").notNull(), + + multiTenant: boolean("multi_tenant").notNull().default(true), + must_change_password: boolean("must_change_password").notNull().default(false), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + + ported: boolean("ported").notNull().default(true), +}) + +export type AuthUser = typeof authUsers.$inferSelect +export type NewAuthUser = typeof authUsers.$inferInsert diff --git a/db/schema/bankaccounts.ts b/db/schema/bankaccounts.ts new file mode 100644 index 0000000..2b431d4 --- /dev/null +++ b/db/schema/bankaccounts.ts @@ -0,0 +1,52 @@ +import { + pgTable, + bigint, + timestamp, + text, + doublePrecision, + boolean, + uuid, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" + +export const bankaccounts = pgTable("bankaccounts", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + name: text("name"), + iban: text("iban").notNull(), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + bankId: text("bankId").notNull(), + ownerName: text("ownerName"), + + accountId: text("accountId").notNull(), + + balance: doublePrecision("balance"), + + expired: boolean("expired").notNull().default(false), + + datevNumber: text("datevNumber"), + + syncedAt: timestamp("synced_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), + + archived: boolean("archived").notNull().default(false), +}) + +export type BankAccount = typeof bankaccounts.$inferSelect +export type NewBankAccount = typeof bankaccounts.$inferInsert diff --git a/db/schema/bankrequisitions.ts b/db/schema/bankrequisitions.ts new file mode 100644 index 0000000..3cfd18e --- /dev/null +++ b/db/schema/bankrequisitions.ts @@ -0,0 +1,30 @@ +import { + pgTable, + uuid, + timestamp, + text, + bigint, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" + +export const bankrequisitions = pgTable("bankrequisitions", { + id: uuid("id").primaryKey(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + institutionId: text("institutionId"), + + tenant: bigint("tenant", { mode: "number" }).references(() => tenants.id), + + status: text("status"), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), +}) + +export type BankRequisition = typeof bankrequisitions.$inferSelect +export type NewBankRequisition = typeof bankrequisitions.$inferInsert diff --git a/db/schema/bankstatements.ts b/db/schema/bankstatements.ts new file mode 100644 index 0000000..c69ee2e --- /dev/null +++ b/db/schema/bankstatements.ts @@ -0,0 +1,62 @@ +import { + pgTable, + bigint, + timestamp, + text, + doublePrecision, + boolean, + uuid, +} from "drizzle-orm/pg-core" + +import { bankaccounts } from "./bankaccounts" +import { createddocuments } from "./createddocuments" +import { tenants } from "./tenants" +import { incominginvoices } from "./incominginvoices" +import { contracts } from "./contracts" +import { authUsers } from "./auth_users" + +export const bankstatements = pgTable("bankstatements", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + account: bigint("account", { mode: "number" }) + .notNull() + .references(() => bankaccounts.id), + + date: text("date").notNull(), + + credIban: text("credIban"), + credName: text("credName"), + + text: text("text"), + amount: doublePrecision("amount").notNull(), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + debIban: text("debIban"), + debName: text("debName"), + gocardlessId: text("gocardlessId"), + currency: text("currency"), + valueDate: text("valueDate"), + + mandateId: text("mandateId"), + + contract: bigint("contract", { mode: "number" }).references( + () => contracts.id + ), + + archived: boolean("archived").notNull().default(false), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), +}) + +export type BankStatement = typeof bankstatements.$inferSelect +export type NewBankStatement = typeof bankstatements.$inferInsert diff --git a/db/schema/checkexecutions.ts b/db/schema/checkexecutions.ts new file mode 100644 index 0000000..455877c --- /dev/null +++ b/db/schema/checkexecutions.ts @@ -0,0 +1,27 @@ +import { + pgTable, + uuid, + timestamp, + text, +} from "drizzle-orm/pg-core" + +import { checks } from "./checks" + +export const checkexecutions = pgTable("checkexecutions", { + id: uuid("id").primaryKey().defaultRandom(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + check: uuid("check").references(() => checks.id), + + executedAt: timestamp("executed_at"), + + // ❌ executed_by removed (was 0_profiles) + + description: text("description"), +}) + +export type CheckExecution = typeof checkexecutions.$inferSelect +export type NewCheckExecution = typeof checkexecutions.$inferInsert diff --git a/db/schema/checks.ts b/db/schema/checks.ts new file mode 100644 index 0000000..45f2a26 --- /dev/null +++ b/db/schema/checks.ts @@ -0,0 +1,52 @@ +import { + pgTable, + uuid, + timestamp, + text, + bigint, + boolean, + jsonb, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { vehicles } from "./vehicles" +import { inventoryitems } from "./inventoryitems" +import { authUsers } from "./auth_users" + +export const checks = pgTable("checks", { + id: uuid("id").primaryKey().defaultRandom(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + vehicle: bigint("vehicle", { mode: "number" }) + .references(() => vehicles.id), + + // ❌ profile removed (old 0_profiles reference) + + inventoryItem: bigint("inventoryitem", { mode: "number" }) + .references(() => inventoryitems.id), + + tenant: bigint("tenant", { mode: "number" }) + .references(() => tenants.id), + + name: text("name"), + type: text("type"), + + distance: bigint("distance", { mode: "number" }).default(1), + + distanceUnit: text("distanceUnit").default("days"), + + description: text("description"), + + profiles: jsonb("profiles").notNull().default([]), + + archived: boolean("archived").notNull().default(false), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), +}) + +export type Check = typeof checks.$inferSelect +export type NewCheck = typeof checks.$inferInsert diff --git a/db/schema/citys.ts b/db/schema/citys.ts new file mode 100644 index 0000000..e54e5fd --- /dev/null +++ b/db/schema/citys.ts @@ -0,0 +1,32 @@ +import { + pgTable, + bigint, + text, + jsonb, +} from "drizzle-orm/pg-core" + +export const citys = pgTable("citys", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + name: text("name"), + short: text("short"), + long: text("long"), + + geometry: jsonb("geometry"), + + zip: bigint("zip", { mode: "number" }), + + districtCode: bigint("districtCode", { mode: "number" }), + + countryName: text("countryName"), + countryCode: bigint("countryCode", { mode: "number" }), + + districtName: text("districtName"), + + geopoint: text("geopoint"), +}) + +export type City = typeof citys.$inferSelect +export type NewCity = typeof citys.$inferInsert diff --git a/db/schema/contacts.ts b/db/schema/contacts.ts new file mode 100644 index 0000000..b3f3824 --- /dev/null +++ b/db/schema/contacts.ts @@ -0,0 +1,66 @@ +import { + pgTable, + bigint, + text, + timestamp, + boolean, + jsonb, + date, + uuid, +} from "drizzle-orm/pg-core" + +import { customers } from "./customers" +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" + +export const contacts = pgTable( + "contacts", + { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + firstName: text("firstName"), + lastName: text("lastName"), + email: text("email"), + + customer: bigint("customer", { mode: "number" }).references( + () => customers.id + ), + + tenant: bigint("tenant", { mode: "number" }).notNull(), + + phoneMobile: text("phoneMobile"), + phoneHome: text("phoneHome"), + + heroId: text("heroId"), + role: text("role"), + + fullName: text("fullName"), + + salutation: text("salutation"), + + vendor: bigint("vendor", { mode: "number" }), // vendors folgt separat + + active: boolean("active").notNull().default(true), + + birthday: date("birthday"), + notes: text("notes"), + + profiles: jsonb("profiles").notNull().default([]), + + archived: boolean("archived").notNull().default(false), + + title: text("title"), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), + } +) + +export type Contact = typeof contacts.$inferSelect +export type NewContact = typeof contacts.$inferInsert diff --git a/db/schema/contracts.ts b/db/schema/contracts.ts new file mode 100644 index 0000000..3673395 --- /dev/null +++ b/db/schema/contracts.ts @@ -0,0 +1,76 @@ +import { + pgTable, + bigint, + text, + timestamp, + boolean, + jsonb, + uuid, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { customers } from "./customers" +import { contacts } from "./contacts" +import { authUsers } from "./auth_users" + +export const contracts = pgTable( + "contracts", + { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + tenant: bigint("tenant", { mode: "number" }).notNull(), + + name: text("name").notNull(), + + customer: bigint("customer", { mode: "number" }) + .notNull() + .references(() => customers.id), + + notes: text("notes"), + + active: boolean("active").notNull().default(true), + recurring: boolean("recurring").notNull().default(false), + + rhythm: jsonb("rhythm"), + + startDate: timestamp("startDate", { withTimezone: true }), + endDate: timestamp("endDate", { withTimezone: true }), + signDate: timestamp("signDate", { withTimezone: true }), + + duration: text("duration"), + + contact: bigint("contact", { mode: "number" }).references( + () => contacts.id + ), + + bankingIban: text("bankingIban"), + bankingBIC: text("bankingBIC"), + bankingName: text("bankingName"), + bankingOwner: text("bankingOwner"), + sepaRef: text("sepaRef"), + sepaDate: timestamp("sepaDate", { withTimezone: true }), + + paymentType: text("paymentType"), + invoiceDispatch: text("invoiceDispatch"), + + ownFields: jsonb("ownFields").notNull().default({}), + profiles: jsonb("profiles").notNull().default([]), + + archived: boolean("archived").notNull().default(false), + + contractNumber: text("contractNumber"), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + + updatedBy: uuid("updated_by").references(() => authUsers.id), + } +) + +export type Contract = typeof contracts.$inferSelect +export type NewContract = typeof contracts.$inferInsert diff --git a/db/schema/costcentres.ts b/db/schema/costcentres.ts new file mode 100644 index 0000000..7dccb10 --- /dev/null +++ b/db/schema/costcentres.ts @@ -0,0 +1,50 @@ +import { + pgTable, + uuid, + timestamp, + text, + boolean, + jsonb, + bigint, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { inventoryitems } from "./inventoryitems" +import { projects } from "./projects" +import { vehicles } from "./vehicles" +import { authUsers } from "./auth_users" + +export const costcentres = pgTable("costcentres", { + id: uuid("id").primaryKey().defaultRandom(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + number: text("number").notNull(), + name: text("name").notNull(), + + vehicle: bigint("vehicle", { mode: "number" }).references(() => vehicles.id), + + project: bigint("project", { mode: "number" }).references(() => projects.id), + + inventoryitem: bigint("inventoryitem", { mode: "number" }).references( + () => inventoryitems.id + ), + + description: text("description"), + + archived: boolean("archived").notNull().default(false), + + profiles: jsonb("profiles").notNull().default([]), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), +}) + +export type CostCentre = typeof costcentres.$inferSelect +export type NewCostCentre = typeof costcentres.$inferInsert diff --git a/db/schema/countrys.ts b/db/schema/countrys.ts new file mode 100644 index 0000000..9eb3e9f --- /dev/null +++ b/db/schema/countrys.ts @@ -0,0 +1,21 @@ +import { + pgTable, + bigint, + timestamp, + text, +} from "drizzle-orm/pg-core" + +export const countrys = pgTable("countrys", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + name: text("name").notNull(), +}) + +export type Country = typeof countrys.$inferSelect +export type NewCountry = typeof countrys.$inferInsert diff --git a/db/schema/createddocuments.ts b/db/schema/createddocuments.ts new file mode 100644 index 0000000..9fd881a --- /dev/null +++ b/db/schema/createddocuments.ts @@ -0,0 +1,124 @@ +import { + pgTable, + bigint, + timestamp, + text, + jsonb, + boolean, + smallint, + uuid, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { customers } from "./customers" +import { contacts } from "./contacts" +import { contracts } from "./contracts" +import { letterheads } from "./letterheads" +import { projects } from "./projects" +import { plants } from "./plants" +import { authUsers } from "./auth_users" +import {serialExecutions} from "./serialexecutions"; + +export const createddocuments = pgTable("createddocuments", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + type: text("type").notNull().default("INVOICE"), + + customer: bigint("customer", { mode: "number" }).references( + () => customers.id + ), + + contact: bigint("contact", { mode: "number" }).references( + () => contacts.id + ), + + address: jsonb("address"), + project: bigint("project", { mode: "number" }).references( + () => projects.id + ), + + documentNumber: text("documentNumber"), + documentDate: text("documentDate"), + + state: text("state").notNull().default("Entwurf"), + + info: jsonb("info"), + + createdBy: uuid("createdBy").references(() => authUsers.id), + + title: text("title"), + description: text("description"), + + startText: text("startText"), + endText: text("endText"), + + rows: jsonb("rows").default([]), + + deliveryDateType: text("deliveryDateType"), + paymentDays: smallint("paymentDays"), + deliveryDate: text("deliveryDate"), + + contactPerson: uuid("contactPerson"), + + serialConfig: jsonb("serialConfig").default({}), + + createddocument: bigint("linkedDocument", { mode: "number" }).references( + () => createddocuments.id + ), + + agriculture: jsonb("agriculture"), + + letterhead: bigint("letterhead", { mode: "number" }).references( + () => letterheads.id + ), + + advanceInvoiceResolved: boolean("advanceInvoiceResolved") + .notNull() + .default(false), + + usedAdvanceInvoices: jsonb("usedAdvanceInvoices").notNull().default([]), + + archived: boolean("archived").notNull().default(false), + + deliveryDateEnd: text("deliveryDateEnd"), + + plant: bigint("plant", { mode: "number" }).references(() => plants.id), + + taxType: text("taxType"), + + customSurchargePercentage: smallint("customSurchargePercentage") + .notNull() + .default(0), + + report: jsonb("report").notNull().default({}), + + availableInPortal: boolean("availableInPortal") + .notNull() + .default(false), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), + + created_by: uuid("created_by").references(() => authUsers.id), + + payment_type: text("payment_type").default("transfer"), + + contract: bigint("contract", { mode: "number" }).references( + () => contracts.id + ), + + serialexecution: uuid("serialexecution").references(() => serialExecutions.id) +}) + +export type CreatedDocument = typeof createddocuments.$inferSelect +export type NewCreatedDocument = typeof createddocuments.$inferInsert diff --git a/db/schema/createdletters.ts b/db/schema/createdletters.ts new file mode 100644 index 0000000..a180624 --- /dev/null +++ b/db/schema/createdletters.ts @@ -0,0 +1,43 @@ +import { + pgTable, + uuid, + timestamp, + bigint, + text, + jsonb, + boolean, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { customers } from "./customers" +import { vendors } from "./vendors" +import { authUsers } from "./auth_users" + +export const createdletters = pgTable("createdletters", { + id: uuid("id").primaryKey().defaultRandom(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + tenant: bigint("tenant", { mode: "number" }).references(() => tenants.id), + + customer: bigint("customer", { mode: "number" }).references( + () => customers.id + ), + + vendor: bigint("vendor", { mode: "number" }).references(() => vendors.id), + + contentJson: jsonb("content_json").default([]), + + contentText: text("content_text"), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + + updatedBy: uuid("updated_by").references(() => authUsers.id), + + archived: boolean("archived").notNull().default(false), +}) + +export type CreatedLetter = typeof createdletters.$inferSelect +export type NewCreatedLetter = typeof createdletters.$inferInsert diff --git a/db/schema/customers.ts b/db/schema/customers.ts new file mode 100644 index 0000000..67743e8 --- /dev/null +++ b/db/schema/customers.ts @@ -0,0 +1,69 @@ +import { + pgTable, + bigint, + text, + timestamp, + boolean, + jsonb, + smallint, + uuid, +} from "drizzle-orm/pg-core" +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" + +export const customers = pgTable( + "customers", + { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + customerNumber: text("customerNumber").notNull(), + name: text("name").notNull(), + + tenant: bigint("tenant", { mode: "number" }).notNull(), + + infoData: jsonb("infoData").default({}), + active: boolean("active").notNull().default(true), + + notes: text("notes"), + + type: text("type").default("Privat"), + heroId: text("heroId"), + + isCompany: boolean("isCompany").notNull().default(false), + + profiles: jsonb("profiles").notNull().default([]), + + customPaymentDays: smallint("customPaymentDays"), + + firstname: text("firstname"), + lastname: text("lastname"), + + archived: boolean("archived").notNull().default(false), + + customSurchargePercentage: smallint("customSurchargePercentage") + .notNull() + .default(0), + + salutation: text("salutation"), + title: text("title"), + nameAddition: text("nameAddition"), + + availableInPortal: boolean("availableInPortal") + .notNull() + .default(false), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), + + customPaymentType: text("custom_payment_type"), // ENUM payment_types separat? + } +) + +export type Customer = typeof customers.$inferSelect +export type NewCustomer = typeof customers.$inferInsert diff --git a/db/schema/devices.ts b/db/schema/devices.ts new file mode 100644 index 0000000..4825826 --- /dev/null +++ b/db/schema/devices.ts @@ -0,0 +1,29 @@ +import { + pgTable, + uuid, + timestamp, + text, + bigint, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" + +export const devices = pgTable("devices", { + id: uuid("id").primaryKey().defaultRandom(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + name: text("name").notNull(), + type: text("type").notNull(), + + tenant: bigint("tenant", { mode: "number" }).references(() => tenants.id), + + password: text("password"), + + externalId: text("externalId"), +}) + +export type Device = typeof devices.$inferSelect +export type NewDevice = typeof devices.$inferInsert diff --git a/db/schema/documentboxes.ts b/db/schema/documentboxes.ts new file mode 100644 index 0000000..1111a19 --- /dev/null +++ b/db/schema/documentboxes.ts @@ -0,0 +1,28 @@ +import { pgTable, uuid, timestamp, text, boolean, bigint } from "drizzle-orm/pg-core" + +import { spaces } from "./spaces" +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" + +export const documentboxes = pgTable("documentboxes", { + id: uuid("id").primaryKey().defaultRandom(), + + createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(), + + space: bigint("space", { mode: "number" }).references(() => spaces.id), + + key: text("key").notNull(), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + archived: boolean("archived").notNull().default(false), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + + updatedBy: uuid("updated_by").references(() => authUsers.id), +}) + +export type DocumentBox = typeof documentboxes.$inferSelect +export type NewDocumentBox = typeof documentboxes.$inferInsert diff --git a/db/schema/enums.ts b/db/schema/enums.ts new file mode 100644 index 0000000..3030302 --- /dev/null +++ b/db/schema/enums.ts @@ -0,0 +1,97 @@ +import { pgEnum } from "drizzle-orm/pg-core" + +// public.textTemplatePositions +export const textTemplatePositionsEnum = pgEnum("texttemplatepositions", [ + "startText", + "endText", +]) + +// public.folderFunctions +export const folderFunctionsEnum = pgEnum("folderfunctions", [ + "none", + "yearSubCategory", + "incomingInvoices", + "invoices", + "quotes", + "confirmationOrders", + "deliveryNotes", + "vehicleData", + "reminders", + "taxData", + "deposit", + "timeEvaluations", +]) + +// public.locked_tenant +export const lockedTenantEnum = pgEnum("locked_tenant", [ + "maintenance_tenant", + "maintenance", + "general", + "no_subscription", +]) + +// public.credential_types +export const credentialTypesEnum = pgEnum("credential_types", [ + "mail", + "m365", +]) + +// public.payment_types +export const paymentTypesEnum = pgEnum("payment_types", [ + "transfer", + "direct_debit", +]) + +// public.notification_status +export const notificationStatusEnum = pgEnum("notification_status", [ + "queued", + "sent", + "failed", + "read", +]) + +// public.notification_channel +export const notificationChannelEnum = pgEnum("notification_channel", [ + "email", + "inapp", + "sms", + "push", + "webhook", +]) + +// public.notification_severity +export const notificationSeverityEnum = pgEnum("notification_severity", [ + "info", + "success", + "warning", + "error", +]) + +// public.times_state +export const timesStateEnum = pgEnum("times_state", [ + "submitted", + "approved", + "draft", +]) + +export const helpdeskStatusEnum = [ + "open", + "in_progress", + "waiting_for_customer", + "answered", + "closed", +] as const + +export const helpdeskPriorityEnum = [ + "low", + "normal", + "high", +] as const + +export const helpdeskDirectionEnum = [ + "incoming", + "outgoing", + "internal", + "system", +] as const + diff --git a/db/schema/events.ts b/db/schema/events.ts new file mode 100644 index 0000000..b703c3e --- /dev/null +++ b/db/schema/events.ts @@ -0,0 +1,60 @@ +import { + pgTable, + bigint, + text, + timestamp, + boolean, + jsonb, + uuid, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { customers } from "./customers" +import { authUsers } from "./auth_users" + +export const events = pgTable( + "events", + { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + tenant: bigint("tenant", { mode: "number" }).notNull(), + + name: text("name").notNull(), + + startDate: timestamp("startDate", { withTimezone: true }).notNull(), + endDate: timestamp("endDate", { withTimezone: true }), + + eventtype: text("eventtype").default("Umsetzung"), + + project: bigint("project", { mode: "number" }), // FK follows when projects.ts exists + + resources: jsonb("resources").default([]), + notes: text("notes"), + link: text("link"), + + profiles: jsonb("profiles").notNull().default([]), + archived: boolean("archived").notNull().default(false), + + vehicles: jsonb("vehicles").notNull().default([]), + inventoryitems: jsonb("inventoryitems").notNull().default([]), + inventoryitemgroups: jsonb("inventoryitemgroups").notNull().default([]), + + customer: bigint("customer", { mode: "number" }).references( + () => customers.id + ), + + vendor: bigint("vendor", { mode: "number" }), // will link once vendors.ts is created + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), + } +) + +export type Event = typeof events.$inferSelect +export type NewEvent = typeof events.$inferInsert diff --git a/db/schema/files.ts b/db/schema/files.ts new file mode 100644 index 0000000..a151421 --- /dev/null +++ b/db/schema/files.ts @@ -0,0 +1,79 @@ +import { + pgTable, + uuid, + timestamp, + text, + boolean, + bigint, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { projects } from "./projects" +import { customers } from "./customers" +import { contracts } from "./contracts" +import { vendors } from "./vendors" +import { incominginvoices } from "./incominginvoices" +import { plants } from "./plants" +import { createddocuments } from "./createddocuments" +import { vehicles } from "./vehicles" +import { products } from "./products" +import { inventoryitems } from "./inventoryitems" +import { folders } from "./folders" +import { filetags } from "./filetags" +import { authUsers } from "./auth_users" +import { authProfiles } from "./auth_profiles" +import { spaces } from "./spaces" +import { documentboxes } from "./documentboxes" +import { checks } from "./checks" + +export const files = pgTable("files", { + id: uuid("id").primaryKey().defaultRandom(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + path: text("path"), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + project: bigint("project", { mode: "number" }).references(() => projects.id), + customer: bigint("customer", { mode: "number" }).references(() => customers.id), + contract: bigint("contract", { mode: "number" }).references(() => contracts.id), + vendor: bigint("vendor", { mode: "number" }).references(() => vendors.id), + incominginvoice: bigint("incominginvoice", { mode: "number" }).references(() => incominginvoices.id), + plant: bigint("plant", { mode: "number" }).references(() => plants.id), + createddocument: bigint("createddocument", { mode: "number" }).references(() => createddocuments.id), + vehicle: bigint("vehicle", { mode: "number" }).references(() => vehicles.id), + product: bigint("product", { mode: "number" }).references(() => products.id), + + check: uuid("check").references(() => checks.id), + + inventoryitem: bigint("inventoryitem", { mode: "number" }).references(() => inventoryitems.id), + + folder: uuid("folder").references(() => folders.id), + + mimeType: text("mimeType"), + + archived: boolean("archived").notNull().default(false), + + space: bigint("space", { mode: "number" }).references(() => spaces.id), + + type: uuid("type").references(() => filetags.id), + + documentbox: uuid("documentbox").references(() => documentboxes.id), + + name: text("name"), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), + + createdBy: uuid("created_by").references(() => authUsers.id), + + authProfile: uuid("auth_profile").references(() => authProfiles.id), +}) + +export type File = typeof files.$inferSelect +export type NewFile = typeof files.$inferInsert diff --git a/db/schema/filetags.ts b/db/schema/filetags.ts new file mode 100644 index 0000000..3dc47cf --- /dev/null +++ b/db/schema/filetags.ts @@ -0,0 +1,33 @@ +import { + pgTable, + uuid, + timestamp, + text, + boolean, + bigint, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" + +export const filetags = pgTable("filetags", { + id: uuid("id").primaryKey().defaultRandom(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + name: text("name").notNull(), + color: text("color"), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + createdDocumentType: text("createddocumenttype").default(""), + incomingDocumentType: text("incomingDocumentType"), + + archived: boolean("archived").notNull().default(false), +}) + +export type FileTag = typeof filetags.$inferSelect +export type NewFileTag = typeof filetags.$inferInsert diff --git a/db/schema/folders.ts b/db/schema/folders.ts new file mode 100644 index 0000000..74a9a11 --- /dev/null +++ b/db/schema/folders.ts @@ -0,0 +1,51 @@ +import { + pgTable, + uuid, + timestamp, + text, + boolean, + integer, + bigint, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" +import { filetags } from "./filetags" +import { folderFunctionsEnum } from "./enums" + +export const folders = pgTable("folders", { + id: uuid("id").primaryKey().defaultRandom(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + name: text("name").notNull(), + icon: text("icon"), + + parent: uuid("parent").references(() => folders.id), + + isSystemUsed: boolean("isSystemUsed").notNull().default(false), + + function: folderFunctionsEnum("function"), + + year: integer("year"), + + standardFiletype: uuid("standardFiletype").references(() => filetags.id), + + standardFiletypeIsOptional: boolean("standardFiletypeIsOptional") + .notNull() + .default(true), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), + + archived: boolean("archived").notNull().default(false), +}) + +export type Folder = typeof folders.$inferSelect +export type NewFolder = typeof folders.$inferInsert diff --git a/db/schema/generatedexports.ts b/db/schema/generatedexports.ts new file mode 100644 index 0000000..b2a5c84 --- /dev/null +++ b/db/schema/generatedexports.ts @@ -0,0 +1,35 @@ +import { + pgTable, + bigint, + timestamp, + text, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" + +export const generatedexports = pgTable("exports", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + tenantId: bigint("tenant_id", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + startDate: timestamp("start_date", { withTimezone: true }).notNull(), + endDate: timestamp("end_date", { withTimezone: true }).notNull(), + + validUntil: timestamp("valid_until", { withTimezone: true }), + + type: text("type").notNull().default("datev"), + + url: text("url").notNull(), + filePath: text("file_path"), +}) + +export type Export = typeof generatedexports.$inferSelect +export type NewExport = typeof generatedexports.$inferInsert diff --git a/db/schema/globalmessages.ts b/db/schema/globalmessages.ts new file mode 100644 index 0000000..3a2ffb9 --- /dev/null +++ b/db/schema/globalmessages.ts @@ -0,0 +1,22 @@ +import { + pgTable, + bigint, + timestamp, + text, +} from "drizzle-orm/pg-core" + +export const globalmessages = pgTable("globalmessages", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + title: text("title"), + description: text("description"), +}) + +export type GlobalMessage = typeof globalmessages.$inferSelect +export type NewGlobalMessage = typeof globalmessages.$inferInsert diff --git a/db/schema/globalmessagesseen.ts b/db/schema/globalmessagesseen.ts new file mode 100644 index 0000000..7ee9c8e --- /dev/null +++ b/db/schema/globalmessagesseen.ts @@ -0,0 +1,17 @@ +import { + pgTable, + timestamp, + bigint, +} from "drizzle-orm/pg-core" + +import { globalmessages } from "./globalmessages" + +export const globalmessagesseen = pgTable("globalmessagesseen", { + message: bigint("message", { mode: "number" }) + .notNull() + .references(() => globalmessages.id), + + seenAt: timestamp("seen_at", { withTimezone: true }) + .notNull() + .defaultNow(), +}) diff --git a/db/schema/helpdesk_channel_instances.ts b/db/schema/helpdesk_channel_instances.ts new file mode 100644 index 0000000..29edfea --- /dev/null +++ b/db/schema/helpdesk_channel_instances.ts @@ -0,0 +1,44 @@ +import { + pgTable, + uuid, + timestamp, + text, + boolean, + jsonb, + bigint, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" +import { helpdesk_channel_types } from "./helpdesk_channel_types" + +export const helpdesk_channel_instances = pgTable("helpdesk_channel_instances", { + id: uuid("id").primaryKey().defaultRandom(), + + tenantId: bigint("tenant_id", { mode: "number" }) + .notNull() + .references(() => tenants.id, { onDelete: "cascade" }), + + typeId: text("type_id") + .notNull() + .references(() => helpdesk_channel_types.id), + + name: text("name").notNull(), + + isActive: boolean("is_active").notNull().default(true), + + config: jsonb("config").notNull(), + publicConfig: jsonb("public_config").notNull().default({}), + + publicToken: text("public_token").unique(), + secretToken: text("secret_token"), + + createdBy: uuid("created_by").references(() => authUsers.id), + + createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(), +}) + +export type HelpdeskChannelInstance = + typeof helpdesk_channel_instances.$inferSelect +export type NewHelpdeskChannelInstance = + typeof helpdesk_channel_instances.$inferInsert diff --git a/db/schema/helpdesk_channel_types.ts b/db/schema/helpdesk_channel_types.ts new file mode 100644 index 0000000..8b1a8f3 --- /dev/null +++ b/db/schema/helpdesk_channel_types.ts @@ -0,0 +1,9 @@ +import { pgTable, text } from "drizzle-orm/pg-core" + +export const helpdesk_channel_types = pgTable("helpdesk_channel_types", { + id: text("id").primaryKey(), + description: text("description").notNull(), +}) + +export type HelpdeskChannelType = typeof helpdesk_channel_types.$inferSelect +export type NewHelpdeskChannelType = typeof helpdesk_channel_types.$inferInsert diff --git a/db/schema/helpdesk_contacts.ts b/db/schema/helpdesk_contacts.ts new file mode 100644 index 0000000..baeab18 --- /dev/null +++ b/db/schema/helpdesk_contacts.ts @@ -0,0 +1,45 @@ +import { + pgTable, + uuid, + timestamp, + text, + jsonb, + bigint, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { customers } from "./customers" +import { contacts } from "./contacts" +import { helpdesk_channel_instances } from "./helpdesk_channel_instances" // placeholder + +export const helpdesk_contacts = pgTable("helpdesk_contacts", { + id: uuid("id").primaryKey().defaultRandom(), + + tenantId: bigint("tenant_id", { mode: "number" }) + .notNull() + .references(() => tenants.id, { onDelete: "cascade" }), + + customerId: bigint("customer_id", { mode: "number" }) + .references(() => customers.id, { onDelete: "set null" }), + + email: text("email"), + phone: text("phone"), + + externalRef: jsonb("external_ref"), + displayName: text("display_name"), + + createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(), + + sourceChannelId: uuid("source_channel_id").references( + () => helpdesk_channel_instances.id, + { onDelete: "set null" } + ), + + contactId: bigint("contact_id", { mode: "number" }).references( + () => contacts.id, + { onDelete: "set null" } + ), +}) + +export type HelpdeskContact = typeof helpdesk_contacts.$inferSelect +export type NewHelpdeskContact = typeof helpdesk_contacts.$inferInsert diff --git a/db/schema/helpdesk_conversation_participants.ts b/db/schema/helpdesk_conversation_participants.ts new file mode 100644 index 0000000..c4d7c6b --- /dev/null +++ b/db/schema/helpdesk_conversation_participants.ts @@ -0,0 +1,34 @@ +import { + pgTable, + uuid, + text, +} from "drizzle-orm/pg-core" + +import { helpdesk_conversations } from "./helpdesk_conversations" +import { authUsers } from "./auth_users" + +export const helpdesk_conversation_participants = pgTable( + "helpdesk_conversation_participants", + { + conversationId: uuid("conversation_id") + .notNull() + .references(() => helpdesk_conversations.id, { onDelete: "cascade" }), + + userId: uuid("user_id") + .notNull() + .references(() => authUsers.id, { onDelete: "cascade" }), + + role: text("role"), + }, + (table) => ({ + pk: { + name: "helpdesk_conversation_participants_pkey", + columns: [table.conversationId, table.userId], + }, + }) +) + +export type HelpdeskConversationParticipant = + typeof helpdesk_conversation_participants.$inferSelect +export type NewHelpdeskConversationParticipant = + typeof helpdesk_conversation_participants.$inferInsert diff --git a/db/schema/helpdesk_conversations.ts b/db/schema/helpdesk_conversations.ts new file mode 100644 index 0000000..f2c14dd --- /dev/null +++ b/db/schema/helpdesk_conversations.ts @@ -0,0 +1,59 @@ +import { + pgTable, + uuid, + timestamp, + text, + bigint, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { helpdesk_contacts } from "./helpdesk_contacts" +import { contacts } from "./contacts" +import { customers } from "./customers" +import { authUsers } from "./auth_users" +import { helpdesk_channel_instances } from "./helpdesk_channel_instances" + +export const helpdesk_conversations = pgTable("helpdesk_conversations", { + id: uuid("id").primaryKey().defaultRandom(), + + tenantId: bigint("tenant_id", { mode: "number" }) + .notNull() + .references(() => tenants.id, { onDelete: "cascade" }), + + channelInstanceId: uuid("channel_instance_id") + .notNull() + .references(() => helpdesk_channel_instances.id, { onDelete: "cascade" }), + + contactId: uuid("contact_id").references(() => helpdesk_contacts.id, { + onDelete: "set null", + }), + + subject: text("subject"), + + status: text("status").notNull().default("open"), + + priority: text("priority").default("normal"), + + assigneeUserId: uuid("assignee_user_id").references(() => authUsers.id), + + lastMessageAt: timestamp("last_message_at", { withTimezone: true }), + + createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(), + + customerId: bigint("customer_id", { mode: "number" }).references( + () => customers.id, + { onDelete: "set null" } + ), + + contactPersonId: bigint("contact_person_id", { mode: "number" }).references( + () => contacts.id, + { onDelete: "set null" } + ), + + ticketNumber: text("ticket_number"), +}) + +export type HelpdeskConversation = + typeof helpdesk_conversations.$inferSelect +export type NewHelpdeskConversation = + typeof helpdesk_conversations.$inferInsert diff --git a/db/schema/helpdesk_messages.ts b/db/schema/helpdesk_messages.ts new file mode 100644 index 0000000..08eec71 --- /dev/null +++ b/db/schema/helpdesk_messages.ts @@ -0,0 +1,46 @@ +import { + pgTable, + uuid, + timestamp, + text, + jsonb, + bigint, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { helpdesk_contacts } from "./helpdesk_contacts" +import { helpdesk_conversations } from "./helpdesk_conversations" +import { authUsers } from "./auth_users" + +export const helpdesk_messages = pgTable("helpdesk_messages", { + id: uuid("id").primaryKey().defaultRandom(), + + tenantId: bigint("tenant_id", { mode: "number" }) + .notNull() + .references(() => tenants.id, { onDelete: "cascade" }), + + conversationId: uuid("conversation_id") + .notNull() + .references(() => helpdesk_conversations.id, { onDelete: "cascade" }), + + direction: text("direction").notNull(), + + authorUserId: uuid("author_user_id").references(() => authUsers.id), + + payload: jsonb("payload").notNull(), + + rawMeta: jsonb("raw_meta"), + + createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(), + + contactId: uuid("contact_id").references(() => helpdesk_contacts.id, { + onDelete: "set null", + }), + + externalMessageId: text("external_message_id").unique(), + + receivedAt: timestamp("received_at", { withTimezone: true }).defaultNow(), +}) + +export type HelpdeskMessage = typeof helpdesk_messages.$inferSelect +export type NewHelpdeskMessage = typeof helpdesk_messages.$inferInsert diff --git a/db/schema/helpdesk_routing_rules.ts b/db/schema/helpdesk_routing_rules.ts new file mode 100644 index 0000000..4c3065b --- /dev/null +++ b/db/schema/helpdesk_routing_rules.ts @@ -0,0 +1,33 @@ +import { + pgTable, + uuid, + timestamp, + text, + jsonb, + bigint, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" + +export const helpdesk_routing_rules = pgTable("helpdesk_routing_rules", { + id: uuid("id").primaryKey().defaultRandom(), + + tenantId: bigint("tenant_id", { mode: "number" }) + .notNull() + .references(() => tenants.id, { onDelete: "cascade" }), + + name: text("name").notNull(), + + condition: jsonb("condition").notNull(), + action: jsonb("action").notNull(), + + createdBy: uuid("created_by").references(() => authUsers.id), + + createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(), +}) + +export type HelpdeskRoutingRule = + typeof helpdesk_routing_rules.$inferSelect +export type NewHelpdeskRoutingRule = + typeof helpdesk_routing_rules.$inferInsert diff --git a/db/schema/historyitems.ts b/db/schema/historyitems.ts new file mode 100644 index 0000000..4f82235 --- /dev/null +++ b/db/schema/historyitems.ts @@ -0,0 +1,140 @@ +import { + pgTable, + bigint, + uuid, + timestamp, + text, + jsonb, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { customers } from "./customers" +import { vendors } from "./vendors" +import { projects } from "./projects" +import { plants } from "./plants" +import { incominginvoices } from "./incominginvoices" +import { contacts } from "./contacts" +import { inventoryitems } from "./inventoryitems" +import { products } from "./products" +import { tasks } from "./tasks" +import { vehicles } from "./vehicles" +import { bankstatements } from "./bankstatements" +import { spaces } from "./spaces" +import { costcentres } from "./costcentres" +import { ownaccounts } from "./ownaccounts" +import { createddocuments } from "./createddocuments" +import { documentboxes } from "./documentboxes" +import { hourrates } from "./hourrates" +import { projecttypes } from "./projecttypes" +import { checks } from "./checks" +import { services } from "./services" +import { events } from "./events" +import { inventoryitemgroups } from "./inventoryitemgroups" +import { authUsers } from "./auth_users" +import {files} from "./files"; + +export const historyitems = pgTable("historyitems", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + text: text("text").notNull(), + + customer: bigint("customer", { mode: "number" }).references( + () => customers.id, + { onDelete: "cascade" } + ), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + vendor: bigint("vendor", { mode: "number" }).references(() => vendors.id), + + project: bigint("project", { mode: "number" }).references( + () => projects.id, + { onDelete: "cascade" } + ), + + plant: bigint("plant", { mode: "number" }).references( + () => plants.id, + { onDelete: "cascade" } + ), + + incomingInvoice: bigint("incomingInvoice", { mode: "number" }).references( + () => incominginvoices.id, + { onDelete: "cascade" } + ), + + contact: bigint("contact", { mode: "number" }).references(() => contacts.id, { + onDelete: "cascade", + }), + + inventoryitem: bigint("inventoryitem", { mode: "number" }).references( + () => inventoryitems.id, + { onDelete: "cascade" } + ), + + product: bigint("product", { mode: "number" }).references( + () => products.id, + { onDelete: "cascade" } + ), + + event: bigint("event", { mode: "number" }).references(() => events.id), + + newVal: text("newVal"), + oldVal: text("oldVal"), + + task: bigint("task", { mode: "number" }).references(() => tasks.id), + + vehicle: bigint("vehicle", { mode: "number" }).references(() => vehicles.id), + + bankstatement: bigint("bankstatement", { mode: "number" }).references( + () => bankstatements.id + ), + + space: bigint("space", { mode: "number" }).references(() => spaces.id), + + config: jsonb("config"), + + projecttype: bigint("projecttype", { mode: "number" }).references( + () => projecttypes.id + ), + + check: uuid("check").references(() => checks.id), + + service: bigint("service", { mode: "number" }).references( + () => services.id + ), + + createddocument: bigint("createddocument", { mode: "number" }).references( + () => createddocuments.id + ), + + file: uuid("file").references(() => files.id), + + inventoryitemgroup: uuid("inventoryitemgroup").references( + () => inventoryitemgroups.id + ), + + source: text("source").default("Software"), + + costcentre: uuid("costcentre").references(() => costcentres.id), + + ownaccount: uuid("ownaccount").references(() => ownaccounts.id), + + documentbox: uuid("documentbox").references(() => documentboxes.id), + + hourrate: uuid("hourrate").references(() => hourrates.id), + + createdBy: uuid("created_by").references(() => authUsers.id), + + action: text("action"), +}) + +export type HistoryItem = typeof historyitems.$inferSelect +export type NewHistoryItem = typeof historyitems.$inferInsert diff --git a/db/schema/holidays.ts b/db/schema/holidays.ts new file mode 100644 index 0000000..9a53dd8 --- /dev/null +++ b/db/schema/holidays.ts @@ -0,0 +1,18 @@ +import { pgTable, bigint, date, text, timestamp } from "drizzle-orm/pg-core" + +export const holidays = pgTable("holidays", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedAlwaysAsIdentity(), + + date: date("date").notNull(), + + name: text("name").notNull(), + + state_code: text("state_code").notNull(), + + createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(), +}) + +export type Holiday = typeof holidays.$inferSelect +export type NewHoliday = typeof holidays.$inferInsert diff --git a/db/schema/hourrates.ts b/db/schema/hourrates.ts new file mode 100644 index 0000000..299c2d5 --- /dev/null +++ b/db/schema/hourrates.ts @@ -0,0 +1,27 @@ +import { pgTable, uuid, timestamp, text, boolean, bigint, doublePrecision } from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" + +export const hourrates = pgTable("hourrates", { + id: uuid("id").primaryKey().defaultRandom(), + + createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + name: text("name").notNull(), + + purchasePrice: doublePrecision("purchasePrice").notNull(), + sellingPrice: doublePrecision("sellingPrice").notNull(), + + archived: boolean("archived").notNull().default(false), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), +}) + +export type HourRate = typeof hourrates.$inferSelect +export type NewHourRate = typeof hourrates.$inferInsert diff --git a/db/schema/incominginvoices.ts b/db/schema/incominginvoices.ts new file mode 100644 index 0000000..07ac711 --- /dev/null +++ b/db/schema/incominginvoices.ts @@ -0,0 +1,63 @@ +import { + pgTable, + bigint, + timestamp, + text, + boolean, + jsonb, + uuid, +} from "drizzle-orm/pg-core" + +import { vendors } from "./vendors" +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" + +export const incominginvoices = pgTable("incominginvoices", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + state: text("state").notNull().default("Entwurf"), + + vendor: bigint("vendor", { mode: "number" }).references(() => vendors.id), + + reference: text("reference"), + date: text("date"), + + document: bigint("document", { mode: "number" }), + + dueDate: text("dueDate"), + + description: text("description"), + + paymentType: text("paymentType"), + + accounts: jsonb("accounts").notNull().default([ + { + account: null, + taxType: null, + amountNet: null, + amountTax: 19, + costCentre: null, + }, + ]), + + paid: boolean("paid").notNull().default(false), + expense: boolean("expense").notNull().default(true), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), + + archived: boolean("archived").notNull().default(false), +}) + +export type IncomingInvoice = typeof incominginvoices.$inferSelect +export type NewIncomingInvoice = typeof incominginvoices.$inferInsert diff --git a/db/schema/index.ts b/db/schema/index.ts new file mode 100644 index 0000000..47d8bee --- /dev/null +++ b/db/schema/index.ts @@ -0,0 +1,74 @@ +export * from "./accounts" +export * from "./auth_profiles" +export * from "./auth_role_permisssions" +export * from "./auth_roles" +export * from "./auth_tenant_users" +export * from "./auth_user_roles" +export * from "./auth_users" +export * from "./bankaccounts" +export * from "./bankrequisitions" +export * from "./bankstatements" +export * from "./checkexecutions" +export * from "./checks" +export * from "./citys" +export * from "./contacts" +export * from "./contracts" +export * from "./costcentres" +export * from "./countrys" +export * from "./createddocuments" +export * from "./createdletters" +export * from "./customers" +export * from "./devices" +export * from "./documentboxes" +export * from "./enums" +export * from "./events" +export * from "./files" +export * from "./filetags" +export * from "./folders" +export * from "./generatedexports" +export * from "./globalmessages" +export * from "./globalmessagesseen" +export * from "./helpdesk_channel_instances" +export * from "./helpdesk_channel_types" +export * from "./helpdesk_contacts" +export * from "./helpdesk_conversation_participants" +export * from "./helpdesk_conversations" +export * from "./helpdesk_messages" +export * from "./helpdesk_routing_rules" +export * from "./historyitems" +export * from "./holidays" +export * from "./hourrates" +export * from "./incominginvoices" +export * from "./inventoryitemgroups" +export * from "./inventoryitems" +export * from "./letterheads" +export * from "./movements" +export * from "./notifications_event_types" +export * from "./notifications_items" +export * from "./notifications_preferences" +export * from "./notifications_preferences_defaults" +export * from "./ownaccounts" +export * from "./plants" +export * from "./productcategories" +export * from "./products" +export * from "./projects" +export * from "./projecttypes" +export * from "./servicecategories" +export * from "./services" +export * from "./spaces" +export * from "./staff_time_entries" +export * from "./staff_time_entry_connects" +export * from "./staff_zeitstromtimestamps" +export * from "./statementallocations" +export * from "./tasks" +export * from "./taxtypes" +export * from "./tenants" +export * from "./texttemplates" +export * from "./units" +export * from "./user_credentials" +export * from "./vehicles" +export * from "./vendors" +export * from "./staff_time_events" +export * from "./serialtypes" +export * from "./serialexecutions" +export * from "./public_links" \ No newline at end of file diff --git a/db/schema/inventoryitemgroups.ts b/db/schema/inventoryitemgroups.ts new file mode 100644 index 0000000..3fe9dc1 --- /dev/null +++ b/db/schema/inventoryitemgroups.ts @@ -0,0 +1,39 @@ +import { + pgTable, + uuid, + timestamp, + text, + boolean, + jsonb, bigint, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" + +export const inventoryitemgroups = pgTable("inventoryitemgroups", { + id: uuid("id").primaryKey().defaultRandom(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + tenant: bigint("tenant", { mode: "number" }).notNull().references(() => tenants.id), + + name: text("name").notNull(), + + inventoryitems: jsonb("inventoryitems").notNull().default([]), + + description: text("description"), + + archived: boolean("archived").notNull().default(false), + + profiles: jsonb("profiles").notNull().default([]), + + usePlanning: boolean("usePlanning").notNull().default(false), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), +}) + +export type InventoryItemGroup = typeof inventoryitemgroups.$inferSelect +export type NewInventoryItemGroup = typeof inventoryitemgroups.$inferInsert diff --git a/db/schema/inventoryitems.ts b/db/schema/inventoryitems.ts new file mode 100644 index 0000000..f3437d8 --- /dev/null +++ b/db/schema/inventoryitems.ts @@ -0,0 +1,68 @@ +import { + pgTable, + bigint, + timestamp, + text, + boolean, + doublePrecision, + uuid, + jsonb, + date, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { vendors } from "./vendors" +import { spaces } from "./spaces" +import { authUsers } from "./auth_users" + +export const inventoryitems = pgTable("inventoryitems", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + name: text("name").notNull(), + + usePlanning: boolean("usePlanning").notNull().default(false), + + description: text("description"), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + currentSpace: bigint("currentSpace", { mode: "number" }).references( + () => spaces.id + ), + + articleNumber: text("articleNumber"), + serialNumber: text("serialNumber"), + + purchaseDate: date("purchaseDate"), + + vendor: bigint("vendor", { mode: "number" }).references(() => vendors.id), + + quantity: bigint("quantity", { mode: "number" }).notNull().default(0), + + purchasePrice: doublePrecision("purchasePrice").default(0), + + manufacturer: text("manufacturer"), + manufacturerNumber: text("manufacturerNumber"), + + currentValue: doublePrecision("currentValue"), + + archived: boolean("archived").notNull().default(false), + + profiles: jsonb("profiles").notNull().default([]), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => + authUsers.id + ), +}) + +export type InventoryItem = typeof inventoryitems.$inferSelect +export type NewInventoryItem = typeof inventoryitems.$inferInsert diff --git a/db/schema/letterheads.ts b/db/schema/letterheads.ts new file mode 100644 index 0000000..2cbc534 --- /dev/null +++ b/db/schema/letterheads.ts @@ -0,0 +1,39 @@ +import { + pgTable, + bigint, + timestamp, + text, + boolean, + uuid, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" + +export const letterheads = pgTable("letterheads", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + name: text("name").default("Standard"), + + path: text("path").notNull(), + + documentTypes: text("documentTypes").array().notNull().default([]), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), + + archived: boolean("archived").notNull().default(false), +}) + +export type Letterhead = typeof letterheads.$inferSelect +export type NewLetterhead = typeof letterheads.$inferInsert diff --git a/db/schema/movements.ts b/db/schema/movements.ts new file mode 100644 index 0000000..72a2759 --- /dev/null +++ b/db/schema/movements.ts @@ -0,0 +1,49 @@ +import { + pgTable, + bigint, + timestamp, + text, + uuid, +} from "drizzle-orm/pg-core" + +import { products } from "./products" +import { spaces } from "./spaces" +import { tenants } from "./tenants" +import { projects } from "./projects" +import { authUsers } from "./auth_users" + +export const movements = pgTable("movements", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + quantity: bigint("quantity", { mode: "number" }).notNull(), + + productId: bigint("productId", { mode: "number" }) + .notNull() + .references(() => products.id), + + spaceId: bigint("spaceId", { mode: "number" }).references(() => spaces.id), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + projectId: bigint("projectId", { mode: "number" }).references( + () => projects.id + ), + + notes: text("notes"), + + serials: text("serials").array(), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), +}) + +export type Movement = typeof movements.$inferSelect +export type NewMovement = typeof movements.$inferInsert diff --git a/db/schema/notifications_event_types.ts b/db/schema/notifications_event_types.ts new file mode 100644 index 0000000..c16d648 --- /dev/null +++ b/db/schema/notifications_event_types.ts @@ -0,0 +1,34 @@ +import { + pgTable, + text, + jsonb, + boolean, + timestamp, +} from "drizzle-orm/pg-core" +import {notificationSeverityEnum} from "./enums"; + + +export const notificationsEventTypes = pgTable("notifications_event_types", { + eventKey: text("event_key").primaryKey(), + + displayName: text("display_name").notNull(), + description: text("description"), + category: text("category"), + + severity: notificationSeverityEnum("severity").notNull().default("info"), + + allowedChannels: jsonb("allowed_channels").notNull().default(["inapp", "email"]), + + payloadSchema: jsonb("payload_schema"), + + isActive: boolean("is_active").notNull().default(true), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), +}) + +export type NotificationsEventType = + typeof notificationsEventTypes.$inferSelect +export type NewNotificationsEventType = + typeof notificationsEventTypes.$inferInsert diff --git a/db/schema/notifications_items.ts b/db/schema/notifications_items.ts new file mode 100644 index 0000000..d6c6cb3 --- /dev/null +++ b/db/schema/notifications_items.ts @@ -0,0 +1,54 @@ +import { + pgTable, + uuid, + bigint, + text, + jsonb, + timestamp, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" +import { notificationsEventTypes } from "./notifications_event_types" +import {notificationChannelEnum, notificationStatusEnum} from "./enums"; + + +export const notificationsItems = pgTable("notifications_items", { + id: uuid("id").primaryKey().defaultRandom(), + + tenantId: bigint("tenant_id", { mode: "number" }) + .notNull() + .references(() => tenants.id, { onDelete: "cascade", onUpdate: "cascade" }), + + userId: uuid("user_id") + .notNull() + .references(() => authUsers.id, { onDelete: "cascade", onUpdate: "cascade" }), + + eventType: text("event_type") + .notNull() + .references(() => notificationsEventTypes.eventKey, { + onUpdate: "cascade", + onDelete: "restrict", + }), + + title: text("title").notNull(), + message: text("message").notNull(), + + payload: jsonb("payload"), + + channel: notificationChannelEnum("channel").notNull(), + + status: notificationStatusEnum("status").notNull().default("queued"), + + error: text("error"), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + sentAt: timestamp("sent_at", { withTimezone: true }), + readAt: timestamp("read_at", { withTimezone: true }), +}) + +export type NotificationItem = typeof notificationsItems.$inferSelect +export type NewNotificationItem = typeof notificationsItems.$inferInsert diff --git a/db/schema/notifications_preferences.ts b/db/schema/notifications_preferences.ts new file mode 100644 index 0000000..8397a0a --- /dev/null +++ b/db/schema/notifications_preferences.ts @@ -0,0 +1,60 @@ +import { + pgTable, + uuid, + bigint, + text, + boolean, + timestamp, + uniqueIndex, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" +import { notificationsEventTypes } from "./notifications_event_types" +import {notificationChannelEnum} from "./enums"; + +export const notificationsPreferences = pgTable( + "notifications_preferences", + { + id: uuid("id").primaryKey().defaultRandom(), + + tenantId: bigint("tenant_id", { mode: "number" }) + .notNull() + .references(() => tenants.id, { + onDelete: "cascade", + onUpdate: "cascade", + }), + + userId: uuid("user_id") + .notNull() + .references(() => authUsers.id, { + onDelete: "cascade", + onUpdate: "cascade", + }), + + eventType: text("event_type") + .notNull() + .references(() => notificationsEventTypes.eventKey, { + onDelete: "restrict", + onUpdate: "cascade", + }), + + channel: notificationChannelEnum("channel").notNull(), + + enabled: boolean("enabled").notNull().default(true), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + }, + (table) => ({ + uniquePrefs: uniqueIndex( + "notifications_preferences_tenant_id_user_id_event_type_chan_key", + ).on(table.tenantId, table.userId, table.eventType, table.channel), + }), +) + +export type NotificationPreference = + typeof notificationsPreferences.$inferSelect +export type NewNotificationPreference = + typeof notificationsPreferences.$inferInsert diff --git a/db/schema/notifications_preferences_defaults.ts b/db/schema/notifications_preferences_defaults.ts new file mode 100644 index 0000000..3c263c9 --- /dev/null +++ b/db/schema/notifications_preferences_defaults.ts @@ -0,0 +1,52 @@ +import { + pgTable, + uuid, + bigint, + text, + boolean, + timestamp, + uniqueIndex, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { notificationsEventTypes } from "./notifications_event_types" +import {notificationChannelEnum} from "./enums"; + +export const notificationsPreferencesDefaults = pgTable( + "notifications_preferences_defaults", + { + id: uuid("id").primaryKey().defaultRandom(), + + tenantId: bigint("tenant_id", { mode: "number" }) + .notNull() + .references(() => tenants.id, { + onDelete: "cascade", + onUpdate: "cascade", + }), + + eventKey: text("event_key") + .notNull() + .references(() => notificationsEventTypes.eventKey, { + onDelete: "restrict", + onUpdate: "cascade", + }), + + channel: notificationChannelEnum("channel").notNull(), + + enabled: boolean("enabled").notNull().default(true), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + }, + (table) => ({ + uniqueDefaults: uniqueIndex( + "notifications_preferences_defau_tenant_id_event_key_channel_key", + ).on(table.tenantId, table.eventKey, table.channel), + }), +) + +export type NotificationPreferenceDefault = + typeof notificationsPreferencesDefaults.$inferSelect +export type NewNotificationPreferenceDefault = + typeof notificationsPreferencesDefaults.$inferInsert diff --git a/db/schema/ownaccounts.ts b/db/schema/ownaccounts.ts new file mode 100644 index 0000000..1970adc --- /dev/null +++ b/db/schema/ownaccounts.ts @@ -0,0 +1,39 @@ +import { + pgTable, + uuid, + timestamp, + text, + boolean, + jsonb, + bigint, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" + +export const ownaccounts = pgTable("ownaccounts", { + id: uuid("id").primaryKey().defaultRandom(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + number: text("number").notNull(), + name: text("name").notNull(), + + description: text("description"), + + archived: boolean("archived").notNull().default(false), + + profiles: jsonb("profiles").notNull().default([]), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), +}) + +export type OwnAccount = typeof ownaccounts.$inferSelect +export type NewOwnAccount = typeof ownaccounts.$inferInsert diff --git a/db/schema/plants.ts b/db/schema/plants.ts new file mode 100644 index 0000000..a7b35f4 --- /dev/null +++ b/db/schema/plants.ts @@ -0,0 +1,56 @@ +import { + pgTable, + bigint, + timestamp, + text, + jsonb, + boolean, + uuid, + date, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { customers } from "./customers" +import { contracts } from "./contracts" +import { authUsers } from "./auth_users" + +export const plants = pgTable("plants", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + name: text("name").notNull(), + + customer: bigint("customer", { mode: "number" }).references( + () => customers.id + ), + + infoData: jsonb("infoData"), + contract: bigint("contract", { mode: "number" }).references( + () => contracts.id + ), + + description: jsonb("description").default({ + html: "", + json: [], + text: "", + }), + + archived: boolean("archived").notNull().default(false), + + profiles: jsonb("profiles").notNull().default([]), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), +}) + +export type Plant = typeof plants.$inferSelect +export type NewPlant = typeof plants.$inferInsert diff --git a/db/schema/productcategories.ts b/db/schema/productcategories.ts new file mode 100644 index 0000000..980a7fc --- /dev/null +++ b/db/schema/productcategories.ts @@ -0,0 +1,37 @@ +import { + pgTable, + bigint, + timestamp, + text, + boolean, + uuid, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" + +export const productcategories = pgTable("productcategories", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + name: text("name").notNull(), + + description: text("description"), + + archived: boolean("archived").notNull().default(false), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), +}) + +export type ProductCategory = typeof productcategories.$inferSelect +export type NewProductCategory = typeof productcategories.$inferInsert diff --git a/db/schema/products.ts b/db/schema/products.ts new file mode 100644 index 0000000..d070254 --- /dev/null +++ b/db/schema/products.ts @@ -0,0 +1,69 @@ +import { + pgTable, + bigint, + timestamp, + text, + doublePrecision, + boolean, + smallint, + uuid, + jsonb, + json, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { units } from "./units" +import { authUsers } from "./auth_users" + +export const products = pgTable("products", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + name: text("name").notNull(), + manufacturer: text("manufacturer"), + + unit: bigint("unit", { mode: "number" }) + .notNull() + .references(() => units.id), + + tags: json("tags").notNull().default([]), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + ean: text("ean"), + barcode: text("barcode"), + + purchase_price: doublePrecision("purchasePrice"), + selling_price: doublePrecision("sellingPrice"), + + description: text("description"), + + manufacturer_number: text("manufacturerNumber"), + + vendor_allocation: jsonb("vendorAllocation").default([]), + + article_number: text("articleNumber"), + + barcodes: text("barcodes").array().notNull().default([]), + + productcategories: jsonb("productcategories").default([]), + + archived: boolean("archived").notNull().default(false), + + tax_percentage: smallint("taxPercentage").notNull().default(19), + + markup_percentage: doublePrecision("markupPercentage"), + + updated_at: timestamp("updated_at", { withTimezone: true }), + updated_by: uuid("updated_by").references(() => authUsers.id), +}) + +export type Product = typeof products.$inferSelect +export type NewProduct = typeof products.$inferInsert diff --git a/db/schema/projects.ts b/db/schema/projects.ts new file mode 100644 index 0000000..badf583 --- /dev/null +++ b/db/schema/projects.ts @@ -0,0 +1,78 @@ +import { + pgTable, + bigint, + timestamp, + text, + jsonb, + json, + boolean, + uuid, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { customers } from "./customers" +import { contracts } from "./contracts" +import { projecttypes } from "./projecttypes" +import { authUsers } from "./auth_users" + +export const projects = pgTable("projects", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + name: text("name").notNull(), + + notes: text("notes"), + + customer: bigint("customer", { mode: "number" }).references( + () => customers.id + ), + + phases: jsonb("phases").default([]), + + description: json("description"), + + forms: jsonb("forms").default([]), + + heroId: text("heroId"), + + measure: text("measure"), + + material: jsonb("material"), + + plant: bigint("plant", { mode: "number" }), + + profiles: uuid("profiles").array().notNull().default([]), + + projectNumber: text("projectNumber"), + + contract: bigint("contract", { mode: "number" }).references( + () => contracts.id + ), + + projectType: text("projectType").default("Projekt"), + + projecttype: bigint("projecttype", { mode: "number" }).references( + () => projecttypes.id + ), + + archived: boolean("archived").notNull().default(false), + + customerRef: text("customerRef"), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), + + active_phase: text("active_phase"), +}) + +export type Project = typeof projects.$inferSelect +export type NewProject = typeof projects.$inferInsert diff --git a/db/schema/projecttypes.ts b/db/schema/projecttypes.ts new file mode 100644 index 0000000..fc7b90d --- /dev/null +++ b/db/schema/projecttypes.ts @@ -0,0 +1,41 @@ +import { + pgTable, + bigint, + timestamp, + text, + jsonb, + boolean, + uuid, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" + +export const projecttypes = pgTable("projecttypes", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + name: text("name").notNull(), + + initialPhases: jsonb("initialPhases"), + addablePhases: jsonb("addablePhases"), + + icon: text("icon"), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + archived: boolean("archived").notNull().default(false), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), +}) + +export type ProjectType = typeof projecttypes.$inferSelect +export type NewProjectType = typeof projecttypes.$inferInsert diff --git a/db/schema/public_links.ts b/db/schema/public_links.ts new file mode 100644 index 0000000..283f96b --- /dev/null +++ b/db/schema/public_links.ts @@ -0,0 +1,30 @@ +import { pgTable, text, integer, boolean, jsonb, timestamp, uuid } from 'drizzle-orm/pg-core'; +import { tenants } from './tenants'; +import { authProfiles } from './auth_profiles'; + +export const publicLinks = pgTable('public_links', { + id: uuid("id").primaryKey().defaultRandom(), + + // Der öffentliche Token (z.B. "werkstatt-tablet-01") + token: text('token').notNull().unique(), + + // Zuordnung zum Tenant (WICHTIG für die Datentrennung) + tenant: integer('tenant').references(() => tenants.id).notNull(), + + defaultProfile: uuid('default_profile').references(() => authProfiles.id), + + // Sicherheit + isProtected: boolean('is_protected').default(false).notNull(), + pinHash: text('pin_hash'), + + // Konfiguration (JSON) + config: jsonb('config').default({}), + + // Metadaten + name: text('name').notNull(), + description: text('description'), + + active: boolean('active').default(true).notNull(), + createdAt: timestamp('created_at').defaultNow(), + updatedAt: timestamp('updated_at').defaultNow(), +}); \ No newline at end of file diff --git a/db/schema/serialexecutions.ts b/db/schema/serialexecutions.ts new file mode 100644 index 0000000..c63cfb2 --- /dev/null +++ b/db/schema/serialexecutions.ts @@ -0,0 +1,21 @@ +import { + pgTable, + bigint, + timestamp, + text, + jsonb, + boolean, + uuid, +} from "drizzle-orm/pg-core" +import {tenants} from "./tenants"; + +export const serialExecutions = pgTable("serial_executions", { + id: uuid("id").primaryKey().defaultRandom(), + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), executionDate: timestamp("execution_date").notNull(), + status: text("status").default("draft"), // 'draft', 'completed' + createdBy: text("created_by"), // oder UUID, je nach Auth-System + createdAt: timestamp("created_at").defaultNow(), + summary: text("summary"), // z.B. "25 Rechnungen erstellt" +}); \ No newline at end of file diff --git a/db/schema/serialtypes.ts b/db/schema/serialtypes.ts new file mode 100644 index 0000000..6a32d3b --- /dev/null +++ b/db/schema/serialtypes.ts @@ -0,0 +1,40 @@ +import { + pgTable, + bigint, + timestamp, + text, + jsonb, + boolean, + uuid, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" + +export const serialtypes = pgTable("serialtypes", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + name: text("name").notNull(), + + intervall: text("intervall"), + + icon: text("icon"), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + archived: boolean("archived").notNull().default(false), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), +}) + +export type SerialType = typeof serialtypes.$inferSelect +export type NewSerialType = typeof serialtypes.$inferInsert diff --git a/db/schema/servicecategories.ts b/db/schema/servicecategories.ts new file mode 100644 index 0000000..f0364b5 --- /dev/null +++ b/db/schema/servicecategories.ts @@ -0,0 +1,39 @@ +import { + pgTable, + bigint, + timestamp, + text, + doublePrecision, + boolean, + uuid, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" + +export const servicecategories = pgTable("servicecategories", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + created_at: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + name: text("name").notNull(), + description: text("description"), + + discount: doublePrecision("discount").default(0), + + archived: boolean("archived").notNull().default(false), + + updated_at: timestamp("updated_at", { withTimezone: true }), + updated_by: uuid("updated_by").references(() => authUsers.id), +}) + +export type ServiceCategory = typeof servicecategories.$inferSelect +export type NewServiceCategory = typeof servicecategories.$inferInsert diff --git a/db/schema/services.ts b/db/schema/services.ts new file mode 100644 index 0000000..0dcdd4b --- /dev/null +++ b/db/schema/services.ts @@ -0,0 +1,63 @@ +import { + pgTable, + bigint, + timestamp, + text, + doublePrecision, + jsonb, + boolean, + smallint, + uuid, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { units } from "./units" +import { authUsers } from "./auth_users" + +export const services = pgTable("services", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + name: text("name").notNull(), + + sellingPrice: doublePrecision("sellingPrice"), + + description: text("description"), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + unit: bigint("unit", { mode: "number" }).references(() => units.id), + + serviceNumber: bigint("serviceNumber", { mode: "number" }), + + tags: jsonb("tags").default([]), + servicecategories: jsonb("servicecategories").notNull().default([]), + + archived: boolean("archived").notNull().default(false), + + purchasePriceComposed: jsonb("purchasePriceComposed") + .notNull() + .default({ total: 0 }), + + sellingPriceComposed: jsonb("sellingPriceComposed") + .notNull() + .default({ total: 0 }), + + taxPercentage: smallint("taxPercentage").notNull().default(19), + + materialComposition: jsonb("materialComposition").notNull().default([]), + personalComposition: jsonb("personalComposition").notNull().default([]), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), +}) + +export type Service = typeof services.$inferSelect +export type NewService = typeof services.$inferInsert diff --git a/db/schema/spaces.ts b/db/schema/spaces.ts new file mode 100644 index 0000000..7b8ce0d --- /dev/null +++ b/db/schema/spaces.ts @@ -0,0 +1,49 @@ +import { + pgTable, + bigint, + timestamp, + text, + boolean, + jsonb, + uuid, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" + +export const spaces = pgTable("spaces", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + name: text("name"), + type: text("type").notNull(), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + space_number: text("spaceNumber").notNull(), + + parentSpace: bigint("parentSpace", { mode: "number" }).references( + () => spaces.id + ), + + info_data: jsonb("infoData") + .notNull() + .default({ zip: "", city: "", streetNumber: "" }), + + description: text("description"), + + archived: boolean("archived").notNull().default(false), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), +}) + +export type Space = typeof spaces.$inferSelect +export type NewSpace = typeof spaces.$inferInsert diff --git a/db/schema/staff_time_entries.ts b/db/schema/staff_time_entries.ts new file mode 100644 index 0000000..5159aa0 --- /dev/null +++ b/db/schema/staff_time_entries.ts @@ -0,0 +1,68 @@ +import { + pgTable, + uuid, + bigint, + timestamp, + integer, + text, + boolean, + numeric, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" +import { timesStateEnum } from "./enums" +import {sql} from "drizzle-orm"; + +export const stafftimeentries = pgTable("staff_time_entries", { + id: uuid("id").primaryKey().defaultRandom(), + + tenant_id: bigint("tenant_id", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + user_id: uuid("user_id") + .notNull() + .references(() => authUsers.id, { onDelete: "cascade" }), + + started_at: timestamp("started_at", { withTimezone: true }).notNull(), + stopped_at: timestamp("stopped_at", { withTimezone: true }), + + duration_minutes: integer("duration_minutes").generatedAlwaysAs( + sql`CASE + WHEN stopped_at IS NOT NULL + THEN (EXTRACT(epoch FROM (stopped_at - started_at)) / 60) + ELSE NULL + END` + ), + + type: text("type").default("work"), + + description: text("description"), + + created_at: timestamp("created_at", { withTimezone: true }).defaultNow(), + updated_at: timestamp("updated_at", { withTimezone: true }).defaultNow(), + + archived: boolean("archived").notNull().default(false), + + updated_by: uuid("updated_by").references(() => authUsers.id), + + source: text("source"), + + state: timesStateEnum("state").notNull().default("draft"), + + device: uuid("device"), + + internal_note: text("internal_note"), + + vacation_reason: text("vacation_reason"), + vacation_days: numeric("vacation_days", { precision: 5, scale: 2 }), + + approved_by: uuid("approved_by").references(() => authUsers.id), + approved_at: timestamp("approved_at", { withTimezone: true }), + + sick_reason: text("sick_reason"), +}) + +export type StaffTimeEntry = typeof stafftimeentries.$inferSelect +export type NewStaffTimeEntry = typeof stafftimeentries.$inferInsert diff --git a/db/schema/staff_time_entry_connects.ts b/db/schema/staff_time_entry_connects.ts new file mode 100644 index 0000000..dbdd3a3 --- /dev/null +++ b/db/schema/staff_time_entry_connects.ts @@ -0,0 +1,38 @@ +import { + pgTable, + uuid, + bigint, + timestamp, + integer, + text, +} from "drizzle-orm/pg-core" + +import { stafftimeentries } from "./staff_time_entries" +import {sql} from "drizzle-orm"; + +export const stafftimenetryconnects = pgTable("staff_time_entry_connects", { + id: uuid("id").primaryKey().defaultRandom(), + + stafftimeentry: uuid("time_entry_id") + .notNull() + .references(() => stafftimeentries.id, { onDelete: "cascade" }), + + project_id: bigint("project_id", { mode: "number" }), // referenziert später projects.id + + started_at: timestamp("started_at", { withTimezone: true }).notNull(), + stopped_at: timestamp("stopped_at", { withTimezone: true }).notNull(), + + durationMinutes: integer("duration_minutes").generatedAlwaysAs( + sql`(EXTRACT(epoch FROM (stopped_at - started_at)) / 60)` + ), + + notes: text("notes"), + + created_at: timestamp("created_at", { withTimezone: true }).defaultNow(), + updated_at: timestamp("updated_at", { withTimezone: true }).defaultNow(), +}) + +export type StaffTimeEntryConnect = + typeof stafftimenetryconnects.$inferSelect +export type NewStaffTimeEntryConnect = + typeof stafftimenetryconnects.$inferInsert diff --git a/db/schema/staff_time_events.ts b/db/schema/staff_time_events.ts new file mode 100644 index 0000000..d58f77c --- /dev/null +++ b/db/schema/staff_time_events.ts @@ -0,0 +1,85 @@ +import { + pgTable, + uuid, + bigint, + text, + timestamp, + jsonb, + index, + check, +} from "drizzle-orm/pg-core"; +import { sql } from "drizzle-orm"; +import {tenants} from "./tenants"; +import {authUsers} from "./auth_users"; + +export const stafftimeevents = pgTable( + "staff_time_events", + { + id: uuid("id").primaryKey().defaultRandom(), + + tenant_id: bigint("tenant_id", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + user_id: uuid("user_id") + .notNull() + .references(() => authUsers.id), + + // Akteur + actortype: text("actor_type").notNull(), // 'user' | 'system' + actoruser_id: uuid("actor_user_id").references(() => authUsers.id), + + // Zeit + eventtime: timestamp("event_time", { + withTimezone: true, + }).notNull(), + + // Fachliche Bedeutung + eventtype: text("event_type").notNull(), + + // Quelle + source: text("source").notNull(), // web | mobile | terminal | system + + // Entkräftung + invalidates_event_id: uuid("invalidates_event_id") + .references(() => stafftimeevents.id), + + //Beziehung Approval etc + related_event_id: uuid("related_event_id") + .references(() => stafftimeevents.id), + + // Zusatzdaten + metadata: jsonb("metadata"), + + // Technisch + created_at: timestamp("created_at", { + withTimezone: true, + }) + .defaultNow() + .notNull(), + }, + (table) => ({ + // Indizes + tenantUserTimeIdx: index("idx_time_events_tenant_user_time").on( + table.tenant_id, + table.user_id, + table.eventtime + ), + + createdAtIdx: index("idx_time_events_created_at").on(table.created_at), + + invalidatesIdx: index("idx_time_events_invalidates").on( + table.invalidates_event_id + ), + + // Constraints + actorUserCheck: check( + "time_events_actor_user_check", + sql` + (actor_type = 'system' AND actor_user_id IS NULL) + OR + (actor_type = 'user' AND actor_user_id IS NOT NULL) + ` + ), + }) +); diff --git a/db/schema/staff_zeitstromtimestamps.ts b/db/schema/staff_zeitstromtimestamps.ts new file mode 100644 index 0000000..174e843 --- /dev/null +++ b/db/schema/staff_zeitstromtimestamps.ts @@ -0,0 +1,44 @@ +import { + pgTable, + uuid, + timestamp, + bigint, + text, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { authProfiles } from "./auth_profiles" +import { stafftimeentries } from "./staff_time_entries" + +export const staffZeitstromTimestamps = pgTable("staff_zeitstromtimestamps", { + id: uuid("id").primaryKey().defaultRandom(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + profile: uuid("profile") + .notNull() + .references(() => authProfiles.id), + + key: text("key").notNull(), + + intent: text("intent").notNull(), + + time: timestamp("time", { withTimezone: true }).notNull(), + + staffTimeEntry: uuid("staff_time_entry").references( + () => stafftimeentries.id + ), + + internalNote: text("internal_note"), +}) + +export type StaffZeitstromTimestamp = + typeof staffZeitstromTimestamps.$inferSelect +export type NewStaffZeitstromTimestamp = + typeof staffZeitstromTimestamps.$inferInsert diff --git a/db/schema/statementallocations.ts b/db/schema/statementallocations.ts new file mode 100644 index 0000000..c0db9bc --- /dev/null +++ b/db/schema/statementallocations.ts @@ -0,0 +1,69 @@ +import { + pgTable, + uuid, + bigint, + integer, + text, + timestamp, + boolean, + doublePrecision, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" +import { customers } from "./customers" +import { vendors } from "./vendors" +import { ownaccounts } from "./ownaccounts" +import { incominginvoices } from "./incominginvoices" +import { createddocuments } from "./createddocuments" +import { bankstatements } from "./bankstatements" +import { accounts } from "./accounts" // Falls noch nicht erstellt → bitte melden! + +export const statementallocations = pgTable("statementallocations", { + id: uuid("id").primaryKey().defaultRandom(), + + // foreign keys + bankstatement: integer("bs_id") + .notNull() + .references(() => bankstatements.id), + + createddocument: integer("cd_id").references(() => createddocuments.id), + + amount: doublePrecision("amount").notNull().default(0), + + incominginvoice: bigint("ii_id", { mode: "number" }).references( + () => incominginvoices.id + ), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + account: bigint("account", { mode: "number" }).references( + () => accounts.id + ), + + created_at: timestamp("created_at", { + withTimezone: false, + }).defaultNow(), + + ownaccount: uuid("ownaccount").references(() => ownaccounts.id), + + description: text("description"), + + customer: bigint("customer", { mode: "number" }).references( + () => customers.id + ), + + vendor: bigint("vendor", { mode: "number" }).references(() => vendors.id), + + updated_at: timestamp("updated_at", { withTimezone: true }), + + updated_by: uuid("updated_by").references(() => authUsers.id), + + archived: boolean("archived").notNull().default(false), +}) + +export type StatementAllocation = typeof statementallocations.$inferSelect +export type NewStatementAllocation = + typeof statementallocations.$inferInsert diff --git a/db/schema/tasks.ts b/db/schema/tasks.ts new file mode 100644 index 0000000..aa40617 --- /dev/null +++ b/db/schema/tasks.ts @@ -0,0 +1,51 @@ +import { + pgTable, + bigint, + text, + timestamp, + boolean, + jsonb, + uuid, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" +import { customers } from "./customers" + +export const tasks = pgTable("tasks", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + name: text("name").notNull(), + description: text("description"), + categorie: text("categorie"), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + // FIXED: user_id statt profile, verweist auf auth_users.id + userId: uuid("user_id").references(() => authUsers.id), + + project: bigint("project", { mode: "number" }), + plant: bigint("plant", { mode: "number" }), + + customer: bigint("customer", { mode: "number" }).references( + () => customers.id + ), + + profiles: jsonb("profiles").notNull().default([]), + + archived: boolean("archived").notNull().default(false), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), +}) + +export type Task = typeof tasks.$inferSelect +export type NewTask = typeof tasks.$inferInsert diff --git a/db/schema/taxtypes.ts b/db/schema/taxtypes.ts new file mode 100644 index 0000000..5d3c45d --- /dev/null +++ b/db/schema/taxtypes.ts @@ -0,0 +1,28 @@ +import { + pgTable, + bigint, + timestamp, + text, + uuid, +} from "drizzle-orm/pg-core" + +import { authUsers } from "./auth_users" + +export const taxTypes = pgTable("taxtypes", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + label: text("label").notNull(), + percentage: bigint("percentage", { mode: "number" }).notNull(), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), +}) + +export type TaxType = typeof taxTypes.$inferSelect +export type NewTaxType = typeof taxTypes.$inferInsert diff --git a/db/schema/tenants.ts b/db/schema/tenants.ts new file mode 100644 index 0000000..b798aab --- /dev/null +++ b/db/schema/tenants.ts @@ -0,0 +1,140 @@ +import { + pgTable, + bigint, + text, + timestamp, + boolean, + jsonb, + integer, + smallint, + date, + uuid, + pgEnum, +} from "drizzle-orm/pg-core" +import { authUsers } from "./auth_users" +import {lockedTenantEnum} from "./enums"; + +export const tenants = pgTable( + "tenants", + { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + name: text("name").notNull(), + short: text("short").notNull(), + + calendarConfig: jsonb("calendarConfig").default({ + eventTypes: [ + { color: "blue", label: "Büro" }, + { color: "yellow", label: "Besprechung" }, + { color: "green", label: "Umsetzung" }, + { color: "red", label: "Vor Ort Termin" }, + ], + }), + + timeConfig: jsonb("timeConfig").notNull().default({}), + + tags: jsonb("tags").notNull().default({ + products: [], + documents: [], + }), + + measures: jsonb("measures") + .notNull() + .default([ + { name: "Netzwerktechnik", short: "NWT" }, + { name: "Elektrotechnik", short: "ELT" }, + { name: "Photovoltaik", short: "PV" }, + { name: "Videüberwachung", short: "VÜA" }, + { name: "Projekt", short: "PRJ" }, + { name: "Smart Home", short: "SHO" }, + ]), + + businessInfo: jsonb("businessInfo").default({ + zip: "", + city: "", + name: "", + street: "", + }), + + features: jsonb("features").default({ + objects: true, + calendar: true, + contacts: true, + projects: true, + vehicles: true, + contracts: true, + inventory: true, + accounting: true, + timeTracking: true, + planningBoard: true, + workingTimeTracking: true, + }), + + ownFields: jsonb("ownFields"), + + numberRanges: jsonb("numberRanges") + .notNull() + .default({ + vendors: { prefix: "", suffix: "", nextNumber: 10000 }, + customers: { prefix: "", suffix: "", nextNumber: 10000 }, + products: { prefix: "AT-", suffix: "", nextNumber: 1000 }, + quotes: { prefix: "AN-", suffix: "", nextNumber: 1000 }, + confirmationOrders: { prefix: "AB-", suffix: "", nextNumber: 1000 }, + invoices: { prefix: "RE-", suffix: "", nextNumber: 1000 }, + spaces: { prefix: "LP-", suffix: "", nextNumber: 1000 }, + inventoryitems: { prefix: "IA-", suffix: "", nextNumber: 1000 }, + projects: { prefix: "PRJ-", suffix: "", nextNumber: 1000 }, + costcentres: { prefix: "KST-", suffix: "", nextNumber: 1000 }, + }), + + standardEmailForInvoices: text("standardEmailForInvoices"), + + extraModules: jsonb("extraModules").notNull().default([]), + + isInTrial: boolean("isInTrial").default(false), + trialEndDate: date("trialEndDate"), + + stripeCustomerId: text("stripeCustomerId"), + + hasActiveLicense: boolean("hasActiveLicense").notNull().default(false), + + userLicenseCount: integer("userLicenseCount") + .notNull() + .default(0), + + workstationLicenseCount: integer("workstationLicenseCount") + .notNull() + .default(0), + + standardPaymentDays: smallint("standardPaymentDays") + .notNull() + .default(14), + + dokuboxEmailAddresses: jsonb("dokuboxEmailAddresses").default([]), + + dokuboxkey: uuid("dokuboxkey").notNull().defaultRandom(), + + autoPrepareIncomingInvoices: boolean("autoPrepareIncomingInvoices") + .default(true), + + portalDomain: text("portalDomain"), + + portalConfig: jsonb("portalConfig") + .notNull() + .default({ primayColor: "#69c350" }), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), + + locked: lockedTenantEnum("locked"), + } +) + +export type Tenant = typeof tenants.$inferSelect +export type NewTenant = typeof tenants.$inferInsert diff --git a/db/schema/texttemplates.ts b/db/schema/texttemplates.ts new file mode 100644 index 0000000..baddc0d --- /dev/null +++ b/db/schema/texttemplates.ts @@ -0,0 +1,44 @@ +import { + pgTable, + bigint, + text, + timestamp, + boolean, + jsonb, + uuid, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" +import { textTemplatePositionsEnum } from "./enums" + +export const texttemplates = pgTable("texttemplates", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + name: text("name").notNull(), + text: text("text").notNull(), + + documentType: text("documentType").default(""), + + default: boolean("default").notNull().default(false), + + pos: textTemplatePositionsEnum("pos").notNull(), + + archived: boolean("archived").notNull().default(false), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), +}) + +export type TextTemplate = typeof texttemplates.$inferSelect +export type NewTextTemplate = typeof texttemplates.$inferInsert diff --git a/db/schema/units.ts b/db/schema/units.ts new file mode 100644 index 0000000..61e5e11 --- /dev/null +++ b/db/schema/units.ts @@ -0,0 +1,27 @@ +import { + pgTable, + bigint, + timestamp, + text, +} from "drizzle-orm/pg-core" + +export const units = pgTable("units", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + name: text("name").notNull(), + single: text("single").notNull(), + + multiple: text("multiple"), + short: text("short"), + + step: text("step").notNull().default("1"), +}) + +export type Unit = typeof units.$inferSelect +export type NewUnit = typeof units.$inferInsert diff --git a/db/schema/user_credentials.ts b/db/schema/user_credentials.ts new file mode 100644 index 0000000..f1ae045 --- /dev/null +++ b/db/schema/user_credentials.ts @@ -0,0 +1,53 @@ +import { + pgTable, + uuid, + timestamp, + bigint, + boolean, + jsonb, + numeric, pgEnum, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" +import {credentialTypesEnum} from "./enums"; + + + +export const userCredentials = pgTable("user_credentials", { + id: uuid("id").primaryKey().defaultRandom(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + userId: uuid("user_id") + .notNull() + .references(() => authUsers.id), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + + tenantId: bigint("tenant_id", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + smtpPort: numeric("smtp_port"), + smtpSsl: boolean("smtp_ssl"), + + type: credentialTypesEnum("type").notNull(), + + imapPort: numeric("imap_port"), + imapSsl: boolean("imap_ssl"), + + emailEncrypted: jsonb("email_encrypted"), + passwordEncrypted: jsonb("password_encrypted"), + + smtpHostEncrypted: jsonb("smtp_host_encrypted"), + imapHostEncrypted: jsonb("imap_host_encrypted"), + + accessTokenEncrypted: jsonb("access_token_encrypted"), + refreshTokenEncrypted: jsonb("refresh_token_encrypted"), +}) + +export type UserCredential = typeof userCredentials.$inferSelect +export type NewUserCredential = typeof userCredentials.$inferInsert diff --git a/db/schema/vehicles.ts b/db/schema/vehicles.ts new file mode 100644 index 0000000..30a6553 --- /dev/null +++ b/db/schema/vehicles.ts @@ -0,0 +1,57 @@ +import { + pgTable, + bigint, + text, + timestamp, + boolean, + jsonb, + uuid, + doublePrecision, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" + +export const vehicles = pgTable("vehicles", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + created_at: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + license_plate: text("licensePlate"), + name: text("name"), + type: text("type"), + + active: boolean("active").default(true), + + // FIXED: driver references auth_users.id + driver: uuid("driver").references(() => authUsers.id), + + vin: text("vin"), + + tank_size: doublePrecision("tankSize").notNull().default(0), + + archived: boolean("archived").notNull().default(false), + + build_year: text("buildYear"), + + towing_capacity: bigint("towingCapacity", { mode: "number" }), + power_in_kw: bigint("powerInKW", { mode: "number" }), + + color: text("color"), + + profiles: jsonb("profiles").notNull().default([]), + + updated_at: timestamp("updated_at", { withTimezone: true }), + updated_by: uuid("updated_by").references(() => authUsers.id), +}) + +export type Vehicle = typeof vehicles.$inferSelect +export type NewVehicle = typeof vehicles.$inferInsert diff --git a/db/schema/vendors.ts b/db/schema/vendors.ts new file mode 100644 index 0000000..32ae94f --- /dev/null +++ b/db/schema/vendors.ts @@ -0,0 +1,45 @@ +import { + pgTable, + bigint, + text, + timestamp, + boolean, + jsonb, + uuid, +} from "drizzle-orm/pg-core" + +import { tenants } from "./tenants" +import { authUsers } from "./auth_users" + +export const vendors = pgTable("vendors", { + id: bigint("id", { mode: "number" }) + .primaryKey() + .generatedByDefaultAsIdentity(), + + createdAt: timestamp("created_at", { withTimezone: true }) + .notNull() + .defaultNow(), + + name: text("name").notNull(), + vendorNumber: text("vendorNumber").notNull(), + + tenant: bigint("tenant", { mode: "number" }) + .notNull() + .references(() => tenants.id), + + infoData: jsonb("infoData").notNull().default({}), + notes: text("notes"), + + hasSEPA: boolean("hasSEPA").notNull().default(false), + + profiles: jsonb("profiles").notNull().default([]), + archived: boolean("archived").notNull().default(false), + + defaultPaymentMethod: text("defaultPaymentMethod"), + + updatedAt: timestamp("updated_at", { withTimezone: true }), + updatedBy: uuid("updated_by").references(() => authUsers.id), +}) + +export type Vendor = typeof vendors.$inferSelect +export type NewVendor = typeof vendors.$inferInsert diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c6a115c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +services: + backend: + image: reg.federspiel.software/fedeo/backend:main + restart: always + + environment: + diff --git a/drizzle.config.ts b/drizzle.config.ts new file mode 100644 index 0000000..d2b0225 --- /dev/null +++ b/drizzle.config.ts @@ -0,0 +1,11 @@ +import { defineConfig } from "drizzle-kit" +import {secrets} from "./src/utils/secrets"; + +export default defineConfig({ + dialect: "postgresql", + schema: "./db/schema", + out: "./db/migrations", + dbCredentials: { + url: secrets.DATABASE_URL || process.env.DATABASE_URL, + }, +}) \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..6b2b772 --- /dev/null +++ b/package.json @@ -0,0 +1,64 @@ +{ + "name": "backend", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "dev": "tsx watch src/index.ts", + "build": "tsc", + "start": "node dist/src/index.js", + "schema:index": "ts-node scripts/generate-schema-index.ts" + }, + "repository": { + "type": "git", + "url": "https://git.federspiel.software/fedeo/backend.git" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "@aws-sdk/client-s3": "^3.879.0", + "@aws-sdk/s3-request-presigner": "^3.879.0", + "@fastify/cookie": "^11.0.2", + "@fastify/cors": "^11.1.0", + "@fastify/multipart": "^9.0.3", + "@fastify/swagger": "^9.5.1", + "@fastify/swagger-ui": "^5.2.3", + "@infisical/sdk": "^4.0.6", + "@mmote/niimbluelib": "^0.0.1-alpha.29", + "@prisma/client": "^6.15.0", + "@supabase/supabase-js": "^2.56.1", + "@zip.js/zip.js": "^2.7.73", + "archiver": "^7.0.1", + "axios": "^1.12.1", + "bcrypt": "^6.0.0", + "bwip-js": "^4.8.0", + "crypto": "^1.0.1", + "dayjs": "^1.11.18", + "drizzle-orm": "^0.45.0", + "fastify": "^5.5.0", + "fastify-plugin": "^5.0.1", + "handlebars": "^4.7.8", + "imapflow": "^1.1.1", + "jsonwebtoken": "^9.0.2", + "mailparser": "^3.9.0", + "nodemailer": "^7.0.6", + "openai": "^6.10.0", + "pdf-lib": "^1.17.1", + "pg": "^8.16.3", + "pngjs": "^7.0.0", + "sharp": "^0.34.5", + "xmlbuilder": "^15.1.1", + "zpl-image": "^0.2.0", + "zpl-renderer-js": "^2.0.2" + }, + "devDependencies": { + "@types/bcrypt": "^6.0.0", + "@types/jsonwebtoken": "^9.0.10", + "@types/node": "^24.3.0", + "drizzle-kit": "^0.31.8", + "prisma": "^6.15.0", + "tsx": "^4.20.5", + "typescript": "^5.9.2" + } +} diff --git a/scripts/generate-schema-index.ts b/scripts/generate-schema-index.ts new file mode 100644 index 0000000..a7e6c29 --- /dev/null +++ b/scripts/generate-schema-index.ts @@ -0,0 +1,16 @@ +import fs from "node:fs" +import path from "node:path" + +const schemaDir = path.resolve("db/schema") +const indexFile = path.join(schemaDir, "index.ts") + +const files = fs + .readdirSync(schemaDir) + .filter((f) => f.endsWith(".ts") && f !== "index.ts") + +const exportsToWrite = files + .map((f) => `export * from "./${f.replace(".ts", "")}"`) + .join("\n") + +fs.writeFileSync(indexFile, exportsToWrite) +console.log("✓ schema/index.ts generated") \ No newline at end of file diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..d4155be --- /dev/null +++ b/src/index.ts @@ -0,0 +1,166 @@ +import Fastify from "fastify"; +import swaggerPlugin from "./plugins/swagger" +import supabasePlugin from "./plugins/supabase"; +import dayjsPlugin from "./plugins/dayjs"; +import healthRoutes from "./routes/health"; +import meRoutes from "./routes/auth/me"; +import tenantRoutes from "./routes/tenant"; +import tenantPlugin from "./plugins/tenant"; +import authRoutes from "./routes/auth/auth"; +import authRoutesAuthenticated from "./routes/auth/auth-authenticated"; +import authPlugin from "./plugins/auth"; +import adminRoutes from "./routes/admin"; +import corsPlugin from "./plugins/cors"; +import queryConfigPlugin from "./plugins/queryconfig"; +import dbPlugin from "./plugins/db"; +import resourceRoutesSpecial from "./routes/resourcesSpecial"; +import fastifyCookie from "@fastify/cookie"; +import historyRoutes from "./routes/history"; +import fileRoutes from "./routes/files"; +import functionRoutes from "./routes/functions"; +import bankingRoutes from "./routes/banking"; +import exportRoutes from "./routes/exports" +import emailAsUserRoutes from "./routes/emailAsUser"; +import authProfilesRoutes from "./routes/profiles"; +import helpdeskRoutes from "./routes/helpdesk"; +import helpdeskInboundRoutes from "./routes/helpdesk.inbound"; +import notificationsRoutes from "./routes/notifications"; +import staffTimeRoutes from "./routes/staff/time"; +import staffTimeConnectRoutes from "./routes/staff/timeconnects"; +import userRoutes from "./routes/auth/user"; +import publiclinksAuthenticatedRoutes from "./routes/publiclinks/publiclinks-authenticated"; + +//Public Links +import publiclinksNonAuthenticatedRoutes from "./routes/publiclinks/publiclinks-non-authenticated"; + +//Resources +import resourceRoutes from "./routes/resources/main"; + +//M2M +import authM2m from "./plugins/auth.m2m"; +import helpdeskInboundEmailRoutes from "./routes/helpdesk.inbound.email"; +import deviceRoutes from "./routes/internal/devices"; +import tenantRoutesInternal from "./routes/internal/tenant"; +import staffTimeRoutesInternal from "./routes/internal/time"; + +//Devices +import devicesRFIDRoutes from "./routes/devices/rfid"; + + +import {sendMail} from "./utils/mailer"; +import {loadSecrets, secrets} from "./utils/secrets"; +import {initMailer} from "./utils/mailer" +import {initS3} from "./utils/s3"; + +//Services +import servicesPlugin from "./plugins/services"; + +async function main() { + const app = Fastify({ logger: false }); + await loadSecrets(); + await initMailer(); + await initS3(); + + + + /*app.addHook("onRequest", (req, reply, done) => { + console.log("Incoming:", req.method, req.url, "Headers:", req.headers) + done() + })*/ + + // Plugins Global verfügbar + await app.register(swaggerPlugin); + await app.register(corsPlugin); + await app.register(supabasePlugin); + await app.register(tenantPlugin); + await app.register(dayjsPlugin); + await app.register(dbPlugin); + await app.register(servicesPlugin); + + app.addHook('preHandler', (req, reply, done) => { + console.log(req.method) + console.log('Matched path:', req.routeOptions.url) + console.log('Exact URL:', req.url) + done() + }) + + app.get('/health', async (req, res) => { + return res.send({ status: 'ok' }) + }) + + //Plugin nur auf bestimmten Routes + await app.register(queryConfigPlugin, { + routes: ['/api/resource/:resource/paginated'] + }) + + app.register(fastifyCookie, { + secret: secrets.COOKIE_SECRET, + }) + // Öffentliche Routes + await app.register(authRoutes); + await app.register(healthRoutes); + + await app.register(helpdeskInboundRoutes); + + await app.register(publiclinksNonAuthenticatedRoutes) + + + await app.register(async (m2mApp) => { + await m2mApp.register(authM2m) + await m2mApp.register(helpdeskInboundEmailRoutes) + await m2mApp.register(deviceRoutes) + await m2mApp.register(tenantRoutesInternal) + await m2mApp.register(staffTimeRoutesInternal) + },{prefix: "/internal"}) + + await app.register(async (devicesApp) => { + await devicesApp.register(devicesRFIDRoutes) + },{prefix: "/devices"}) + + + //Geschützte Routes + + await app.register(async (subApp) => { + await subApp.register(authPlugin); + await subApp.register(authRoutesAuthenticated); + await subApp.register(meRoutes); + await subApp.register(tenantRoutes); + await subApp.register(adminRoutes); + await subApp.register(resourceRoutesSpecial); + await subApp.register(historyRoutes); + await subApp.register(fileRoutes); + await subApp.register(functionRoutes); + await subApp.register(bankingRoutes); + await subApp.register(exportRoutes); + await subApp.register(emailAsUserRoutes); + await subApp.register(authProfilesRoutes); + await subApp.register(helpdeskRoutes); + await subApp.register(notificationsRoutes); + await subApp.register(staffTimeRoutes); + await subApp.register(staffTimeConnectRoutes); + await subApp.register(userRoutes); + await subApp.register(publiclinksAuthenticatedRoutes); + await subApp.register(resourceRoutes); + + },{prefix: "/api"}) + + app.ready(async () => { + try { + const result = await app.db.execute("SELECT NOW()"); + console.log("✓ DB connection OK: " + JSON.stringify(result.rows[0])); + } catch (err) { + console.log("❌ DB connection failed:", err); + } + }); + + // Start + try { + await app.listen({ port: secrets.PORT, host: secrets.HOST }); + console.log(`🚀 Server läuft auf http://${secrets.HOST}:${secrets.PORT}`); + } catch (err) { + app.log.error(err); + process.exit(1); + } +} + +main(); \ No newline at end of file diff --git a/src/modules/cron/bankstatementsync.service.ts b/src/modules/cron/bankstatementsync.service.ts new file mode 100644 index 0000000..66863b0 --- /dev/null +++ b/src/modules/cron/bankstatementsync.service.ts @@ -0,0 +1,253 @@ +// /services/bankStatementService.ts +import axios from "axios" +import dayjs from "dayjs" +import utc from "dayjs/plugin/utc.js" +import {secrets} from "../../utils/secrets" +import {FastifyInstance} from "fastify" + +// Drizzle imports +import { + bankaccounts, + bankstatements, +} from "../../../db/schema" + +import { + eq, + and, + isNull, +} from "drizzle-orm" + +dayjs.extend(utc) + +interface BalanceAmount { + amount: string + currency: string +} + +interface BookedTransaction { + bookingDate: string + valueDate: string + internalTransactionId: string + transactionAmount: { amount: string; currency: string } + + creditorAccount?: { iban?: string } + creditorName?: string + + debtorAccount?: { iban?: string } + debtorName?: string + + remittanceInformationUnstructured?: string + remittanceInformationStructured?: string + remittanceInformationStructuredArray?: string[] + additionalInformation?: string +} + +interface TransactionsResponse { + transactions: { + booked: BookedTransaction[] + } +} + +const normalizeDate = (val: any) => { + if (!val) return null + const d = new Date(val) + return isNaN(d.getTime()) ? null : d +} + +export function bankStatementService(server: FastifyInstance) { + + let accessToken: string | null = null + + // ----------------------------------------------- + // ✔ TOKEN LADEN + // ----------------------------------------------- + const getToken = async () => { + console.log("Fetching GoCardless token…") + + const response = await axios.post( + `${secrets.GOCARDLESS_BASE_URL}/token/new/`, + { + secret_id: secrets.GOCARDLESS_SECRET_ID, + secret_key: secrets.GOCARDLESS_SECRET_KEY, + } + ) + + accessToken = response.data.access + } + + // ----------------------------------------------- + // ✔ Salden laden + // ----------------------------------------------- + const getBalanceData = async (accountId: string): Promise${this.nl2br(this.escapeHtml(message))}
+Automatisch generiert von FEDEO
+Hallo,
+Dein Passwort wurde zurückgesetzt.
+Neues Passwort: ${plainPassword}
+Bitte ändere es nach dem Login umgehend.
+ ` + ); + + return { success: true }; + }); +} diff --git a/src/routes/auth/me.ts b/src/routes/auth/me.ts new file mode 100644 index 0000000..fffb793 --- /dev/null +++ b/src/routes/auth/me.ts @@ -0,0 +1,140 @@ +import { FastifyInstance } from "fastify" +import { + authUsers, + authTenantUsers, + tenants, + authProfiles, + authUserRoles, + authRoles, + authRolePermissions, +} from "../../../db/schema" +import { eq, and, or, isNull } from "drizzle-orm" + +export default async function meRoutes(server: FastifyInstance) { + server.get("/me", async (req, reply) => { + try { + const authUser = req.user + + if (!authUser) { + return reply.code(401).send({ error: "Unauthorized" }) + } + + const userId = authUser.user_id + const activeTenantId = authUser.tenant_id + + // ---------------------------------------------------- + // 1) USER LADEN + // ---------------------------------------------------- + const userResult = await server.db + .select({ + id: authUsers.id, + email: authUsers.email, + created_at: authUsers.created_at, + must_change_password: authUsers.must_change_password, + }) + .from(authUsers) + .where(eq(authUsers.id, userId)) + .limit(1) + + const user = userResult[0] + + if (!user) { + return reply.code(401).send({ error: "User not found" }) + } + + // ---------------------------------------------------- + // 2) TENANTS LADEN + // ---------------------------------------------------- + const tenantRows = await server.db + .select({ + id: tenants.id, + name: tenants.name, + short: tenants.short, + locked: tenants.locked, + extraModules: tenants.extraModules, + businessInfo: tenants.businessInfo, + numberRanges: tenants.numberRanges, + dokuboxkey: tenants.dokuboxkey, + standardEmailForInvoices: tenants.standardEmailForInvoices, + standardPaymentDays: tenants.standardPaymentDays, + }) + .from(authTenantUsers) + .innerJoin(tenants, eq(authTenantUsers.tenant_id, tenants.id)) + .where(eq(authTenantUsers.user_id, userId)) + + const tenantList = tenantRows ?? [] + + // ---------------------------------------------------- + // 3) ACTIVE TENANT + // ---------------------------------------------------- + const activeTenant = activeTenantId + + // ---------------------------------------------------- + // 4) PROFIL LADEN + // ---------------------------------------------------- + let profile = null + if (activeTenantId) { + const profileResult = await server.db + .select() + .from(authProfiles) + .where( + and( + eq(authProfiles.user_id, userId), + eq(authProfiles.tenant_id, activeTenantId) + ) + ) + .limit(1) + + profile = profileResult?.[0] ?? null + } + + // ---------------------------------------------------- + // 5) PERMISSIONS — RPC ERSETZT + // ---------------------------------------------------- + const permissionRows = + (await server.db + .select({ + permission: authRolePermissions.permission, + }) + .from(authUserRoles) + .innerJoin( + authRoles, + and( + eq(authRoles.id, authUserRoles.role_id), + or( + isNull(authRoles.tenant_id), // globale Rolle + eq(authRoles.tenant_id, activeTenantId) // tenant-spezifische Rolle + ) + ) + ) + .innerJoin( + authRolePermissions, + eq(authRolePermissions.role_id, authRoles.id) + ) + .where( + and( + eq(authUserRoles.user_id, userId), + eq(authUserRoles.tenant_id, activeTenantId) + ) + )) ?? [] + + const permissions = Array.from( + new Set(permissionRows.map((p) => p.permission)) + ) + + // ---------------------------------------------------- + // RESPONSE + // ---------------------------------------------------- + return { + user, + tenants: tenantList, + activeTenant, + profile, + permissions, + } + } catch (err: any) { + console.error("ERROR in /me route:", err) + return reply.code(500).send({ error: "Internal server error" }) + } + }) +} diff --git a/src/routes/auth/user.ts b/src/routes/auth/user.ts new file mode 100644 index 0000000..fde299a --- /dev/null +++ b/src/routes/auth/user.ts @@ -0,0 +1,129 @@ +import { FastifyInstance } from "fastify" +import { eq, and } from "drizzle-orm" + +import { + authUsers, + authProfiles, +} from "../../../db/schema" + +export default async function userRoutes(server: FastifyInstance) { + + // ------------------------------------------------------------- + // GET /user/:id + // ------------------------------------------------------------- + server.get("/user/:id", async (req, reply) => { + try { + const authUser = req.user + const { id } = req.params as { id: string } + + if (!authUser) { + return reply.code(401).send({ error: "Unauthorized" }) + } + + // 1️⃣ User laden + const [user] = await server.db + .select({ + id: authUsers.id, + email: authUsers.email, + created_at: authUsers.created_at, + must_change_password: authUsers.must_change_password, + }) + .from(authUsers) + .where(eq(authUsers.id, id)) + + if (!user) { + return reply.code(404).send({ error: "User not found" }) + } + + // 2️⃣ Profil im Tenant + let profile = null + + if (authUser.tenant_id) { + const [profileRow] = await server.db + .select() + .from(authProfiles) + .where( + and( + eq(authProfiles.user_id, id), + eq(authProfiles.tenant_id, authUser.tenant_id) + ) + ) + + profile = profileRow || null + } + + return { user, profile } + + } catch (err: any) { + console.error("/user/:id ERROR", err) + return reply.code(500).send({ error: err.message || "Internal error" }) + } + }) + + // ------------------------------------------------------------- + // PUT /user/:id/profile + // ------------------------------------------------------------- + server.put("/user/:id/profile", async (req, reply) => { + try { + const { id } = req.params as { id: string } + const { data } = req.body as { data?: Record