1312 lines
84 KiB
SQL
1312 lines
84 KiB
SQL
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 '<p>Mit freundlichen Grüßen</p>',
|
|
"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"); |