--
-- PostgreSQL database dump
--

\restrict YdyOBw7ea7r5Hbt0TOrTLOEM6ytHKswa16nmEwgUe7J82iI10joho1abUqa1Xas

-- Dumped from database version 15.15
-- Dumped by pg_dump version 15.15

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: data; Type: SCHEMA; Schema: -; Owner: service_finder_app
--

CREATE SCHEMA data;


ALTER SCHEMA data OWNER TO service_finder_app;

--
-- Name: public; Type: SCHEMA; Schema: -; Owner: service_finder_app
--

-- *not* creating schema, since initdb creates it


ALTER SCHEMA public OWNER TO service_finder_app;

--
-- Name: companyrole; Type: TYPE; Schema: data; Owner: kincses
--

CREATE TYPE data.companyrole AS ENUM (
    'owner',
    'manager',
    'driver'
);


ALTER TYPE data.companyrole OWNER TO kincses;

--
-- Name: equipment_source; Type: TYPE; Schema: data; Owner: kincses
--

CREATE TYPE data.equipment_source AS ENUM (
    'factory',
    'aftermarket'
);


ALTER TYPE data.equipment_source OWNER TO kincses;

--
-- Name: expense_category_enum; Type: TYPE; Schema: data; Owner: kincses
--

CREATE TYPE data.expense_category_enum AS ENUM (
    'PURCHASE_PRICE',
    'TRANSFER_TAX',
    'ADMIN_FEE',
    'VEHICLE_TAX',
    'INSURANCE',
    'REFUELING',
    'SERVICE',
    'PARKING',
    'TOLL',
    'FINE',
    'TUNING_ACCESSORIES',
    'OTHER'
);


ALTER TYPE data.expense_category_enum OWNER TO kincses;

--
-- Name: moderation_status_enum; Type: TYPE; Schema: data; Owner: kincses
--

CREATE TYPE data.moderation_status_enum AS ENUM (
    'pending',
    'approved',
    'rejected'
);


ALTER TYPE data.moderation_status_enum OWNER TO kincses;

--
-- Name: source_type_enum; Type: TYPE; Schema: data; Owner: kincses
--

CREATE TYPE data.source_type_enum AS ENUM (
    'manual',
    'ocr',
    'api_import'
);


ALTER TYPE data.source_type_enum OWNER TO kincses;

--
-- Name: tokentype; Type: TYPE; Schema: data; Owner: kincses
--

CREATE TYPE data.tokentype AS ENUM (
    'email_verify',
    'password_reset',
    'api_key'
);


ALTER TYPE data.tokentype OWNER TO kincses;

--
-- Name: emailtype; Type: TYPE; Schema: public; Owner: kincses
--

CREATE TYPE public.emailtype AS ENUM (
    'REGISTRATION',
    'PASSWORD_RESET',
    'GDPR_NOTICE'
);


ALTER TYPE public.emailtype OWNER TO kincses;

--
-- Name: orgtype; Type: TYPE; Schema: public; Owner: kincses
--

CREATE TYPE public.orgtype AS ENUM (
    'PRIVATE',
    'COMPANY',
    'SERVICE'
);


ALTER TYPE public.orgtype OWNER TO kincses;

--
-- Name: orguserrole; Type: TYPE; Schema: public; Owner: kincses
--

CREATE TYPE public.orguserrole AS ENUM (
    'OWNER',
    'ADMIN',
    'FLEET_MANAGER',
    'DRIVER',
    'owner',
    'manager',
    'driver',
    'service'
);


ALTER TYPE public.orguserrole OWNER TO kincses;

--
-- Name: uitheme; Type: TYPE; Schema: public; Owner: kincses
--

CREATE TYPE public.uitheme AS ENUM (
    'LIGHT',
    'DARK',
    'SYSTEM'
);


ALTER TYPE public.uitheme OWNER TO kincses;

--
-- Name: userrole; Type: TYPE; Schema: public; Owner: kincses
--

