1584 lines
42 KiB
PL/PgSQL
1584 lines
42 KiB
PL/PgSQL
-- Downloaded from: https://github.com/mvnp/start-dashboard-v3-backend/blob/9603e953662b7eb711d2d0ae5b026ee9825eea12/schema_only.sql
|
|
--
|
|
-- PostgreSQL database dump
|
|
--
|
|
|
|
-- Dumped from database version 16.9
|
|
-- Dumped by pg_dump version 16.5
|
|
|
|
SET statement_timeout = 0;
|
|
SET lock_timeout = 0;
|
|
SET idle_in_transaction_session_timeout = 0;
|
|
SET client_encoding = 'UTF8';
|
|
SET standard_conforming_strings = on;
|
|
SELECT pg_catalog.set_config('search_path', '', false);
|
|
SET check_function_bodies = false;
|
|
SET xmloption = content;
|
|
SET client_min_messages = warning;
|
|
SET row_security = off;
|
|
|
|
--
|
|
-- Name: priority_level; Type: TYPE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TYPE public.priority_level AS ENUM (
|
|
'Low',
|
|
'Medium',
|
|
'High',
|
|
'Urgent'
|
|
);
|
|
|
|
|
|
ALTER TYPE public.priority_level OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: ticket_status; Type: TYPE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TYPE public.ticket_status AS ENUM (
|
|
'Open',
|
|
'In Progress',
|
|
'Resolved',
|
|
'Closed'
|
|
);
|
|
|
|
|
|
ALTER TYPE public.ticket_status OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: transaction_type; Type: TYPE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TYPE public.transaction_type AS ENUM (
|
|
'revenue',
|
|
'expense'
|
|
);
|
|
|
|
|
|
ALTER TYPE public.transaction_type OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: whatsapp_status; Type: TYPE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TYPE public.whatsapp_status AS ENUM (
|
|
'Connected',
|
|
'Disconnected',
|
|
'Error'
|
|
);
|
|
|
|
|
|
ALTER TYPE public.whatsapp_status OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: update_updated_at_column(); Type: FUNCTION; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE FUNCTION public.update_updated_at_column() RETURNS trigger
|
|
LANGUAGE plpgsql
|
|
AS $$
|
|
BEGIN
|
|
NEW.updated_at = CURRENT_TIMESTAMP;
|
|
RETURN NEW;
|
|
END;
|
|
$$;
|
|
|
|
|
|
ALTER FUNCTION public.update_updated_at_column() OWNER TO neondb_owner;
|
|
|
|
SET default_tablespace = '';
|
|
|
|
SET default_table_access_method = heap;
|
|
|
|
--
|
|
-- Name: accounting_transaction_categories; Type: TABLE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TABLE public.accounting_transaction_categories (
|
|
id integer NOT NULL,
|
|
description character varying(255) NOT NULL,
|
|
business_id integer
|
|
);
|
|
|
|
|
|
ALTER TABLE public.accounting_transaction_categories OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: accounting_transaction_categories_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE SEQUENCE public.accounting_transaction_categories_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.accounting_transaction_categories_id_seq OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: accounting_transaction_categories_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER SEQUENCE public.accounting_transaction_categories_id_seq OWNED BY public.accounting_transaction_categories.id;
|
|
|
|
|
|
--
|
|
-- Name: accounting_transactions; Type: TABLE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TABLE public.accounting_transactions (
|
|
id integer NOT NULL,
|
|
type public.transaction_type NOT NULL,
|
|
description text,
|
|
amount numeric(10,2) NOT NULL,
|
|
payment_method character varying(100),
|
|
reference_number character varying(100),
|
|
transaction_date date NOT NULL,
|
|
notes text,
|
|
is_recurring boolean DEFAULT false,
|
|
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
client_id integer,
|
|
staff_id integer,
|
|
business_id integer,
|
|
category_id integer
|
|
);
|
|
|
|
|
|
ALTER TABLE public.accounting_transactions OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: accounting_transactions_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE SEQUENCE public.accounting_transactions_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.accounting_transactions_id_seq OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: accounting_transactions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER SEQUENCE public.accounting_transactions_id_seq OWNED BY public.accounting_transactions.id;
|
|
|
|
|
|
--
|
|
-- Name: appointments; Type: TABLE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TABLE public.appointments (
|
|
id integer NOT NULL,
|
|
appointment_date date NOT NULL,
|
|
appointment_time time without time zone NOT NULL,
|
|
status character varying(50) DEFAULT 'Scheduled'::character varying,
|
|
notes text,
|
|
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
deleted_at timestamp without time zone,
|
|
user_id integer,
|
|
business_id integer,
|
|
service_id integer,
|
|
client_id integer
|
|
);
|
|
|
|
|
|
ALTER TABLE public.appointments OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: appointments_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE SEQUENCE public.appointments_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.appointments_id_seq OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: appointments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER SEQUENCE public.appointments_id_seq OWNED BY public.appointments.id;
|
|
|
|
|
|
--
|
|
-- Name: barber_plans; Type: TABLE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TABLE public.barber_plans (
|
|
id integer NOT NULL,
|
|
title character varying(255) NOT NULL,
|
|
subtitle character varying(255),
|
|
benefits text[],
|
|
image1 character varying(500),
|
|
image2 character varying(500),
|
|
price1m numeric(10,2),
|
|
price3m numeric(10,2),
|
|
price12m numeric(10,2),
|
|
payment_link character varying(500),
|
|
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
business_id integer
|
|
);
|
|
|
|
|
|
ALTER TABLE public.barber_plans OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: barber_plans_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE SEQUENCE public.barber_plans_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.barber_plans_id_seq OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: barber_plans_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER SEQUENCE public.barber_plans_id_seq OWNED BY public.barber_plans.id;
|
|
|
|
|
|
--
|
|
-- Name: businesses; Type: TABLE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TABLE public.businesses (
|
|
id integer NOT NULL,
|
|
name character varying(255) NOT NULL,
|
|
description text,
|
|
address text,
|
|
phone character varying(20),
|
|
email character varying(255),
|
|
tax_id character varying(50),
|
|
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
user_id integer
|
|
);
|
|
|
|
|
|
ALTER TABLE public.businesses OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: businesses_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE SEQUENCE public.businesses_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.businesses_id_seq OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: businesses_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER SEQUENCE public.businesses_id_seq OWNED BY public.businesses.id;
|
|
|
|
|
|
--
|
|
-- Name: faqs; Type: TABLE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TABLE public.faqs (
|
|
id integer NOT NULL,
|
|
question text NOT NULL,
|
|
answer text NOT NULL,
|
|
category character varying(100),
|
|
is_published boolean DEFAULT true,
|
|
order_index integer DEFAULT 0,
|
|
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
|
|
ALTER TABLE public.faqs OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: faqs_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE SEQUENCE public.faqs_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.faqs_id_seq OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: faqs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER SEQUENCE public.faqs_id_seq OWNED BY public.faqs.id;
|
|
|
|
|
|
--
|
|
-- Name: payment_gateway_types; Type: TABLE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TABLE public.payment_gateway_types (
|
|
id integer NOT NULL,
|
|
description character varying(255) NOT NULL
|
|
);
|
|
|
|
|
|
ALTER TABLE public.payment_gateway_types OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: payment_gateway_types_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE SEQUENCE public.payment_gateway_types_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.payment_gateway_types_id_seq OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: payment_gateway_types_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER SEQUENCE public.payment_gateway_types_id_seq OWNED BY public.payment_gateway_types.id;
|
|
|
|
|
|
--
|
|
-- Name: payment_gateways; Type: TABLE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TABLE public.payment_gateways (
|
|
id integer NOT NULL,
|
|
name character varying(255) NOT NULL,
|
|
api_url character varying(500),
|
|
api_key character varying(500),
|
|
token character varying(500),
|
|
email character varying(255),
|
|
is_active boolean DEFAULT true,
|
|
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
business_id integer,
|
|
type_id integer,
|
|
type text DEFAULT 'Unknown'::text NOT NULL,
|
|
staff_id integer
|
|
);
|
|
|
|
|
|
ALTER TABLE public.payment_gateways OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: payment_gateways_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE SEQUENCE public.payment_gateways_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.payment_gateways_id_seq OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: payment_gateways_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER SEQUENCE public.payment_gateways_id_seq OWNED BY public.payment_gateways.id;
|
|
|
|
|
|
--
|
|
-- Name: persons; Type: TABLE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TABLE public.persons (
|
|
id integer NOT NULL,
|
|
first_name character varying(100) NOT NULL,
|
|
last_name character varying(100) NOT NULL,
|
|
phone character varying(20),
|
|
tax_id character varying(50),
|
|
hire_date date,
|
|
salary numeric(10,2),
|
|
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
deleted_at timestamp without time zone,
|
|
user_id integer,
|
|
address text
|
|
);
|
|
|
|
|
|
ALTER TABLE public.persons OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: persons_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE SEQUENCE public.persons_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.persons_id_seq OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: persons_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER SEQUENCE public.persons_id_seq OWNED BY public.persons.id;
|
|
|
|
|
|
--
|
|
-- Name: roles; Type: TABLE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TABLE public.roles (
|
|
id integer NOT NULL,
|
|
type character varying(100) NOT NULL,
|
|
description text
|
|
);
|
|
|
|
|
|
ALTER TABLE public.roles OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: roles_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE SEQUENCE public.roles_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.roles_id_seq OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: roles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER SEQUENCE public.roles_id_seq OWNED BY public.roles.id;
|
|
|
|
|
|
--
|
|
-- Name: services; Type: TABLE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TABLE public.services (
|
|
id integer NOT NULL,
|
|
name character varying(255) NOT NULL,
|
|
description text,
|
|
duration integer,
|
|
price numeric(10,2),
|
|
is_active boolean DEFAULT true,
|
|
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
business_id integer
|
|
);
|
|
|
|
|
|
ALTER TABLE public.services OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: services_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE SEQUENCE public.services_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.services_id_seq OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: services_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER SEQUENCE public.services_id_seq OWNED BY public.services.id;
|
|
|
|
|
|
--
|
|
-- Name: settings; Type: TABLE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TABLE public.settings (
|
|
id integer NOT NULL,
|
|
language text DEFAULT 'en'::text NOT NULL,
|
|
timezone text DEFAULT 'UTC'::text NOT NULL,
|
|
currency text DEFAULT 'USD'::text NOT NULL,
|
|
created_at timestamp without time zone DEFAULT now(),
|
|
updated_at timestamp without time zone DEFAULT now(),
|
|
business_id integer NOT NULL
|
|
);
|
|
|
|
|
|
ALTER TABLE public.settings OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: settings_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE SEQUENCE public.settings_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.settings_id_seq OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: settings_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER SEQUENCE public.settings_id_seq OWNED BY public.settings.id;
|
|
|
|
|
|
--
|
|
-- Name: support_ticket_categories; Type: TABLE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TABLE public.support_ticket_categories (
|
|
id integer NOT NULL,
|
|
title character varying(255) NOT NULL,
|
|
description text
|
|
);
|
|
|
|
|
|
ALTER TABLE public.support_ticket_categories OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: support_ticket_categories_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE SEQUENCE public.support_ticket_categories_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.support_ticket_categories_id_seq OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: support_ticket_categories_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER SEQUENCE public.support_ticket_categories_id_seq OWNED BY public.support_ticket_categories.id;
|
|
|
|
|
|
--
|
|
-- Name: support_tickets; Type: TABLE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TABLE public.support_tickets (
|
|
id integer NOT NULL,
|
|
title character varying(255) NOT NULL,
|
|
description text NOT NULL,
|
|
priority public.priority_level DEFAULT 'Medium'::public.priority_level,
|
|
status public.ticket_status DEFAULT 'Open'::public.ticket_status,
|
|
category character varying(100),
|
|
client_email character varying(255),
|
|
client_name character varying(255),
|
|
resolution_notes text,
|
|
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
resolved_at timestamp without time zone,
|
|
deleted_at timestamp without time zone,
|
|
assigned_user_id integer,
|
|
ticket_open_user_id integer,
|
|
business_id integer
|
|
);
|
|
|
|
|
|
ALTER TABLE public.support_tickets OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: support_tickets_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE SEQUENCE public.support_tickets_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.support_tickets_id_seq OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: support_tickets_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER SEQUENCE public.support_tickets_id_seq OWNED BY public.support_tickets.id;
|
|
|
|
|
|
--
|
|
-- Name: traductions; Type: TABLE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TABLE public.traductions (
|
|
id integer NOT NULL,
|
|
string text NOT NULL,
|
|
created_at timestamp without time zone DEFAULT now(),
|
|
updated_at timestamp without time zone DEFAULT now()
|
|
);
|
|
|
|
|
|
ALTER TABLE public.traductions OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: traductions_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE SEQUENCE public.traductions_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.traductions_id_seq OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: traductions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER SEQUENCE public.traductions_id_seq OWNED BY public.traductions.id;
|
|
|
|
|
|
--
|
|
-- Name: translations; Type: TABLE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TABLE public.translations (
|
|
id integer NOT NULL,
|
|
traduction_id integer NOT NULL,
|
|
traduction text NOT NULL,
|
|
language text NOT NULL,
|
|
created_at timestamp without time zone DEFAULT now(),
|
|
updated_at timestamp without time zone DEFAULT now()
|
|
);
|
|
|
|
|
|
ALTER TABLE public.translations OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: translations_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE SEQUENCE public.translations_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.translations_id_seq OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: translations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER SEQUENCE public.translations_id_seq OWNED BY public.translations.id;
|
|
|
|
|
|
--
|
|
-- Name: users; Type: TABLE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TABLE public.users (
|
|
id integer NOT NULL,
|
|
password character varying(255) NOT NULL,
|
|
email character varying(255) NOT NULL,
|
|
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
deleted_at timestamp without time zone
|
|
);
|
|
|
|
|
|
ALTER TABLE public.users OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: users_business; Type: TABLE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TABLE public.users_business (
|
|
user_id integer NOT NULL,
|
|
business_id integer NOT NULL
|
|
);
|
|
|
|
|
|
ALTER TABLE public.users_business OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE SEQUENCE public.users_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.users_id_seq OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;
|
|
|
|
|
|
--
|
|
-- Name: users_roles; Type: TABLE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TABLE public.users_roles (
|
|
user_id integer NOT NULL,
|
|
role_id integer NOT NULL
|
|
);
|
|
|
|
|
|
ALTER TABLE public.users_roles OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: whatsapp_instances; Type: TABLE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TABLE public.whatsapp_instances (
|
|
id integer NOT NULL,
|
|
name character varying(255) NOT NULL,
|
|
phone_number character varying(20),
|
|
status public.whatsapp_status DEFAULT 'Disconnected'::public.whatsapp_status,
|
|
qr_code text,
|
|
session_id character varying(255),
|
|
last_seen timestamp without time zone,
|
|
webhook_url character varying(500),
|
|
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
business_id integer
|
|
);
|
|
|
|
|
|
ALTER TABLE public.whatsapp_instances OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: whatsapp_instances_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE SEQUENCE public.whatsapp_instances_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.whatsapp_instances_id_seq OWNER TO neondb_owner;
|
|
|
|
--
|
|
-- Name: whatsapp_instances_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER SEQUENCE public.whatsapp_instances_id_seq OWNED BY public.whatsapp_instances.id;
|
|
|
|
|
|
--
|
|
-- Name: accounting_transaction_categories id; Type: DEFAULT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.accounting_transaction_categories ALTER COLUMN id SET DEFAULT nextval('public.accounting_transaction_categories_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: accounting_transactions id; Type: DEFAULT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.accounting_transactions ALTER COLUMN id SET DEFAULT nextval('public.accounting_transactions_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: appointments id; Type: DEFAULT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.appointments ALTER COLUMN id SET DEFAULT nextval('public.appointments_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: barber_plans id; Type: DEFAULT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.barber_plans ALTER COLUMN id SET DEFAULT nextval('public.barber_plans_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: businesses id; Type: DEFAULT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.businesses ALTER COLUMN id SET DEFAULT nextval('public.businesses_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: faqs id; Type: DEFAULT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.faqs ALTER COLUMN id SET DEFAULT nextval('public.faqs_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: payment_gateway_types id; Type: DEFAULT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.payment_gateway_types ALTER COLUMN id SET DEFAULT nextval('public.payment_gateway_types_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: payment_gateways id; Type: DEFAULT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.payment_gateways ALTER COLUMN id SET DEFAULT nextval('public.payment_gateways_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: persons id; Type: DEFAULT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.persons ALTER COLUMN id SET DEFAULT nextval('public.persons_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: roles id; Type: DEFAULT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.roles ALTER COLUMN id SET DEFAULT nextval('public.roles_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: services id; Type: DEFAULT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.services ALTER COLUMN id SET DEFAULT nextval('public.services_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: settings id; Type: DEFAULT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.settings ALTER COLUMN id SET DEFAULT nextval('public.settings_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: support_ticket_categories id; Type: DEFAULT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.support_ticket_categories ALTER COLUMN id SET DEFAULT nextval('public.support_ticket_categories_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: support_tickets id; Type: DEFAULT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.support_tickets ALTER COLUMN id SET DEFAULT nextval('public.support_tickets_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: traductions id; Type: DEFAULT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.traductions ALTER COLUMN id SET DEFAULT nextval('public.traductions_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: translations id; Type: DEFAULT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.translations ALTER COLUMN id SET DEFAULT nextval('public.translations_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: users id; Type: DEFAULT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: whatsapp_instances id; Type: DEFAULT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.whatsapp_instances ALTER COLUMN id SET DEFAULT nextval('public.whatsapp_instances_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: accounting_transaction_categories accounting_transaction_categories_pkey; Type: CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.accounting_transaction_categories
|
|
ADD CONSTRAINT accounting_transaction_categories_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: accounting_transactions accounting_transactions_pkey; Type: CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.accounting_transactions
|
|
ADD CONSTRAINT accounting_transactions_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: appointments appointments_pkey; Type: CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.appointments
|
|
ADD CONSTRAINT appointments_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: barber_plans barber_plans_pkey; Type: CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.barber_plans
|
|
ADD CONSTRAINT barber_plans_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: businesses businesses_pkey; Type: CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.businesses
|
|
ADD CONSTRAINT businesses_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: faqs faqs_pkey; Type: CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.faqs
|
|
ADD CONSTRAINT faqs_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: payment_gateway_types payment_gateway_types_pkey; Type: CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.payment_gateway_types
|
|
ADD CONSTRAINT payment_gateway_types_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: payment_gateways payment_gateways_pkey; Type: CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.payment_gateways
|
|
ADD CONSTRAINT payment_gateways_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: persons persons_pkey; Type: CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.persons
|
|
ADD CONSTRAINT persons_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: roles roles_pkey; Type: CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.roles
|
|
ADD CONSTRAINT roles_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: services services_pkey; Type: CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.services
|
|
ADD CONSTRAINT services_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: settings settings_pkey; Type: CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.settings
|
|
ADD CONSTRAINT settings_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: support_ticket_categories support_ticket_categories_pkey; Type: CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.support_ticket_categories
|
|
ADD CONSTRAINT support_ticket_categories_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: support_tickets support_tickets_pkey; Type: CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.support_tickets
|
|
ADD CONSTRAINT support_tickets_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: traductions traductions_pkey; Type: CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.traductions
|
|
ADD CONSTRAINT traductions_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: traductions traductions_string_unique; Type: CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.traductions
|
|
ADD CONSTRAINT traductions_string_unique UNIQUE (string);
|
|
|
|
|
|
--
|
|
-- Name: translations translations_pkey; Type: CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.translations
|
|
ADD CONSTRAINT translations_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: users_business users_business_pkey; Type: CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.users_business
|
|
ADD CONSTRAINT users_business_pkey PRIMARY KEY (user_id, business_id);
|
|
|
|
|
|
--
|
|
-- Name: users users_email_key; Type: CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.users
|
|
ADD CONSTRAINT users_email_key UNIQUE (email);
|
|
|
|
|
|
--
|
|
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.users
|
|
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: users_roles users_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.users_roles
|
|
ADD CONSTRAINT users_roles_pkey PRIMARY KEY (user_id, role_id);
|
|
|
|
|
|
--
|
|
-- Name: whatsapp_instances whatsapp_instances_pkey; Type: CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.whatsapp_instances
|
|
ADD CONSTRAINT whatsapp_instances_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: idx_accounting_transactions_date; Type: INDEX; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE INDEX idx_accounting_transactions_date ON public.accounting_transactions USING btree (transaction_date);
|
|
|
|
|
|
--
|
|
-- Name: idx_appointments_business_id; Type: INDEX; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE INDEX idx_appointments_business_id ON public.appointments USING btree (business_id);
|
|
|
|
|
|
--
|
|
-- Name: idx_appointments_date; Type: INDEX; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE INDEX idx_appointments_date ON public.appointments USING btree (appointment_date);
|
|
|
|
|
|
--
|
|
-- Name: idx_appointments_deleted_at; Type: INDEX; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE INDEX idx_appointments_deleted_at ON public.appointments USING btree (deleted_at);
|
|
|
|
|
|
--
|
|
-- Name: idx_appointments_service_id; Type: INDEX; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE INDEX idx_appointments_service_id ON public.appointments USING btree (service_id);
|
|
|
|
|
|
--
|
|
-- Name: idx_appointments_user_id; Type: INDEX; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE INDEX idx_appointments_user_id ON public.appointments USING btree (user_id);
|
|
|
|
|
|
--
|
|
-- Name: idx_barber_plans_business_id; Type: INDEX; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE INDEX idx_barber_plans_business_id ON public.barber_plans USING btree (business_id);
|
|
|
|
|
|
--
|
|
-- Name: idx_payment_gateways_business_id; Type: INDEX; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE INDEX idx_payment_gateways_business_id ON public.payment_gateways USING btree (business_id);
|
|
|
|
|
|
--
|
|
-- Name: idx_persons_deleted_at; Type: INDEX; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE INDEX idx_persons_deleted_at ON public.persons USING btree (deleted_at);
|
|
|
|
|
|
--
|
|
-- Name: idx_persons_user_id; Type: INDEX; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE INDEX idx_persons_user_id ON public.persons USING btree (user_id);
|
|
|
|
|
|
--
|
|
-- Name: idx_services_business_id; Type: INDEX; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE INDEX idx_services_business_id ON public.services USING btree (business_id);
|
|
|
|
|
|
--
|
|
-- Name: idx_support_tickets_assigned_user_id; Type: INDEX; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE INDEX idx_support_tickets_assigned_user_id ON public.support_tickets USING btree (assigned_user_id);
|
|
|
|
|
|
--
|
|
-- Name: idx_support_tickets_business_id; Type: INDEX; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE INDEX idx_support_tickets_business_id ON public.support_tickets USING btree (business_id);
|
|
|
|
|
|
--
|
|
-- Name: idx_support_tickets_deleted_at; Type: INDEX; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE INDEX idx_support_tickets_deleted_at ON public.support_tickets USING btree (deleted_at);
|
|
|
|
|
|
--
|
|
-- Name: idx_support_tickets_status; Type: INDEX; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE INDEX idx_support_tickets_status ON public.support_tickets USING btree (status);
|
|
|
|
|
|
--
|
|
-- Name: idx_support_tickets_ticket_open_user_id; Type: INDEX; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE INDEX idx_support_tickets_ticket_open_user_id ON public.support_tickets USING btree (ticket_open_user_id);
|
|
|
|
|
|
--
|
|
-- Name: idx_users_deleted_at; Type: INDEX; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE INDEX idx_users_deleted_at ON public.users USING btree (deleted_at);
|
|
|
|
|
|
--
|
|
-- Name: idx_users_email; Type: INDEX; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE INDEX idx_users_email ON public.users USING btree (email);
|
|
|
|
|
|
--
|
|
-- Name: idx_whatsapp_instances_business_id; Type: INDEX; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE INDEX idx_whatsapp_instances_business_id ON public.whatsapp_instances USING btree (business_id);
|
|
|
|
|
|
--
|
|
-- Name: accounting_transactions update_accounting_transactions_updated_at; Type: TRIGGER; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TRIGGER update_accounting_transactions_updated_at BEFORE UPDATE ON public.accounting_transactions FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();
|
|
|
|
|
|
--
|
|
-- Name: appointments update_appointments_updated_at; Type: TRIGGER; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TRIGGER update_appointments_updated_at BEFORE UPDATE ON public.appointments FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();
|
|
|
|
|
|
--
|
|
-- Name: barber_plans update_barber_plans_updated_at; Type: TRIGGER; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TRIGGER update_barber_plans_updated_at BEFORE UPDATE ON public.barber_plans FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();
|
|
|
|
|
|
--
|
|
-- Name: businesses update_businesses_updated_at; Type: TRIGGER; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TRIGGER update_businesses_updated_at BEFORE UPDATE ON public.businesses FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();
|
|
|
|
|
|
--
|
|
-- Name: faqs update_faqs_updated_at; Type: TRIGGER; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TRIGGER update_faqs_updated_at BEFORE UPDATE ON public.faqs FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();
|
|
|
|
|
|
--
|
|
-- Name: payment_gateways update_payment_gateways_updated_at; Type: TRIGGER; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TRIGGER update_payment_gateways_updated_at BEFORE UPDATE ON public.payment_gateways FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();
|
|
|
|
|
|
--
|
|
-- Name: persons update_persons_updated_at; Type: TRIGGER; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TRIGGER update_persons_updated_at BEFORE UPDATE ON public.persons FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();
|
|
|
|
|
|
--
|
|
-- Name: services update_services_updated_at; Type: TRIGGER; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TRIGGER update_services_updated_at BEFORE UPDATE ON public.services FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();
|
|
|
|
|
|
--
|
|
-- Name: support_tickets update_support_tickets_updated_at; Type: TRIGGER; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TRIGGER update_support_tickets_updated_at BEFORE UPDATE ON public.support_tickets FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();
|
|
|
|
|
|
--
|
|
-- Name: users update_users_updated_at; Type: TRIGGER; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TRIGGER update_users_updated_at BEFORE UPDATE ON public.users FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();
|
|
|
|
|
|
--
|
|
-- Name: whatsapp_instances update_whatsapp_instances_updated_at; Type: TRIGGER; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
CREATE TRIGGER update_whatsapp_instances_updated_at BEFORE UPDATE ON public.whatsapp_instances FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();
|
|
|
|
|
|
--
|
|
-- Name: accounting_transaction_categories accounting_transaction_categories_business_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.accounting_transaction_categories
|
|
ADD CONSTRAINT accounting_transaction_categories_business_id_fkey FOREIGN KEY (business_id) REFERENCES public.businesses(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: accounting_transactions accounting_transactions_business_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.accounting_transactions
|
|
ADD CONSTRAINT accounting_transactions_business_id_fkey FOREIGN KEY (business_id) REFERENCES public.businesses(id);
|
|
|
|
|
|
--
|
|
-- Name: accounting_transactions accounting_transactions_category_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.accounting_transactions
|
|
ADD CONSTRAINT accounting_transactions_category_id_fkey FOREIGN KEY (category_id) REFERENCES public.accounting_transaction_categories(id);
|
|
|
|
|
|
--
|
|
-- Name: accounting_transactions accounting_transactions_client_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.accounting_transactions
|
|
ADD CONSTRAINT accounting_transactions_client_id_fkey FOREIGN KEY (client_id) REFERENCES public.users(id);
|
|
|
|
|
|
--
|
|
-- Name: accounting_transactions accounting_transactions_staff_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.accounting_transactions
|
|
ADD CONSTRAINT accounting_transactions_staff_id_fkey FOREIGN KEY (staff_id) REFERENCES public.users(id);
|
|
|
|
|
|
--
|
|
-- Name: appointments appointments_business_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.appointments
|
|
ADD CONSTRAINT appointments_business_id_fkey FOREIGN KEY (business_id) REFERENCES public.businesses(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: appointments appointments_client_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.appointments
|
|
ADD CONSTRAINT appointments_client_id_fkey FOREIGN KEY (client_id) REFERENCES public.persons(id);
|
|
|
|
|
|
--
|
|
-- Name: appointments appointments_service_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.appointments
|
|
ADD CONSTRAINT appointments_service_id_fkey FOREIGN KEY (service_id) REFERENCES public.services(id) ON DELETE SET NULL;
|
|
|
|
|
|
--
|
|
-- Name: appointments appointments_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.appointments
|
|
ADD CONSTRAINT appointments_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.persons(id);
|
|
|
|
|
|
--
|
|
-- Name: barber_plans barber_plans_business_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.barber_plans
|
|
ADD CONSTRAINT barber_plans_business_id_fkey FOREIGN KEY (business_id) REFERENCES public.businesses(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: businesses businesses_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.businesses
|
|
ADD CONSTRAINT businesses_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
|
|
|
|
|
|
--
|
|
-- Name: payment_gateways payment_gateways_business_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.payment_gateways
|
|
ADD CONSTRAINT payment_gateways_business_id_fkey FOREIGN KEY (business_id) REFERENCES public.businesses(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: payment_gateways payment_gateways_staff_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.payment_gateways
|
|
ADD CONSTRAINT payment_gateways_staff_id_fkey FOREIGN KEY (staff_id) REFERENCES public.persons(id);
|
|
|
|
|
|
--
|
|
-- Name: payment_gateways payment_gateways_type_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.payment_gateways
|
|
ADD CONSTRAINT payment_gateways_type_id_fkey FOREIGN KEY (type_id) REFERENCES public.payment_gateway_types(id) ON DELETE SET NULL;
|
|
|
|
|
|
--
|
|
-- Name: persons persons_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.persons
|
|
ADD CONSTRAINT persons_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: services services_business_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.services
|
|
ADD CONSTRAINT services_business_id_fkey FOREIGN KEY (business_id) REFERENCES public.businesses(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: settings settings_business_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.settings
|
|
ADD CONSTRAINT settings_business_id_fkey FOREIGN KEY (business_id) REFERENCES public.businesses(id);
|
|
|
|
|
|
--
|
|
-- Name: support_tickets support_tickets_assigned_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.support_tickets
|
|
ADD CONSTRAINT support_tickets_assigned_user_id_fkey FOREIGN KEY (assigned_user_id) REFERENCES public.users(id) ON DELETE SET NULL;
|
|
|
|
|
|
--
|
|
-- Name: support_tickets support_tickets_business_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.support_tickets
|
|
ADD CONSTRAINT support_tickets_business_id_fkey FOREIGN KEY (business_id) REFERENCES public.businesses(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: support_tickets support_tickets_ticket_open_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.support_tickets
|
|
ADD CONSTRAINT support_tickets_ticket_open_user_id_fkey FOREIGN KEY (ticket_open_user_id) REFERENCES public.users(id) ON DELETE SET NULL;
|
|
|
|
|
|
--
|
|
-- Name: translations translations_traduction_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.translations
|
|
ADD CONSTRAINT translations_traduction_id_fkey FOREIGN KEY (traduction_id) REFERENCES public.traductions(id);
|
|
|
|
|
|
--
|
|
-- Name: users_business users_business_business_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.users_business
|
|
ADD CONSTRAINT users_business_business_id_fkey FOREIGN KEY (business_id) REFERENCES public.businesses(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: users_business users_business_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.users_business
|
|
ADD CONSTRAINT users_business_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: users_roles users_roles_role_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.users_roles
|
|
ADD CONSTRAINT users_roles_role_id_fkey FOREIGN KEY (role_id) REFERENCES public.roles(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: users_roles users_roles_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.users_roles
|
|
ADD CONSTRAINT users_roles_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: whatsapp_instances whatsapp_instances_business_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: neondb_owner
|
|
--
|
|
|
|
ALTER TABLE ONLY public.whatsapp_instances
|
|
ADD CONSTRAINT whatsapp_instances_business_id_fkey FOREIGN KEY (business_id) REFERENCES public.businesses(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: public; Owner: cloud_admin
|
|
--
|
|
|
|
ALTER DEFAULT PRIVILEGES FOR ROLE cloud_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO neon_superuser WITH GRANT OPTION;
|
|
|
|
|
|
--
|
|
-- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: public; Owner: cloud_admin
|
|
--
|
|
|
|
ALTER DEFAULT PRIVILEGES FOR ROLE cloud_admin IN SCHEMA public GRANT ALL ON TABLES TO neon_superuser WITH GRANT OPTION;
|
|
|
|
|
|
--
|
|
-- PostgreSQL database dump complete
|
|
--
|
|
|