--
-- PostgreSQL database dump
--

\restrict KSNzZnHZpEceNNT6ECpaur3DZ2vfo46zPOlHHzj65wcCLFVfh0bZaudbdKNNiIC

-- Dumped from database version 16.11 (Ubuntu 16.11-0ubuntu0.24.04.1)
-- Dumped by pg_dump version 16.11 (Ubuntu 16.11-0ubuntu0.24.04.1)

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: order_status; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE public.order_status AS ENUM (
    'pending',
    'running',
    'finished',
    'failed',
    'dlx'
);


--
-- Name: order_types; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE public.order_types AS ENUM (
    'activate',
    'preactivate',
    'cancel',
    'pause',
    'reactivate',
    'unknown'
);


--
-- Name: status_enum; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE public.status_enum AS ENUM (
    'noRequestID',
    'noMassID',
    'running',
    'finished',
    'error',
    'other'
);


SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- Name: objenious_operation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.objenious_operation (
    id bigint NOT NULL,
    retry_count integer DEFAULT 0,
    max_retry integer DEFAULT 5,
    max_date_retry timestamp without time zone,
    iccids text,
    request_id text,
    mass_action_id text,
    operation text NOT NULL,
    start_date timestamp without time zone DEFAULT (now() AT TIME ZONE 'utc'::text) NOT NULL,
    last_change_date timestamp without time zone DEFAULT now() NOT NULL,
    end_date timestamp without time zone,
    error text,
    status public.status_enum,
    objenious_status text
);


--
-- Name: objenious_operation_change; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.objenious_operation_change (
    id bigint NOT NULL,
    operation_id bigint,
    creation_date timestamp without time zone DEFAULT now() NOT NULL,
    error text,
    new_status public.status_enum,
    previous_status public.status_enum,
    new_objenious_status text,
    previous_objenious_status text,
    new_request_id text,
    new_mass_action_id text
);


--
-- Name: objenious_operation_change_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.objenious_operation_change ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.objenious_operation_change_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: objenious_operation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.objenious_operation ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.objenious_operation_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: objenious_operation_change objenious_operation_change_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.objenious_operation_change
    ADD CONSTRAINT objenious_operation_change_pkey PRIMARY KEY (id);


--
-- Name: objenious_operation objenious_operation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.objenious_operation
    ADD CONSTRAINT objenious_operation_pkey PRIMARY KEY (id);


--
-- Name: operation_change; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX operation_change ON public.objenious_operation_change USING btree (operation_id);


--
-- Name: pending_operations; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX pending_operations ON public.objenious_operation USING btree (start_date) WHERE (end_date IS NULL);


--
-- Name: objenious_operation_change fk_operation_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.objenious_operation_change
    ADD CONSTRAINT fk_operation_id FOREIGN KEY (operation_id) REFERENCES public.objenious_operation(id);


--
-- PostgreSQL database dump complete
--

\unrestrict KSNzZnHZpEceNNT6ECpaur3DZ2vfo46zPOlHHzj65wcCLFVfh0bZaudbdKNNiIC