CREATE TYPE public.userrole AS ENUM (
    'OWNER',
    'ADMIN',
    'FLEET_MANAGER',
    'DRIVER'
);


ALTER TYPE public.userrole OWNER TO kincses;

--
-- Name: validationstatus; Type: TYPE; Schema: public; Owner: kincses
--

CREATE TYPE public.validationstatus AS ENUM (
    'NOT_VALIDATED',
    'PENDING',
    'VALIDATED',
    'REJECTED'
);


ALTER TYPE public.validationstatus OWNER TO kincses;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- Name: audit_logs; Type: TABLE; Schema: data; Owner: kincses
--

CREATE TABLE data.audit_logs (
    id integer NOT NULL,
    user_id integer,
    action character varying(100) NOT NULL,
    endpoint character varying(255),
    method character varying(10),
    ip_address character varying(45),
    created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);


ALTER TABLE data.audit_logs OWNER TO kincses;

--
-- Name: audit_logs_id_seq; Type: SEQUENCE; Schema: data; Owner: kincses
--

CREATE SEQUENCE data.audit_logs_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE data.audit_logs_id_seq OWNER TO kincses;

--
-- Name: audit_logs_id_seq; Type: SEQUENCE OWNED BY; Schema: data; Owner: kincses
--

ALTER SEQUENCE data.audit_logs_id_seq OWNED BY data.audit_logs.id;


--
-- Name: companies; Type: TABLE; Schema: data; Owner: service_finder_app
--

CREATE TABLE data.companies (
    id integer NOT NULL,
    name character varying(255) NOT NULL,
    tax_number character varying(50),
    subscription_tier character varying(50) DEFAULT 'free'::character varying,
    owner_id integer NOT NULL,
    owner_person_id bigint
);


ALTER TABLE data.companies OWNER TO service_finder_app;

--
-- Name: companies_id_seq; Type: SEQUENCE; Schema: data; Owner: service_finder_app
--

CREATE SEQUENCE data.companies_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE data.companies_id_seq OWNER TO service_finder_app;

--
-- Name: companies_id_seq; Type: SEQUENCE OWNED BY; Schema: data; Owner: service_finder_app
--

ALTER SEQUENCE data.companies_id_seq OWNED BY data.companies.id;


--
-- Name: company_members; Type: TABLE; Schema: data; Owner: service_finder_app
--

CREATE TABLE data.company_members (
    id integer NOT NULL,
    company_id integer NOT NULL,
    user_id integer NOT NULL,
    role character varying(50) DEFAULT 'driver'::data.companyrole,
    can_edit_service boolean DEFAULT false,
    can_see_costs boolean DEFAULT false,
    is_active boolean DEFAULT true
);


ALTER TABLE data.company_members OWNER TO service_finder_app;

--
-- Name: company_members_id_seq; Type: SEQUENCE; Schema: data; Owner: service_finder_app
--

CREATE SEQUENCE data.company_members_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE data.company_members_id_seq OWNER TO service_finder_app;

--
-- Name: company_members_id_seq; Type: SEQUENCE OWNED BY; Schema: data; Owner: service_finder_app
--

ALTER SEQUENCE data.company_members_id_seq OWNED BY data.company_members.id;


--
-- Name: engine_specs; Type: TABLE; Schema: data; Owner: service_finder_app
--

CREATE TABLE data.engine_specs (
    id integer NOT NULL,
    engine_code character varying(50),
    fuel_type character varying(20),
    power_kw integer,
    battery_capacity_kwh numeric(10,2),
    onboard_charger_kw numeric(5,2),
    phases integer DEFAULT 3,
    default_service_interval_km integer DEFAULT 15000,
    default_service_interval_hours integer DEFAULT 500,
    emissions_class character varying(20)
);


ALTER TABLE data.engine_specs OWNER TO service_finder_app;

--
-- Name: engine_specs_id_seq; Type: SEQUENCE; Schema: data; Owner: service_finder_app
--

CREATE SEQUENCE data.engine_specs_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE data.engine_specs_id_seq OWNER TO service_finder_app;

