491 lines
11 KiB
PL/PgSQL
491 lines
11 KiB
PL/PgSQL
--
|
|
-- PostgreSQL database dump
|
|
--
|
|
|
|
\restrict EQkcX1mt4Oqej8UZL2Z1qyvnzIAf3O4TYefngsqIN91Lr6JLNTawzD4OIRSJr2s
|
|
|
|
-- Dumped from database version 18.1
|
|
-- Dumped by pg_dump version 18.1
|
|
|
|
SET statement_timeout = 0;
|
|
SET lock_timeout = 0;
|
|
SET idle_in_transaction_session_timeout = 0;
|
|
SET transaction_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: truncate_tables(character varying); Type: FUNCTION; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE FUNCTION public.truncate_tables(username character varying) RETURNS void
|
|
LANGUAGE plpgsql
|
|
AS $$
|
|
DECLARE
|
|
statements CURSOR FOR
|
|
SELECT tablename FROM pg_tables
|
|
WHERE tableowner = username AND schemaname = 'public';
|
|
BEGIN
|
|
FOR stmt IN statements LOOP
|
|
EXECUTE 'TRUNCATE TABLE ' || quote_ident(stmt.tablename) || ' CASCADE;';
|
|
END LOOP;
|
|
END;
|
|
$$;
|
|
|
|
|
|
SET default_tablespace = '';
|
|
|
|
SET default_table_access_method = heap;
|
|
|
|
--
|
|
-- Name: account; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.account (
|
|
id integer NOT NULL,
|
|
number smallint NOT NULL,
|
|
financial_year_id integer NOT NULL,
|
|
description text NOT NULL,
|
|
sru smallint
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: account_balance; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.account_balance (
|
|
account_number integer NOT NULL,
|
|
financial_year_id integer NOT NULL,
|
|
"in" numeric(12,2) DEFAULT 0 NOT NULL,
|
|
"out" numeric(12,2) DEFAULT 0 NOT NULL,
|
|
in_quantity integer,
|
|
out_quantity integer
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: account_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE SEQUENCE public.account_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
--
|
|
-- Name: account_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER SEQUENCE public.account_id_seq OWNED BY public.account.id;
|
|
|
|
|
|
--
|
|
-- Name: dimension; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.dimension (
|
|
id integer NOT NULL,
|
|
number smallint NOT NULL,
|
|
name text
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: dimension_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE SEQUENCE public.dimension_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
--
|
|
-- Name: dimension_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER SEQUENCE public.dimension_id_seq OWNED BY public.dimension.id;
|
|
|
|
|
|
--
|
|
-- Name: entry; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.entry (
|
|
id integer NOT NULL,
|
|
financial_year_id integer NOT NULL,
|
|
journal_id integer NOT NULL,
|
|
number integer NOT NULL,
|
|
transaction_date date NOT NULL,
|
|
description text,
|
|
entry_date date NOT NULL,
|
|
signature text
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: entry_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE SEQUENCE public.entry_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
--
|
|
-- Name: entry_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER SEQUENCE public.entry_id_seq OWNED BY public.entry.id;
|
|
|
|
|
|
--
|
|
-- Name: financial_year; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.financial_year (
|
|
id integer NOT NULL,
|
|
start_date date NOT NULL,
|
|
end_date date NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: financial_year_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE SEQUENCE public.financial_year_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
--
|
|
-- Name: financial_year_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER SEQUENCE public.financial_year_id_seq OWNED BY public.financial_year.id;
|
|
|
|
|
|
--
|
|
-- Name: journal; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.journal (
|
|
id integer NOT NULL,
|
|
identifier text NOT NULL,
|
|
description text
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: journal_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE SEQUENCE public.journal_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
--
|
|
-- Name: journal_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER SEQUENCE public.journal_id_seq OWNED BY public.journal.id;
|
|
|
|
|
|
--
|
|
-- Name: object; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.object (
|
|
id integer NOT NULL,
|
|
dimension_id integer NOT NULL,
|
|
number smallint NOT NULL,
|
|
name text
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: object_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE SEQUENCE public.object_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
--
|
|
-- Name: object_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER SEQUENCE public.object_id_seq OWNED BY public.object.id;
|
|
|
|
|
|
--
|
|
-- Name: transaction; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.transaction (
|
|
id integer NOT NULL,
|
|
entry_id integer NOT NULL,
|
|
account_number smallint NOT NULL,
|
|
amount numeric(12,2) NOT NULL,
|
|
object_id integer,
|
|
description text,
|
|
transaction_date date,
|
|
quantity numeric(12,2),
|
|
signature text
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: transaction_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE SEQUENCE public.transaction_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
--
|
|
-- Name: transaction_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER SEQUENCE public.transaction_id_seq OWNED BY public.transaction.id;
|
|
|
|
|
|
--
|
|
-- Name: transactions_to_objects; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.transactions_to_objects (
|
|
transaction_id integer NOT NULL,
|
|
object_id integer NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: account id; Type: DEFAULT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.account ALTER COLUMN id SET DEFAULT nextval('public.account_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: dimension id; Type: DEFAULT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.dimension ALTER COLUMN id SET DEFAULT nextval('public.dimension_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: entry id; Type: DEFAULT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.entry ALTER COLUMN id SET DEFAULT nextval('public.entry_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: financial_year id; Type: DEFAULT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.financial_year ALTER COLUMN id SET DEFAULT nextval('public.financial_year_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: journal id; Type: DEFAULT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.journal ALTER COLUMN id SET DEFAULT nextval('public.journal_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: object id; Type: DEFAULT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.object ALTER COLUMN id SET DEFAULT nextval('public.object_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: transaction id; Type: DEFAULT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.transaction ALTER COLUMN id SET DEFAULT nextval('public.transaction_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: account_balance account_balance_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.account_balance
|
|
ADD CONSTRAINT account_balance_pkey PRIMARY KEY (account_number, financial_year_id);
|
|
|
|
|
|
--
|
|
-- Name: account account_number_financial_year_id_key; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.account
|
|
ADD CONSTRAINT account_number_financial_year_id_key UNIQUE (number, financial_year_id);
|
|
|
|
|
|
--
|
|
-- Name: account account_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.account
|
|
ADD CONSTRAINT account_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: dimension dimension_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.dimension
|
|
ADD CONSTRAINT dimension_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: entry entry_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.entry
|
|
ADD CONSTRAINT entry_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: financial_year financial_year_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.financial_year
|
|
ADD CONSTRAINT financial_year_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: financial_year financial_year_start_date_end_date_key; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.financial_year
|
|
ADD CONSTRAINT financial_year_start_date_end_date_key UNIQUE (start_date, end_date);
|
|
|
|
|
|
--
|
|
-- Name: journal journal_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.journal
|
|
ADD CONSTRAINT journal_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: object object_dimension_id_number_key; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.object
|
|
ADD CONSTRAINT object_dimension_id_number_key UNIQUE (dimension_id, number);
|
|
|
|
|
|
--
|
|
-- Name: object object_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.object
|
|
ADD CONSTRAINT object_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: transaction transaction_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.transaction
|
|
ADD CONSTRAINT transaction_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: transactions_to_objects transactions_to_objects_transaction_id_object_id_key; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.transactions_to_objects
|
|
ADD CONSTRAINT transactions_to_objects_transaction_id_object_id_key UNIQUE (transaction_id, object_id);
|
|
|
|
|
|
--
|
|
-- Name: object object_dimension_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.object
|
|
ADD CONSTRAINT object_dimension_id_fkey FOREIGN KEY (dimension_id) REFERENCES public.dimension(id);
|
|
|
|
|
|
--
|
|
-- Name: transaction transaction_entry_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.transaction
|
|
ADD CONSTRAINT transaction_entry_id_fkey FOREIGN KEY (entry_id) REFERENCES public.entry(id);
|
|
|
|
|
|
--
|
|
-- Name: transaction transaction_object_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.transaction
|
|
ADD CONSTRAINT transaction_object_id_fkey FOREIGN KEY (object_id) REFERENCES public.object(id);
|
|
|
|
|
|
--
|
|
-- Name: transactions_to_objects transactions_to_objects_object_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.transactions_to_objects
|
|
ADD CONSTRAINT transactions_to_objects_object_id_fkey FOREIGN KEY (object_id) REFERENCES public.object(id);
|
|
|
|
|
|
--
|
|
-- Name: transactions_to_objects transactions_to_objects_transaction_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.transactions_to_objects
|
|
ADD CONSTRAINT transactions_to_objects_transaction_id_fkey FOREIGN KEY (transaction_id) REFERENCES public.transaction(id);
|
|
|
|
|
|
--
|
|
-- PostgreSQL database dump complete
|
|
--
|
|
|
|
\unrestrict EQkcX1mt4Oqej8UZL2Z1qyvnzIAf3O4TYefngsqIN91Lr6JLNTawzD4OIRSJr2s
|
|
|