--
-- Name: engine_specs_id_seq; Type: SEQUENCE OWNED BY; Schema: data; Owner: service_finder_app
--

ALTER SEQUENCE data.engine_specs_id_seq OWNED BY data.engine_specs.id;


--
-- Name: organization_members; Type: TABLE; Schema: data; Owner: kincses
--

CREATE TABLE data.organization_members (
    id integer NOT NULL,
    organization_id integer,
    user_id integer,
    role character varying DEFAULT 'driver'::character varying
);


ALTER TABLE data.organization_members OWNER TO kincses;

--
-- Name: organization_members_id_seq; Type: SEQUENCE; Schema: data; Owner: kincses
--

CREATE SEQUENCE data.organization_members_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE data.organization_members_id_seq OWNER TO kincses;

--
-- Name: organization_members_id_seq; Type: SEQUENCE OWNED BY; Schema: data; Owner: kincses
--

ALTER SEQUENCE data.organization_members_id_seq OWNED BY data.organization_members.id;


--
-- Name: organizations; Type: TABLE; Schema: data; Owner: service_finder_app
--

CREATE TABLE data.organizations (
    id integer NOT NULL,
    name character varying NOT NULL,
    org_type public.orgtype,
    founded_at date,
    validation_status public.validationstatus,
    owner_id integer,
    ui_theme character varying,
    created_at timestamp with time zone DEFAULT now(),
    theme character varying DEFAULT 'system'::character varying,
    is_active boolean DEFAULT true,
    slug character varying(100),
    country_code character(2) DEFAULT 'HU'::bpchar,
    is_transferable boolean DEFAULT true
);


ALTER TABLE data.organizations OWNER TO service_finder_app;

--
-- Name: organizations_id_seq; Type: SEQUENCE; Schema: data; Owner: service_finder_app
--

CREATE SEQUENCE data.organizations_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE data.organizations_id_seq OWNER TO service_finder_app;

--
-- Name: organizations_id_seq; Type: SEQUENCE OWNED BY; Schema: data; Owner: service_finder_app
--

ALTER SEQUENCE data.organizations_id_seq OWNED BY data.organizations.id;


--
-- Name: persons; Type: TABLE; Schema: data; Owner: service_finder_app
--

CREATE TABLE data.persons (
    id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone,
    is_active boolean DEFAULT true NOT NULL,
    reputation_score numeric(10,2) DEFAULT 0 NOT NULL,
    risk_level integer DEFAULT 0 NOT NULL,
    id_uuid uuid DEFAULT gen_random_uuid(),
    last_name character varying,
    first_name character varying,
    mothers_name character varying,
    birth_place character varying,
    birth_date timestamp without time zone,
    identity_docs jsonb DEFAULT '{}'::jsonb,
    medical_emergency jsonb DEFAULT '{}'::jsonb,
    ice_contact jsonb DEFAULT '{}'::jsonb
);


ALTER TABLE data.persons OWNER TO service_finder_app;

--
-- Name: persons_id_seq; Type: SEQUENCE; Schema: data; Owner: service_finder_app
--

CREATE SEQUENCE data.persons_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE data.persons_id_seq OWNER TO service_finder_app;

--
-- Name: persons_id_seq; Type: SEQUENCE OWNED BY; Schema: data; Owner: service_finder_app
--

ALTER SEQUENCE data.persons_id_seq OWNED BY data.persons.id;


--
-- Name: service_providers; Type: TABLE; Schema: data; Owner: service_finder_app
--

CREATE TABLE data.service_providers (
    id integer NOT NULL,
    name character varying(255) NOT NULL,
    official_brand_partner boolean DEFAULT false,
    technical_rating_pct integer DEFAULT 80,
    social_rating_pct integer DEFAULT 80,
    location_city character varying(100),
    is_active boolean DEFAULT true,
    service_type character varying(50),
    search_tags text,
    latitude numeric(10,8),
    longitude numeric(11,8),
    handled_vehicle_types jsonb DEFAULT '["passenger_car"]'::jsonb,
    specialized_brands jsonb DEFAULT '[]'::jsonb,
    verification_status character varying(20) DEFAULT 'pending'::character varying
);


ALTER TABLE data.service_providers OWNER TO service_finder_app;

--
-- Name: service_providers_id_seq; Type: SEQUENCE; Schema: data; Owner: service_finder_app
--

CREATE SEQUENCE data.service_providers_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE data.service_providers_id_seq OWNER TO service_finder_app;

--
-- Name: service_providers_id_seq; Type: SEQUENCE OWNED BY; Schema: data; Owner: service_finder_app
--

ALTER SEQUENCE data.service_providers_id_seq OWNED BY data.service_providers.id;


--
-- Name: service_records; Type: TABLE; Schema: data; Owner: service_finder_app
--

CREATE TABLE data.service_records (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    vehicle_id uuid,
    provider_id integer,
    service_date date NOT NULL,
    usage_value numeric(15,2),
    is_accident_repair boolean DEFAULT false,
    repair_quality_pct integer DEFAULT 100,
    parts_quality_index numeric(3,2) DEFAULT 1.0,
    description text,
    invoice_path text,
    rating_impact_score integer DEFAULT 0
);


ALTER TABLE data.service_records OWNER TO service_finder_app;

--
-- Name: system_settings; Type: TABLE; Schema: data; Owner: kincses
--

CREATE TABLE data.system_settings (
    key character varying(50) NOT NULL,
    value jsonb,
    description text
);


ALTER TABLE data.system_settings OWNER TO kincses;

--
-- Name: users; Type: TABLE; Schema: data; Owner: service_finder_app
--

CREATE TABLE data.users (
    id integer NOT NULL,
    email character varying NOT NULL,
    birthday date,
    is_active boolean,
    is_banned boolean,
    is_gdpr_deleted boolean,
    previous_login_count integer,
    created_at timestamp with time zone DEFAULT now(),
    verified_at timestamp with time zone,
    hashed_password character varying,
    role character varying DEFAULT 'user'::character varying,
    is_superuser boolean DEFAULT false,
    is_company boolean DEFAULT false,
    updated_at timestamp with time zone,
    company_name character varying,
    tax_number character varying,
    region_code character varying DEFAULT 'HU'::character varying,
    person_id bigint,
    deleted_at timestamp with time zone,
    is_deleted boolean DEFAULT false NOT NULL,
    social_provider character varying(50),
    social_id character varying(255)
);


ALTER TABLE data.users OWNER TO service_finder_app;

--
-- Name: users_id_seq; Type: SEQUENCE; Schema: data; Owner: service_finder_app
--

CREATE SEQUENCE data.users_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE data.users_id_seq OWNER TO service_finder_app;

--
-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: data; Owner: service_finder_app
--

ALTER SEQUENCE data.users_id_seq OWNED BY data.users.id;


--
-- Name: vehicle_assignments; Type: TABLE; Schema: data; Owner: service_finder_app
--

CREATE TABLE data.vehicle_assignments (
    id integer NOT NULL,
    company_id integer NOT NULL,
    vehicle_id integer NOT NULL,
    driver_id integer NOT NULL,
    start_date timestamp with time zone DEFAULT now(),
    end_date timestamp with time zone,
    notes character varying
);


ALTER TABLE data.vehicle_assignments OWNER TO service_finder_app;

--
-- Name: vehicle_assignments_id_seq; Type: SEQUENCE; Schema: data; Owner: service_finder_app
--

CREATE SEQUENCE data.vehicle_assignments_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE data.vehicle_assignments_id_seq OWNER TO service_finder_app;

--
-- Name: vehicle_assignments_id_seq; Type: SEQUENCE OWNED BY; Schema: data; Owner: service_finder_app
--

ALTER SEQUENCE data.vehicle_assignments_id_seq OWNED BY data.vehicle_assignments.id;


--
-- Name: vehicle_brands; Type: TABLE; Schema: data; Owner: service_finder_app
--

CREATE TABLE data.vehicle_brands (
    id integer NOT NULL,
    name character varying NOT NULL,
    origin_country character varying,
    slug character varying,
    country_code character varying,
    category_id integer,
    country_of_origin character varying(50),
    is_active boolean DEFAULT true
);


ALTER TABLE data.vehicle_brands OWNER TO service_finder_app;

--
-- Name: vehicle_brands_id_seq; Type: SEQUENCE; Schema: data; Owner: service_finder_app
--

CREATE SEQUENCE data.vehicle_brands_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE data.vehicle_brands_id_seq OWNER TO service_finder_app;

--
-- Name: vehicle_brands_id_seq; Type: SEQUENCE OWNED BY; Schema: data; Owner: service_finder_app
--

ALTER SEQUENCE data.vehicle_brands_id_seq OWNED BY data.vehicle_brands.id;


--
-- Name: vehicles; Type: TABLE; Schema: data; Owner: service_finder_app
--

CREATE TABLE data.vehicles (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    current_company_id integer,
    brand_id integer,
    model_name character varying(100),
    engine_spec_id integer,
    identification_number character varying(50),
    license_plate character varying(20),
    tracking_mode character varying(10) DEFAULT 'km'::character varying,
    current_rating_pct integer DEFAULT 100,
    total_real_usage numeric(15,2) DEFAULT 0,
    odometer_at_last_check numeric(15,2) DEFAULT 0,
    custom_specs jsonb DEFAULT '{}'::jsonb,
    factory_snapshot jsonb,
    created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);


ALTER TABLE data.vehicles OWNER TO service_finder_app;

--
-- Name: wallets; Type: TABLE; Schema: data; Owner: service_finder_app
--

CREATE TABLE data.wallets (
    id bigint NOT NULL,
    user_id integer NOT NULL,
    coin_balance numeric(18,2) DEFAULT 0.00,
    xp_balance bigint DEFAULT 0,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now()
);


ALTER TABLE data.wallets OWNER TO service_finder_app;

--
-- Name: wallets_id_seq; Type: SEQUENCE; Schema: data; Owner: service_finder_app
--

CREATE SEQUENCE data.wallets_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE data.wallets_id_seq OWNER TO service_finder_app;

--
-- Name: wallets_id_seq; Type: SEQUENCE OWNED BY; Schema: data; Owner: service_finder_app
--

ALTER SEQUENCE data.wallets_id_seq OWNED BY data.wallets.id;


--
-- Name: alembic_version; Type: TABLE; Schema: public; Owner: service_finder_app
--

CREATE TABLE public.alembic_version (
    version_num character varying(32) NOT NULL
);


ALTER TABLE public.alembic_version OWNER TO service_finder_app;

--
-- Name: audit_logs id; Type: DEFAULT; Schema: data; Owner: kincses
--

ALTER TABLE ONLY data.audit_logs ALTER COLUMN id SET DEFAULT nextval('data.audit_logs_id_seq'::regclass);


--
-- Name: companies id; Type: DEFAULT; Schema: data; Owner: service_finder_app
--

ALTER TABLE ONLY data.companies ALTER COLUMN id SET DEFAULT nextval('data.companies_id_seq'::regclass);


--
-- Name: company_members id; Type: DEFAULT; Schema: data; Owner: service_finder_app
--

ALTER TABLE ONLY data.company_members ALTER COLUMN id SET DEFAULT nextval('data.company_members_id_seq'::regclass);


--
-- Name: engine_specs id; Type: DEFAULT; Schema: data; Owner: service_finder_app
--

ALTER TABLE ONLY data.engine_specs ALTER COLUMN id SET DEFAULT nextval('data.engine_specs_id_seq'::regclass);


--
-- Name: organization_members id; Type: DEFAULT; Schema: data; Owner: kincses
--

ALTER TABLE ONLY data.organization_members ALTER COLUMN id SET DEFAULT nextval('data.organization_members_id_seq'::regclass);


--
-- Name: organizations id; Type: DEFAULT; Schema: data; Owner: service_finder_app
--

ALTER TABLE ONLY data.organizations ALTER COLUMN id SET DEFAULT nextval('data.organizations_id_seq'::regclass);


--
-- Name: persons id; Type: DEFAULT; Schema: data; Owner: service_finder_app
--

ALTER TABLE ONLY data.persons ALTER COLUMN id SET DEFAULT nextval('data.persons_id_seq'::regclass);


--
-- Name: service_providers id; Type: DEFAULT; Schema: data; Owner: service_finder_app
--

ALTER TABLE ONLY data.service_providers ALTER COLUMN id SET DEFAULT nextval('data.service_providers_id_seq'::regclass);


--
-- Name: users id; Type: DEFAULT; Schema: data; Owner: service_finder_app
--

ALTER TABLE ONLY data.users ALTER COLUMN id SET DEFAULT nextval('data.users_id_seq'::regclass);


--
-- Name: vehicle_assignments id; Type: DEFAULT; Schema: data; Owner: service_finder_app
--

ALTER TABLE ONLY data.vehicle_assignments ALTER COLUMN id SET DEFAULT nextval('data.vehicle_assignments_id_seq'::regclass);


--
-- Name: vehicle_brands id; Type: DEFAULT; Schema: data; Owner: service_finder_app
--

ALTER TABLE ONLY data.vehicle_brands ALTER COLUMN id SET DEFAULT nextval('data.vehicle_brands_id_seq'::regclass);


--
-- Name: wallets id; Type: DEFAULT; Schema: data; Owner: service_finder_app
--

ALTER TABLE ONLY data.wallets ALTER COLUMN id SET DEFAULT nextval('data.wallets_id_seq'::regclass);


--
-- Name: audit_logs audit_logs_pkey; Type: CONSTRAINT; Schema: data; Owner: kincses
--

ALTER TABLE ONLY data.audit_logs
    ADD CONSTRAINT audit_logs_pkey PRIMARY KEY (id);


--
-- Name: companies companies_pkey; Type: CONSTRAINT; Schema: data; Owner: service_finder_app
--

ALTER TABLE ONLY data.companies
    ADD CONSTRAINT companies_pkey PRIMARY KEY (id);


--
-- Name: company_members company_members_pkey; Type: CONSTRAINT; Schema: data; Owner: service_finder_app
--

ALTER TABLE ONLY data.company_members
    ADD CONSTRAINT company_members_pkey PRIMARY KEY (id);


--
-- Name: engine_specs engine_specs_pkey; Type: CONSTRAINT; Schema: data; Owner: service_finder_app
--

ALTER TABLE ONLY data.engine_specs
    ADD CONSTRAINT engine_specs_pkey PRIMARY KEY (id);


--
-- Name: organization_members organization_members_pkey; Type: CONSTRAINT; Schema: data; Owner: kincses
--

ALTER TABLE ONLY data.organization_members
    ADD CONSTRAINT organization_members_pkey PRIMARY KEY (id);


--
-- Name: organizations organizations_pkey; Type: CONSTRAINT; Schema: data; Owner: service_finder_app
--

ALTER TABLE ONLY data.organizations
    ADD CONSTRAINT organizations_pkey PRIMARY KEY (id);


--
-- Name: persons persons_pkey; Type: CONSTRAINT; Schema: data; Owner: service_finder_app
--

ALTER TABLE ONLY data.persons
    ADD CONSTRAINT persons_pkey PRIMARY KEY (id);


--
-- Name: service_providers service_providers_pkey; Type: CONSTRAINT; Schema: data; Owner: service_finder_app
--

ALTER TABLE ONLY data.service_providers
    ADD CONSTRAINT service_providers_pkey PRIMARY KEY (id);


--
-- Name: service_records service_records_pkey; Type: CONSTRAINT; Schema: data; Owner: service_finder_app
--

ALTER TABLE ONLY data.service_records
    ADD CONSTRAINT service_records_pkey PRIMARY KEY (id);


--
-- Name: system_settings system_settings_pkey; Type: CONSTRAINT; Schema: data; Owner: kincses
--

ALTER TABLE ONLY data.system_settings
    ADD CONSTRAINT system_settings_pkey PRIMARY KEY (key);


--
-- Name: users users_pkey; Type: CONSTRAINT; Schema: data; Owner: service_finder_app
--

ALTER TABLE ONLY data.users
    ADD CONSTRAINT users_pkey PRIMARY KEY (id);


--
-- Name: vehicle_assignments vehicle_assignments_pkey; Type: CONSTRAINT; Schema: data; Owner: service_finder_app
--

ALTER TABLE ONLY data.vehicle_assignments
    ADD CONSTRAINT vehicle_assignments_pkey PRIMARY KEY (id);


--
-- Name: vehicle_brands vehicle_brands_cat_name_key; Type: CONSTRAINT; Schema: data; Owner: service_finder_app
--

ALTER TABLE ONLY data.vehicle_brands
    ADD CONSTRAINT vehicle_brands_cat_name_key UNIQUE (category_id, name);


--
-- Name: vehicle_brands vehicle_brands_name_key; Type: CONSTRAINT; Schema: data; Owner: service_finder_app
--

ALTER TABLE ONLY data.vehicle_brands
    ADD CONSTRAINT vehicle_brands_name_key UNIQUE (name);


--
-- Name: vehicle_brands vehicle_brands_pkey; Type: CONSTRAINT; Schema: data; Owner: service_finder_app
--

ALTER TABLE ONLY data.vehicle_brands
    ADD CONSTRAINT vehicle_brands_pkey PRIMARY KEY (id);


--
-- Name: vehicles vehicles_identification_number_key; Type: CONSTRAINT; Schema: data; Owner: service_finder_app
--

ALTER TABLE ONLY data.vehicles
    ADD CONSTRAINT vehicles_identification_number_key UNIQUE (identification_number);


--
-- Name: vehicles vehicles_pkey; Type: CONSTRAINT; Schema: data; Owner: service_finder_app
--

ALTER TABLE ONLY data.vehicles
    ADD CONSTRAINT vehicles_pkey PRIMARY KEY (id);


--
-- Name: wallets wallets_pkey; Type: CONSTRAINT; Schema: data; Owner: service_finder_app
--

ALTER TABLE ONLY data.wallets
    ADD CONSTRAINT wallets_pkey PRIMARY KEY (id);


--
-- Name: wallets wallets_user_id_key; Type: CONSTRAINT; Schema: data; Owner: service_finder_app
--

ALTER TABLE ONLY data.wallets
    ADD CONSTRAINT wallets_user_id_key UNIQUE (user_id);


--
-- Name: alembic_version alembic_version_pkc; Type: CONSTRAINT; Schema: public; Owner: service_finder_app
--

ALTER TABLE ONLY public.alembic_version
    ADD CONSTRAINT alembic_version_pkc PRIMARY KEY (version_num);


--
-- Name: idx_engine_code; Type: INDEX; Schema: data; Owner: service_finder_app
--

CREATE INDEX idx_engine_code ON data.engine_specs USING btree (engine_code);


--
-- Name: idx_org_slug; Type: INDEX; Schema: data; Owner: service_finder_app
--

CREATE UNIQUE INDEX idx_org_slug ON data.organizations USING btree (slug);


--
-- Name: idx_user_email_active_only; Type: INDEX; Schema: data; Owner: service_finder_app
--

CREATE UNIQUE INDEX idx_user_email_active_only ON data.users USING btree (email) WHERE ((is_deleted IS FALSE) AND (deleted_at IS NULL));


--
-- Name: idx_vb_slug; Type: INDEX; Schema: data; Owner: service_finder_app
--

CREATE UNIQUE INDEX idx_vb_slug ON data.vehicle_brands USING btree (slug);


--
-- Name: idx_vehicle_company; Type: INDEX; Schema: data; Owner: service_finder_app
--

CREATE INDEX idx_vehicle_company ON data.vehicles USING btree (current_company_id);


--
-- Name: idx_vehicle_plate; Type: INDEX; Schema: data; Owner: service_finder_app
--

CREATE INDEX idx_vehicle_plate ON data.vehicles USING btree (license_plate);


--
-- Name: idx_vehicle_vin; Type: INDEX; Schema: data; Owner: service_finder_app
--

CREATE INDEX idx_vehicle_vin ON data.vehicles USING btree (identification_number);


--
-- Name: ix_companies_owner_person_id; Type: INDEX; Schema: data; Owner: service_finder_app
--

CREATE INDEX ix_companies_owner_person_id ON data.companies USING btree (owner_person_id);


--
-- Name: ix_data_organizations_id; Type: INDEX; Schema: data; Owner: service_finder_app
--

CREATE INDEX ix_data_organizations_id ON data.organizations USING btree (id);


--
-- Name: ix_data_users_id; Type: INDEX; Schema: data; Owner: service_finder_app
--

CREATE INDEX ix_data_users_id ON data.users USING btree (id);


--
-- Name: ix_data_vehicle_assignments_id; Type: INDEX; Schema: data; Owner: service_finder_app
--

CREATE INDEX ix_data_vehicle_assignments_id ON data.vehicle_assignments USING btree (id);


--
-- Name: ix_data_vehicle_brands_id; Type: INDEX; Schema: data; Owner: service_finder_app
--

CREATE INDEX ix_data_vehicle_brands_id ON data.vehicle_brands USING btree (id);


--
-- Name: ix_users_is_deleted; Type: INDEX; Schema: data; Owner: service_finder_app
--

CREATE INDEX ix_users_is_deleted ON data.users USING btree (is_deleted, deleted_at);


--
-- Name: ix_users_person_id; Type: INDEX; Schema: data; Owner: service_finder_app
--

CREATE INDEX ix_users_person_id ON data.users USING btree (person_id);


--
-- Name: organization_members organization_members_organization_id_fkey; Type: FK CONSTRAINT; Schema: data; Owner: kincses
--

ALTER TABLE ONLY data.organization_members
    ADD CONSTRAINT organization_members_organization_id_fkey FOREIGN KEY (organization_id) REFERENCES data.organizations(id);


--
-- Name: organization_members organization_members_user_id_fkey; Type: FK CONSTRAINT; Schema: data; Owner: kincses
--

ALTER TABLE ONLY data.organization_members
    ADD CONSTRAINT organization_members_user_id_fkey FOREIGN KEY (user_id) REFERENCES data.users(id);


--
-- Name: TABLE audit_logs; Type: ACL; Schema: data; Owner: kincses
--

GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE data.audit_logs TO service_finder_app;


--
-- Name: SEQUENCE audit_logs_id_seq; Type: ACL; Schema: data; Owner: kincses
--

GRANT ALL ON SEQUENCE data.audit_logs_id_seq TO service_finder_app;


--
-- Name: TABLE organization_members; Type: ACL; Schema: data; Owner: kincses
--

GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE data.organization_members TO service_finder_app;


--
-- Name: SEQUENCE organization_members_id_seq; Type: ACL; Schema: data; Owner: kincses
--

GRANT ALL ON SEQUENCE data.organization_members_id_seq TO service_finder_app;


--
-- Name: TABLE system_settings; Type: ACL; Schema: data; Owner: kincses
--

GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE data.system_settings TO service_finder_app;


--
-- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: data; Owner: kincses
--

ALTER DEFAULT PRIVILEGES FOR ROLE kincses IN SCHEMA data GRANT ALL ON SEQUENCES  TO service_finder_app;


--
-- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: data; Owner: kincses
--

ALTER DEFAULT PRIVILEGES FOR ROLE kincses IN SCHEMA data GRANT SELECT,INSERT,DELETE,UPDATE ON TABLES  TO service_finder_app;


--
-- PostgreSQL database dump complete
--

\unrestrict YdyOBw7ea7r5Hbt0TOrTLOEM6ytHKswa16nmEwgUe7J82iI10joho1abUqa1Xas

