--
-- PostgreSQL database dump
--

\connect - calpp

SET search_path = public, pg_catalog;

--
-- TOC entry 4 (OID 38664)
-- Name: contacts; Type: TABLE; Schema: public; Owner: calpp
--

CREATE TABLE contacts (
    contact_id serial NOT NULL,
    title text DEFAULT '',
    initials text DEFAULT '',
    name text NOT NULL,
    qualification text,
    classification text,
    birth_date date,
    termination_date date,
    given_age smallint,
    care_of text,
    guardian text,
    religion text,
    caste text,
    "language" text,
    is_literate boolean DEFAULT true,
    is_active boolean DEFAULT true,
    calling text,
    calling_at text,
    login_name text,
    phone_home text,
    phone_office text,
    phone_mobile text,
    phone_pager text,
    phone_fax text,
    email text,
    web_address text NOT NULL,
    door_no text,
    street text,
    village text,
    taluk text,
    district text,
    state text,
    country text,
    pincode text,
    landmark text,
    office_address text,
    introduced_by_contact_id integer,
    monthly_income money,
    educational_level text,
    login_rights text,
    is_juristic boolean DEFAULT false,
    main_occupation text,
    specialisation text,
    relationship_with_owner text,
    is_friend boolean DEFAULT true,
    access_code text,
    notes text,
    "password" text,
    height text DEFAULT 0,
    built character(1) DEFAULT 'm',
    is_entity boolean DEFAULT 'f',
    css_stylesheet text DEFAULT 'stylesheets/calpp.css',
    group_name text DEFAULT 'public'
);


--
-- TOC entry 5 (OID 38682)
-- Name: procedures; Type: TABLE; Schema: public; Owner: calpp
--

CREATE TABLE procedures (
    procedure_id serial NOT NULL,
    procedure_code text NOT NULL,
    procedure_name text NOT NULL,
    source text NOT NULL,
    main_head text NOT NULL,
    sub_head text NOT NULL,
    country_code character varying(3) DEFAULT 'ind' NOT NULL,
    sub_procedure_in text,
    first_step_code text,
    first_step real,
    invoking_group text DEFAULT 'admin',
    verifying_group text DEFAULT 'manager',
    work_area text,
    script text,
    is_singleton boolean DEFAULT 'f',
    organization text DEFAULT ''
);


--
-- TOC entry 6 (OID 38693)
-- Name: steps; Type: TABLE; Schema: public; Owner: calpp
--

CREATE TABLE steps (
    step_id serial NOT NULL,
    step_code text NOT NULL,
    step_name text NOT NULL,
    procedure_code text NOT NULL,
    step real NOT NULL,
    next_step_code text NOT NULL,
    next_step real NOT NULL,
    next_time_limit real,
    next_time_limit_unit text,
    time_bar_step_code text,
    time_bar_step real,
    default_step real,
    action_by text NOT NULL,
    step_source text NOT NULL,
    is_multi_step boolean,
    script text,
    input_form text
);


--
-- TOC entry 7 (OID 38701)
-- Name: particulars; Type: TABLE; Schema: public; Owner: calpp
--

CREATE TABLE particulars (
    particular_id serial NOT NULL,
    step_id integer NOT NULL,
    heading text DEFAULT '' NOT NULL,
    particular_code text DEFAULT '' NOT NULL,
    particular_name text DEFAULT '' NOT NULL,
    data_type text DEFAULT 'txt' NOT NULL,
    control text DEFAULT 'text' NOT NULL,
    control_tags text DEFAULT '' NOT NULL,
    rank real DEFAULT 1 NOT NULL,
    min_heading smallint DEFAULT 1 NOT NULL,
    max_heading smallint DEFAULT 1 NOT NULL,
    min_key smallint DEFAULT 1 NOT NULL,
    max_key smallint DEFAULT 1 NOT NULL,
    default_min_heading smallint DEFAULT 1 NOT NULL,
    default_min_key smallint DEFAULT 1 NOT NULL,
    stored_in_table text DEFAULT 'facts' NOT NULL,
    field_name text DEFAULT 'fact' NOT NULL,
    default_value text DEFAULT '',
    id_in_table text DEFAULT '',
    scope text DEFAULT 'procedure',
    data_nature character(1) DEFAULT 'R',
    notes text,
    script text
);


--
-- TOC entry 8 (OID 38728)
-- Name: proceedings; Type: TABLE; Schema: public; Owner: calpp
--

CREATE TABLE proceedings (
    proceeding_id serial NOT NULL,
    procedure_code text NOT NULL,
    proceeding_code text NOT NULL,
    proceeding_name text NOT NULL,
    last_completed_step_id integer,
    next_step_due_date date,
    next_step_reminder_date date,
    branch_contact_id integer,
    custom_cat1 text,
    custom_cat2 text,
    entity_id integer,
    start_timestamp timestamp without time zone DEFAULT "timestamp"('now'::text),
    close_timestamp timestamp without time zone,
    status text DEFAULT 'open'
);


--
-- TOC entry 9 (OID 38738)
-- Name: events; Type: TABLE; Schema: public; Owner: calpp
--

CREATE TABLE events (
    event_id serial NOT NULL,
    proceeding_id integer NOT NULL,
    step_id integer NOT NULL,
    step_count integer,
    entry_contact_id integer NOT NULL,
    verification_contact_id integer,
    audit_contact_id integer,
    entry_timestamp timestamp without time zone DEFAULT "timestamp"('now'::text),
    verification_timestamp timestamp without time zone,
    audit_timestamp timestamp without time zone
);


--
-- TOC entry 10 (OID 38744)
-- Name: assertions; Type: TABLE; Schema: public; Owner: calpp
--

CREATE TABLE assertions (
    assertion_id serial NOT NULL,
    event_id integer NOT NULL,
    particular_id integer NOT NULL,
    heading_count smallint DEFAULT 0,
    key_count smallint DEFAULT 0,
    "assertion" text DEFAULT ''
);


--
-- TOC entry 11 (OID 38755)
-- Name: facts; Type: TABLE; Schema: public; Owner: calpp
--

CREATE TABLE facts (
    fact_id serial NOT NULL,
    event_id integer NOT NULL,
    particular_id integer NOT NULL,
    heading_count smallint DEFAULT 1,
    key_count smallint DEFAULT 1,
    fact text
);


--
-- TOC entry 12 (OID 38765)
-- Name: acheads; Type: TABLE; Schema: public; Owner: calpp
--

CREATE TABLE acheads (
    achead_id serial NOT NULL,
    achead_name text NOT NULL,
    nature text NOT NULL,
    achead_type text DEFAULT 'cash' NOT NULL,
    custom_cat1 text DEFAULT '' NOT NULL,
    custom_cat2 text DEFAULT '' NOT NULL,
    is_affecting_profit boolean DEFAULT 'f' NOT NULL,
    is_post_auto_only boolean DEFAULT 'f' NOT NULL,
    is_owned_fund boolean DEFAULT 'f' NOT NULL,
    is_cash_equivalent boolean DEFAULT 'f'
);


--
-- TOC entry 13 (OID 38780)
-- Name: accounts; Type: TABLE; Schema: public; Owner: calpp
--

CREATE TABLE accounts (
    account_id serial NOT NULL,
    account_code text NOT NULL,
    account_name text NOT NULL,
    achead_id integer NOT NULL,
    opening_balance numeric(10,2) DEFAULT 0 NOT NULL,
    achead_sub_name text DEFAULT '',
    entity_id integer
);


--
-- TOC entry 14 (OID 38790)
-- Name: bills; Type: TABLE; Schema: public; Owner: calpp
--

CREATE TABLE bills (
    bill_id serial NOT NULL,
    bill_number text DEFAULT '' NOT NULL,
    bill_date date DEFAULT ('now'::text)::date NOT NULL,
    cash_mode character(1) DEFAULT 'c' NOT NULL,
    recpay character(1) DEFAULT 'r' NOT NULL,
    subgen character(1) DEFAULT 's' NOT NULL,
    chitgroup_code text,
    ticket_number smallint,
    payee_id integer,
    entity_id integer
);


--
-- TOC entry 15 (OID 38803)
-- Name: bill_items; Type: TABLE; Schema: public; Owner: calpp
--

CREATE TABLE bill_items (
    bill_item_id serial NOT NULL,
    bill_id integer NOT NULL,
    rank smallint DEFAULT 0 NOT NULL,
    bill_ac_id integer NOT NULL,
    particular_id integer,
    part_payment smallint DEFAULT 0 NOT NULL,
    narration text NOT NULL,
    debit numeric(10,2) DEFAULT 0 NOT NULL,
    credit numeric(10,2) DEFAULT 0 NOT NULL,
    CHECK ((((debit > 0::numeric) AND (credit = 0::numeric)) OR ((debit = 0::numeric) AND (credit > 0::numeric))))
);


--
-- TOC entry 16 (OID 38816)
-- Name: ledgers; Type: TABLE; Schema: public; Owner: calpp
--

CREATE TABLE ledgers (
    ledger_id serial NOT NULL,
    bill_item_id integer NOT NULL,
    ledger_ac_id integer NOT NULL,
    ledger_detail_ac_id integer NOT NULL,
    ledger_debit numeric(10,2) NOT NULL,
    ledger_credit numeric(10,2) NOT NULL,
    CHECK ((((ledger_debit > 0::numeric) AND (ledger_credit = 0::numeric)) OR ((ledger_debit = 0::numeric) AND (ledger_credit > 0::numeric))))
);


--
-- TOC entry 17 (OID 38822)
-- Name: cheques; Type: TABLE; Schema: public; Owner: calpp
--

CREATE TABLE cheques (
    cheque_id serial NOT NULL,
    bill_id integer NOT NULL,
    cheque_number text,
    cheque_date date,
    drawee_bank text,
    drawee_branch text,
    presented_date date,
    collected_date date
);


--
-- TOC entry 18 (OID 38830)
-- Name: chitgrouptypes; Type: TABLE; Schema: public; Owner: calpp
--

CREATE TABLE chitgrouptypes (
    chitgrouptype_id serial NOT NULL,
    subscribers smallint NOT NULL,
    subscription numeric(10,2) NOT NULL,
    chit_substance text DEFAULT 'money' NOT NULL,
    chit_amount numeric(10,2) NOT NULL,
    instalments smallint NOT NULL,
    chitgroup_prefix text,
    draw_interval text DEFAULT 'monthly' NOT NULL,
    default_foreman_contact_id integer NOT NULL,
    default_foreman_commission real DEFAULT 5 NOT NULL,
    default_foreman_instalment smallint DEFAULT 1 NOT NULL,
    default_si_prized real DEFAULT 0 NOT NULL,
    default_si_non_prized real DEFAULT 0 NOT NULL,
    default_penalty_prized numeric(10,2) DEFAULT 0 NOT NULL,
    default_penalty_non_prized numeric(10,2) DEFAULT 0 NOT NULL
);


--
-- TOC entry 19 (OID 38846)
-- Name: chitgroups; Type: TABLE; Schema: public; Owner: calpp
--

CREATE TABLE chitgroups (
    chitgroup_id serial NOT NULL,
    chitgroup_code text NOT NULL,
    chitgrouptype_id integer NOT NULL,
    proceeding_id integer NOT NULL,
    foreman_commission real DEFAULT 5 NOT NULL,
    foreman_instalment smallint DEFAULT 1 NOT NULL,
    si_prized real DEFAULT 0 NOT NULL,
    si_non_prized real DEFAULT 0 NOT NULL,
    penalty_prized numeric(10,2) DEFAULT 0 NOT NULL,
    penalty_non_prized numeric(10,2) DEFAULT 0 NOT NULL,
    commencement_date date,
    termination_date date,
    last_draw_date date,
    next_draw_date date,
    account_id integer NOT NULL,
    foreman_contact_id integer NOT NULL,
    all_auctions_over_date date,
    prize_paid_to_all_date date,
    all_arrears_collected_date date,
    account_closed_date date,
    current_instalment smallint,
    interest_mode character varying(3) DEFAULT 'cip' NOT NULL
);


--
-- TOC entry 20 (OID 38861)
-- Name: chit_subscribers; Type: TABLE; Schema: public; Owner: calpp
--

CREATE TABLE chit_subscribers (
    chit_subscriber_id serial NOT NULL,
    chit_subscriber_code text,
    ticket_number smallint,
    chitgroup_code text,
    contact_id integer,
    joint_holder_contact_id integer,
    nominee_contact_id integer,
    agent_contact_id integer,
    mode_of_service text DEFAULT 'post',
    rank_sign smallint,
    agreement_signed_date date,
    fraction text DEFAULT 'full',
    prized_date date,
    last_instalment_fully_paid smallint,
    is_defaulter boolean DEFAULT 'n'
);


--
-- TOC entry 21 (OID 38872)
-- Name: chit_transfers; Type: TABLE; Schema: public; Owner: calpp
--

CREATE TABLE chit_transfers (
    chit_transfer_id serial NOT NULL,
    chit_subscriber_code integer NOT NULL,
    removed_contact_id integer NOT NULL,
    added_contact_id integer,
    asnsub character(1) NOT NULL,
    removal_date date,
    substitution_date date,
    is_cancelled boolean DEFAULT 'n',
    old_chit_subscriber_id integer,
    new_chit_subscriber_id integer
);


--
-- TOC entry 22 (OID 38878)
-- Name: auctions; Type: TABLE; Schema: public; Owner: calpp
--

CREATE TABLE auctions (
    auction_id serial NOT NULL,
    auction_date date NOT NULL,
    chitgroup_code text NOT NULL,
    prized_contact_id integer,
    bid_amount numeric(10,2),
    fmc_amount numeric(10,2),
    dividend_amount numeric(10,2),
    share_amount numeric(10,2),
    prize_amount numeric(10,2),
    security_amount numeric(10,2),
    instalment integer,
    prize_paid_date date,
    auction_mode text,
    is_cancelled boolean,
    chit_subscriber_id integer
);


--
-- TOC entry 23 (OID 38886)
-- Name: cheque_returns; Type: TABLE; Schema: public; Owner: calpp
--

CREATE TABLE cheque_returns (
    cheque_return_id serial NOT NULL,
    cheque_id integer NOT NULL,
    return_date date NOT NULL,
    return_reason text NOT NULL,
    action_taken_date date,
    action_taken text
);


--
-- TOC entry 24 (OID 38894)
-- Name: lists; Type: TABLE; Schema: public; Owner: calpp
--

CREATE TABLE lists (
    list_id serial NOT NULL,
    list_name text NOT NULL,
    list_code text,
    list_value text,
    description text
);


--
-- TOC entry 25 (OID 38902)
-- Name: list_sql; Type: TABLE; Schema: public; Owner: calpp
--

CREATE TABLE list_sql (
    list_sql_id serial NOT NULL,
    sql_name text NOT NULL,
    sql_string text NOT NULL,
    description text
);


--
-- TOC entry 26 (OID 38910)
-- Name: tests; Type: TABLE; Schema: public; Owner: calpp
--

CREATE TABLE tests (
    test_id serial NOT NULL,
    test_name text DEFAULT 'test data',
    test_date date DEFAULT date("timestamp"('now'::text)),
    test_time time without time zone DEFAULT "time"("timestamp"('now'::text)),
    test_timestamp timestamp without time zone DEFAULT "timestamp"('now'::text),
    test_bool boolean DEFAULT 'f',
    test_int2 smallint DEFAULT 0,
    test_int4 integer DEFAULT 0,
    test_float real DEFAULT 0,
    test_numeric numeric(10,2) DEFAULT 0
);


--
-- TOC entry 27 (OID 38927)
-- Name: dtps; Type: TABLE; Schema: public; Owner: calpp
--

CREATE TABLE dtps (
    dtp_id serial NOT NULL,
    description text,
    maximum_value text,
    minimum_value text,
    examples text
);


--
-- TOC entry 2 (OID 39465)
-- Name: tokens_seq; Type: SEQUENCE; Schema: public; Owner: calpp
--

CREATE SEQUENCE tokens_seq
    START 1
    INCREMENT 1
    MAXVALUE 9223372036854775807
    MINVALUE 1
    CACHE 1;


\connect - ramanraj

SET search_path = public, pg_catalog;

--
-- TOC entry 28 (OID 39467)
-- Name: tokens; Type: TABLE; Schema: public; Owner: ramanraj
--

CREATE TABLE tokens (
    token_id text NOT NULL,
    contact_id integer NOT NULL
);


--
-- TOC entry 29 (OID 56521)
-- Name: vwh_contacts_name_address_phone; Type: VIEW; Schema: public; Owner: ramanraj
--

CREATE VIEW vwh_contacts_name_address_phone AS
    SELECT contacts.contact_id, ((((((((((((((((((((((('<p><a href=Contacts.php?action=EditContact&contact_id='::text || (contacts.contact_id)::text) || '>'::text) || contacts.title) || ' '::text) || ' '::text) || contacts.name) || ', '::text) || contacts.qualification) || '</a> '::text) || contacts.care_of) || ' '::text) || contacts.guardian) || ', '::text) || contacts.door_no) || ' '::text) || contacts.street) || ', '::text) || contacts.village) || ', '::text) || ' '::text) || contacts.district) || ', '::text) || contacts.pincode) AS particulars, contacts.phone_home, contacts.phone_office, contacts.phone_mobile, (((('<a href=mailto:'::text || contacts.email) || '>'::text) || contacts.email) || '</a>'::text) AS mail FROM contacts;


--
-- TOC entry 30 (OID 56601)
-- Name: words; Type: TABLE; Schema: public; Owner: ramanraj
--

CREATE TABLE words (
    word_id serial NOT NULL,
    word text,
    word_meaning text,
    word_notes text
);


--
-- TOC entry 31 (OID 56660)
-- Name: test; Type: VIEW; Schema: public; Owner: ramanraj
--

CREATE VIEW test AS
    SELECT bill_items.credit AS cr, bill_items.debit AS dr FROM bill_items;


--
-- TOC entry 32 (OID 65219)
-- Name: details; Type: TABLE; Schema: public; Owner: ramanraj
--

CREATE TABLE details (
    detail_id serial NOT NULL,
    event_id integer NOT NULL,
    particular_id integer NOT NULL,
    heading_count smallint NOT NULL,
    key_count smallint NOT NULL,
    detail text DEFAULT '' NOT NULL
);


--
-- TOC entry 33 (OID 65233)
-- Name: v_bills_ext; Type: VIEW; Schema: public; Owner: ramanraj
--

CREATE VIEW v_bills_ext AS
    SELECT bill_items.bill_item_id, bill_items.bill_id, bill_items.rank, bill_items.bill_ac_id, bill_items.particular_id, bill_items.part_payment, bill_items.narration, bill_items.debit, bill_items.credit, bills.bill_number, bills.bill_date, bills.cash_mode, bills.recpay, bills.subgen, bills.chitgroup_code, bills.ticket_number, bills.payee_id, bills.entity_id FROM bill_items, bills WHERE (bill_items.bill_id = bills.bill_id);


--
-- TOC entry 34 (OID 65237)
-- Name: index_sqls; Type: TABLE; Schema: public; Owner: ramanraj
--

CREATE TABLE index_sqls (
    index_sql_id serial NOT NULL,
    index_name text NOT NULL,
    start_table text DEFAULT '' NOT NULL,
    end_sql text DEFAULT '' NOT NULL
);


--
-- TOC entry 35 (OID 65251)
-- Name: index_headings; Type: TABLE; Schema: public; Owner: ramanraj
--

CREATE TABLE index_headings (
    index_heading_id serial NOT NULL,
    index_sql_id integer NOT NULL,
    heading_name text DEFAULT '' NOT NULL,
    index_path text DEFAULT '' NOT NULL
);


--
-- TOC entry 36 (OID 65311)
-- Name: v_acheads_accounts; Type: VIEW; Schema: public; Owner: ramanraj
--

CREATE VIEW v_acheads_accounts AS
    SELECT accounts.account_id, accounts.account_code, accounts.account_name, accounts.opening_balance, accounts.achead_sub_name, accounts.entity_id, acheads.achead_id, acheads.achead_name, acheads.nature, acheads.achead_type, acheads.custom_cat1, acheads.custom_cat2, acheads.is_affecting_profit, acheads.is_post_auto_only, acheads.is_owned_fund, acheads.is_cash_equivalent FROM accounts, acheads WHERE (acheads.achead_id = accounts.achead_id);


--
-- TOC entry 37 (OID 65316)
-- Name: v_procedures_steps; Type: VIEW; Schema: public; Owner: ramanraj
--

CREATE VIEW v_procedures_steps AS
    SELECT procedures.procedure_id, procedures.procedure_code, procedures.procedure_name, procedures.source, procedures.main_head, procedures.sub_head, procedures.country_code, procedures.sub_procedure_in, procedures.first_step_code, procedures.first_step, procedures.invoking_group, procedures.verifying_group, procedures.work_area, steps.step_id, steps.step_code, steps.step_name, steps.step, steps.next_step_code, steps.next_step, steps.next_time_limit, steps.next_time_limit_unit, steps.time_bar_step_code, steps.time_bar_step, steps.default_step, steps.action_by, steps.step_source, steps.is_multi_step, steps.script, steps.input_form FROM procedures, steps WHERE (procedures.procedure_code = steps.procedure_code);


--
-- TOC entry 38 (OID 65321)
-- Name: v_procedures_steps_particulars; Type: VIEW; Schema: public; Owner: ramanraj
--

CREATE VIEW v_procedures_steps_particulars AS
    SELECT particulars.particular_id, particulars.heading, particulars.particular_code, particulars.particular_name, particulars.data_type, particulars.control, particulars.control_tags, particulars.rank, particulars.min_heading, particulars.max_heading, particulars.min_key, particulars.max_key, particulars.default_min_heading, particulars.default_min_key, particulars.stored_in_table, particulars.field_name, particulars.default_value, particulars.id_in_table, particulars.scope, particulars.data_nature, particulars.notes, v_procedures_steps.procedure_id, v_procedures_steps.procedure_code, v_procedures_steps.procedure_name, v_procedures_steps.source, v_procedures_steps.main_head, v_procedures_steps.sub_head, v_procedures_steps.country_code, v_procedures_steps.sub_procedure_in, v_procedures_steps.first_step_code, v_procedures_steps.first_step, v_procedures_steps.invoking_group, v_procedures_steps.verifying_group, v_procedures_steps.work_area, v_procedures_steps.step_id, v_procedures_steps.step_code, v_procedures_steps.step_name, v_procedures_steps.step, v_procedures_steps.next_step_code, v_procedures_steps.next_step, v_procedures_steps.next_time_limit, v_procedures_steps.next_time_limit_unit, v_procedures_steps.time_bar_step_code, v_procedures_steps.time_bar_step, v_procedures_steps.default_step, v_procedures_steps.action_by, v_procedures_steps.step_source, v_procedures_steps.is_multi_step, v_procedures_steps.input_form FROM particulars, v_procedures_steps WHERE (particulars.step_id = v_procedures_steps.step_id);


--
-- TOC entry 39 (OID 65364)
-- Name: v_pp; Type: VIEW; Schema: public; Owner: ramanraj
--

CREATE VIEW v_pp AS
    SELECT procedures.procedure_id, procedures.procedure_code, procedures.procedure_name, procedures.source, procedures.main_head, procedures.sub_head, procedures.country_code, procedures.sub_procedure_in, procedures.first_step_code, procedures.first_step, procedures.invoking_group, procedures.verifying_group, procedures.work_area, proceedings.proceeding_id, proceedings.proceeding_code, proceedings.proceeding_name, proceedings.last_completed_step_id, proceedings.next_step_due_date, proceedings.next_step_reminder_date, proceedings.branch_contact_id, proceedings.custom_cat1, proceedings.custom_cat2, proceedings.entity_id, proceedings.start_timestamp, proceedings.close_timestamp, proceedings.status FROM procedures, proceedings WHERE (procedures.procedure_code = proceedings.procedure_code);


--
-- TOC entry 40 (OID 65368)
-- Name: v_pp_s; Type: VIEW; Schema: public; Owner: ramanraj
--

CREATE VIEW v_pp_s AS
    SELECT steps.step_id, steps.step_code, steps.step_name, steps.step, steps.next_step_code, steps.next_step, steps.next_time_limit, steps.next_time_limit_unit, steps.time_bar_step_code, steps.time_bar_step, steps.default_step, steps.action_by, steps.step_source, steps.is_multi_step, steps.input_form, v_pp.procedure_id, v_pp.procedure_code, v_pp.procedure_name, v_pp.source, v_pp.main_head, v_pp.sub_head, v_pp.country_code, v_pp.sub_procedure_in, v_pp.first_step_code, v_pp.first_step, v_pp.invoking_group, v_pp.verifying_group, v_pp.work_area, v_pp.proceeding_id, v_pp.proceeding_code, v_pp.proceeding_name, v_pp.last_completed_step_id, v_pp.next_step_due_date, v_pp.next_step_reminder_date, v_pp.branch_contact_id, v_pp.custom_cat1, v_pp.custom_cat2, v_pp.entity_id, v_pp.start_timestamp, v_pp.close_timestamp, v_pp.status FROM steps, v_pp WHERE (v_pp.procedure_code = steps.procedure_code);


--
-- TOC entry 41 (OID 65372)
-- Name: v_pp_se; Type: VIEW; Schema: public; Owner: ramanraj
--

CREATE VIEW v_pp_se AS
    SELECT events.event_id, events.step_count, events.entry_contact_id, events.verification_contact_id, events.audit_contact_id, events.entry_timestamp, events.verification_timestamp, events.audit_timestamp, v_pp_s.step_id, v_pp_s.step_code, v_pp_s.step_name, v_pp_s.step, v_pp_s.next_step_code, v_pp_s.next_step, v_pp_s.next_time_limit, v_pp_s.next_time_limit_unit, v_pp_s.time_bar_step_code, v_pp_s.time_bar_step, v_pp_s.default_step, v_pp_s.action_by, v_pp_s.step_source, v_pp_s.is_multi_step, v_pp_s.input_form, v_pp_s.procedure_id, v_pp_s.procedure_code, v_pp_s.procedure_name, v_pp_s.source, v_pp_s.main_head, v_pp_s.sub_head, v_pp_s.country_code, v_pp_s.sub_procedure_in, v_pp_s.first_step_code, v_pp_s.first_step, v_pp_s.invoking_group, v_pp_s.verifying_group, v_pp_s.work_area, v_pp_s.proceeding_id, v_pp_s.proceeding_code, v_pp_s.proceeding_name, v_pp_s.last_completed_step_id, v_pp_s.next_step_due_date, v_pp_s.next_step_reminder_date, v_pp_s.branch_contact_id, v_pp_s.custom_cat1, v_pp_s.custom_cat2, v_pp_s.entity_id, v_pp_s.start_timestamp, v_pp_s.close_timestamp, v_pp_s.status FROM events, v_pp_s WHERE (events.proceeding_id = v_pp_s.proceeding_id);


--
-- TOC entry 42 (OID 65378)
-- Name: v_proceedings_events; Type: VIEW; Schema: public; Owner: ramanraj
--

CREATE VIEW v_proceedings_events AS
    SELECT events.event_id, events.step_id, events.step_count, events.entry_contact_id, events.verification_contact_id, events.audit_contact_id, events.entry_timestamp, events.verification_timestamp, events.audit_timestamp, proceedings.proceeding_id, proceedings.procedure_code, proceedings.proceeding_code, proceedings.proceeding_name, proceedings.last_completed_step_id, proceedings.next_step_due_date, proceedings.next_step_reminder_date, proceedings.branch_contact_id, proceedings.custom_cat1, proceedings.custom_cat2, proceedings.entity_id, proceedings.start_timestamp, proceedings.close_timestamp, proceedings.status FROM events, proceedings WHERE (proceedings.proceeding_id = events.proceeding_id);


--
-- TOC entry 43 (OID 65381)
-- Name: v_proceedings_events_assertions; Type: VIEW; Schema: public; Owner: ramanraj
--

CREATE VIEW v_proceedings_events_assertions AS
    SELECT assertions.assertion_id, assertions.particular_id, assertions.heading_count, assertions.key_count, assertions."assertion", v_proceedings_events.event_id, v_proceedings_events.step_id, v_proceedings_events.step_count, v_proceedings_events.entry_contact_id, v_proceedings_events.verification_contact_id, v_proceedings_events.audit_contact_id, v_proceedings_events.entry_timestamp, v_proceedings_events.verification_timestamp, v_proceedings_events.audit_timestamp, v_proceedings_events.proceeding_id, v_proceedings_events.procedure_code, v_proceedings_events.proceeding_code, v_proceedings_events.proceeding_name, v_proceedings_events.last_completed_step_id, v_proceedings_events.next_step_due_date, v_proceedings_events.next_step_reminder_date, v_proceedings_events.branch_contact_id, v_proceedings_events.custom_cat1, v_proceedings_events.custom_cat2, v_proceedings_events.entity_id, v_proceedings_events.start_timestamp, v_proceedings_events.close_timestamp, v_proceedings_events.status FROM assertions, v_proceedings_events WHERE (v_proceedings_events.event_id = assertions.event_id);


--
-- TOC entry 44 (OID 65386)
-- Name: v_calpp; Type: VIEW; Schema: public; Owner: ramanraj
--

CREATE VIEW v_calpp AS
    SELECT v_procedures_steps_particulars.particular_id, v_procedures_steps_particulars.heading, v_procedures_steps_particulars.particular_code, v_procedures_steps_particulars.particular_name, v_procedures_steps_particulars.data_type, v_procedures_steps_particulars.control, v_procedures_steps_particulars.control_tags, v_procedures_steps_particulars.rank, v_procedures_steps_particulars.min_heading, v_procedures_steps_particulars.max_heading, v_procedures_steps_particulars.min_key, v_procedures_steps_particulars.max_key, v_procedures_steps_particulars.default_min_heading, v_procedures_steps_particulars.default_min_key, v_procedures_steps_particulars.stored_in_table, v_procedures_steps_particulars.field_name, v_procedures_steps_particulars.default_value, v_procedures_steps_particulars.id_in_table, v_procedures_steps_particulars.scope, v_procedures_steps_particulars.data_nature, v_procedures_steps_particulars.notes, v_procedures_steps_particulars.procedure_id, v_procedures_steps_particulars.procedure_code, v_procedures_steps_particulars.procedure_name, v_procedures_steps_particulars.source, v_procedures_steps_particulars.main_head, v_procedures_steps_particulars.sub_head, v_procedures_steps_particulars.country_code, v_procedures_steps_particulars.sub_procedure_in, v_procedures_steps_particulars.first_step_code, v_procedures_steps_particulars.first_step, v_procedures_steps_particulars.invoking_group, v_procedures_steps_particulars.verifying_group, v_procedures_steps_particulars.work_area, v_procedures_steps_particulars.step_id, v_procedures_steps_particulars.step_code, v_procedures_steps_particulars.step_name, v_procedures_steps_particulars.step, v_procedures_steps_particulars.next_step_code, v_procedures_steps_particulars.next_step, v_procedures_steps_particulars.next_time_limit, v_procedures_steps_particulars.next_time_limit_unit, v_procedures_steps_particulars.time_bar_step_code, v_procedures_steps_particulars.time_bar_step, v_procedures_steps_particulars.default_step, v_procedures_steps_particulars.action_by, v_procedures_steps_particulars.step_source, v_procedures_steps_particulars.is_multi_step, v_procedures_steps_particulars.input_form, v_proceedings_events_assertions.assertion_id, v_proceedings_events_assertions.heading_count, v_proceedings_events_assertions.key_count, v_proceedings_events_assertions."assertion", v_proceedings_events_assertions.event_id, v_proceedings_events_assertions.step_count, v_proceedings_events_assertions.entry_contact_id, v_proceedings_events_assertions.verification_contact_id, v_proceedings_events_assertions.audit_contact_id, v_proceedings_events_assertions.entry_timestamp, v_proceedings_events_assertions.verification_timestamp, v_proceedings_events_assertions.audit_timestamp, v_proceedings_events_assertions.proceeding_id, v_proceedings_events_assertions.proceeding_code, v_proceedings_events_assertions.proceeding_name, v_proceedings_events_assertions.last_completed_step_id, v_proceedings_events_assertions.next_step_due_date, v_proceedings_events_assertions.next_step_reminder_date, v_proceedings_events_assertions.branch_contact_id, v_proceedings_events_assertions.custom_cat1, v_proceedings_events_assertions.custom_cat2, v_proceedings_events_assertions.entity_id, v_proceedings_events_assertions.start_timestamp, v_proceedings_events_assertions.close_timestamp, v_proceedings_events_assertions.status FROM v_procedures_steps_particulars, v_proceedings_events_assertions WHERE (((v_procedures_steps_particulars.procedure_code = v_procedures_steps_particulars.procedure_code) AND (v_procedures_steps_particulars.particular_id = v_proceedings_events_assertions.particular_id)) AND (v_procedures_steps_particulars.step_id = v_proceedings_events_assertions.step_id));


--
-- TOC entry 45 (OID 65426)
-- Name: v_calpp_contacts; Type: VIEW; Schema: public; Owner: ramanraj
--

CREATE VIEW v_calpp_contacts AS
    SELECT contacts.contact_id, contacts.title, contacts.initials, contacts.name, contacts.qualification, contacts.classification, contacts.birth_date, contacts.termination_date, contacts.given_age, contacts.care_of, contacts.guardian, contacts.religion, contacts.caste, contacts."language", contacts.is_literate, contacts.is_active, contacts.calling, contacts.calling_at, contacts.login_name, contacts.phone_home, contacts.phone_office, contacts.phone_mobile, contacts.phone_pager, contacts.phone_fax, contacts.email, contacts.web_address, contacts.door_no, contacts.street, contacts.village, contacts.taluk, contacts.district, contacts.state, contacts.country, contacts.pincode, contacts.landmark, contacts.office_address, contacts.introduced_by_contact_id, contacts.monthly_income, contacts.educational_level, contacts.login_rights, contacts.is_juristic, contacts.main_occupation, contacts.specialisation, contacts.relationship_with_owner, contacts.is_friend, contacts.access_code, contacts."password", contacts.height, contacts.built, contacts.is_entity, contacts.css_stylesheet, contacts.group_name, v_calpp.particular_id, v_calpp.heading, v_calpp.particular_code, v_calpp.particular_name, v_calpp.data_type, v_calpp.control, v_calpp.control_tags, v_calpp.rank, v_calpp.min_heading, v_calpp.max_heading, v_calpp.min_key, v_calpp.max_key, v_calpp.default_min_heading, v_calpp.default_min_key, v_calpp.stored_in_table, v_calpp.field_name, v_calpp.default_value, v_calpp.id_in_table, v_calpp.scope, v_calpp.data_nature, v_calpp.notes, v_calpp.procedure_id, v_calpp.procedure_code, v_calpp.procedure_name, v_calpp.source, v_calpp.main_head, v_calpp.sub_head, v_calpp.country_code, v_calpp.sub_procedure_in, v_calpp.first_step_code, v_calpp.first_step, v_calpp.invoking_group, v_calpp.verifying_group, v_calpp.work_area, v_calpp.step_id, v_calpp.step_code, v_calpp.step_name, v_calpp.step, v_calpp.next_step_code, v_calpp.next_step, v_calpp.next_time_limit, v_calpp.next_time_limit_unit, v_calpp.time_bar_step_code, v_calpp.time_bar_step, v_calpp.default_step, v_calpp.action_by, v_calpp.step_source, v_calpp.is_multi_step, v_calpp.input_form, v_calpp.assertion_id, v_calpp.heading_count, v_calpp.key_count, v_calpp."assertion", v_calpp.event_id, v_calpp.step_count, v_calpp.entry_contact_id, v_calpp.verification_contact_id, v_calpp.audit_contact_id, v_calpp.entry_timestamp, v_calpp.verification_timestamp, v_calpp.audit_timestamp, v_calpp.proceeding_id, v_calpp.proceeding_code, v_calpp.proceeding_name, v_calpp.last_completed_step_id, v_calpp.next_step_due_date, v_calpp.next_step_reminder_date, v_calpp.branch_contact_id, v_calpp.custom_cat1, v_calpp.custom_cat2, v_calpp.entity_id, v_calpp.start_timestamp, v_calpp.close_timestamp, v_calpp.status FROM contacts, v_calpp WHERE (((contacts.contact_id)::text = v_calpp."assertion") AND (v_calpp.id_in_table = 'contacts'::text));


--
-- TOC entry 46 (OID 65430)
-- Name: v_calpp_entries; Type: VIEW; Schema: public; Owner: ramanraj
--

CREATE VIEW v_calpp_entries AS
    SELECT contacts.contact_id, contacts.title, contacts.initials, contacts.name, contacts.qualification, contacts.classification, contacts.birth_date, contacts.termination_date, contacts.given_age, contacts.care_of, contacts.guardian, contacts.religion, contacts.caste, contacts."language", contacts.is_literate, contacts.is_active, contacts.calling, contacts.calling_at, contacts.login_name, contacts.phone_home, contacts.phone_office, contacts.phone_mobile, contacts.phone_pager, contacts.phone_fax, contacts.email, contacts.web_address, contacts.door_no, contacts.street, contacts.village, contacts.taluk, contacts.district, contacts.state, contacts.country, contacts.pincode, contacts.landmark, contacts.office_address, contacts.introduced_by_contact_id, contacts.monthly_income, contacts.educational_level, contacts.login_rights, contacts.is_juristic, contacts.main_occupation, contacts.specialisation, contacts.relationship_with_owner, contacts.is_friend, contacts.access_code, contacts."password", contacts.height, contacts.built, contacts.is_entity, contacts.css_stylesheet, contacts.group_name, v_calpp.particular_id, v_calpp.heading, v_calpp.particular_code, v_calpp.particular_name, v_calpp.data_type, v_calpp.control, v_calpp.control_tags, v_calpp.rank, v_calpp.min_heading, v_calpp.max_heading, v_calpp.min_key, v_calpp.max_key, v_calpp.default_min_heading, v_calpp.default_min_key, v_calpp.stored_in_table, v_calpp.field_name, v_calpp.default_value, v_calpp.id_in_table, v_calpp.scope, v_calpp.data_nature, v_calpp.notes, v_calpp.procedure_id, v_calpp.procedure_code, v_calpp.procedure_name, v_calpp.source, v_calpp.main_head, v_calpp.sub_head, v_calpp.country_code, v_calpp.sub_procedure_in, v_calpp.first_step_code, v_calpp.first_step, v_calpp.invoking_group, v_calpp.verifying_group, v_calpp.work_area, v_calpp.step_id, v_calpp.step_code, v_calpp.step_name, v_calpp.step, v_calpp.next_step_code, v_calpp.next_step, v_calpp.next_time_limit, v_calpp.next_time_limit_unit, v_calpp.time_bar_step_code, v_calpp.time_bar_step, v_calpp.default_step, v_calpp.action_by, v_calpp.step_source, v_calpp.is_multi_step, v_calpp.input_form, v_calpp.assertion_id, v_calpp.heading_count, v_calpp.key_count, v_calpp."assertion", v_calpp.event_id, v_calpp.step_count, v_calpp.entry_contact_id, v_calpp.verification_contact_id, v_calpp.audit_contact_id, v_calpp.entry_timestamp, v_calpp.verification_timestamp, v_calpp.audit_timestamp, v_calpp.proceeding_id, v_calpp.proceeding_code, v_calpp.proceeding_name, v_calpp.last_completed_step_id, v_calpp.next_step_due_date, v_calpp.next_step_reminder_date, v_calpp.branch_contact_id, v_calpp.custom_cat1, v_calpp.custom_cat2, v_calpp.entity_id, v_calpp.start_timestamp, v_calpp.close_timestamp, v_calpp.status FROM contacts, v_calpp WHERE (contacts.contact_id = v_calpp.entry_contact_id);


--
-- TOC entry 3 (OID 65483)
-- Name: proceedings_name_seq; Type: SEQUENCE; Schema: public; Owner: ramanraj
--

CREATE SEQUENCE proceedings_name_seq
    START 1
    INCREMENT 1
    MAXVALUE 9223372036854775807
    MINVALUE 1
    CACHE 1;


--
-- TOC entry 47 (OID 65573)
-- Name: documents; Type: TABLE; Schema: public; Owner: ramanraj
--

CREATE TABLE documents (
    document_id serial NOT NULL,
    document_title text,
    document text
);


--
-- TOC entry 48 (OID 65607)
-- Name: v_calpp_documents; Type: VIEW; Schema: public; Owner: ramanraj
--

CREATE VIEW v_calpp_documents AS
    SELECT documents.document_id, documents.document_title, documents.document, v_calpp.particular_id, v_calpp.heading, v_calpp.particular_code, v_calpp.particular_name, v_calpp.data_type, v_calpp.control, v_calpp.control_tags, v_calpp.rank, v_calpp.min_heading, v_calpp.max_heading, v_calpp.min_key, v_calpp.max_key, v_calpp.default_min_heading, v_calpp.default_min_key, v_calpp.stored_in_table, v_calpp.field_name, v_calpp.default_value, v_calpp.id_in_table, v_calpp.scope, v_calpp.data_nature, v_calpp.notes, v_calpp.procedure_id, v_calpp.procedure_code, v_calpp.procedure_name, v_calpp.source, v_calpp.main_head, v_calpp.sub_head, v_calpp.country_code, v_calpp.sub_procedure_in, v_calpp.first_step_code, v_calpp.first_step, v_calpp.invoking_group, v_calpp.verifying_group, v_calpp.work_area, v_calpp.step_id, v_calpp.step_code, v_calpp.step_name, v_calpp.step, v_calpp.next_step_code, v_calpp.next_step, v_calpp.next_time_limit, v_calpp.next_time_limit_unit, v_calpp.time_bar_step_code, v_calpp.time_bar_step, v_calpp.default_step, v_calpp.action_by, v_calpp.step_source, v_calpp.is_multi_step, v_calpp.input_form, v_calpp.assertion_id, v_calpp.heading_count, v_calpp.key_count, v_calpp."assertion", v_calpp.event_id, v_calpp.step_count, v_calpp.entry_contact_id, v_calpp.verification_contact_id, v_calpp.audit_contact_id, v_calpp.entry_timestamp, v_calpp.verification_timestamp, v_calpp.audit_timestamp, v_calpp.proceeding_id, v_calpp.proceeding_code, v_calpp.proceeding_name, v_calpp.last_completed_step_id, v_calpp.next_step_due_date, v_calpp.next_step_reminder_date, v_calpp.branch_contact_id, v_calpp.custom_cat1, v_calpp.custom_cat2, v_calpp.entity_id, v_calpp.start_timestamp, v_calpp.close_timestamp, v_calpp.status FROM documents, v_calpp WHERE (((documents.document_id)::text = v_calpp."assertion") AND (v_calpp.control = 'form'::text));


--
-- TOC entry 78 (OID 56609)
-- Name: word_words_ukey; Type: INDEX; Schema: public; Owner: ramanraj
--

CREATE UNIQUE INDEX word_words_ukey ON words USING btree (word);


\connect - calpp

SET search_path = public, pg_catalog;

--
-- TOC entry 52 (OID 65211)
-- Name: procedure_code_steps_key; Type: INDEX; Schema: public; Owner: calpp
--

CREATE INDEX procedure_code_steps_key ON steps USING btree (procedure_code);


--
-- TOC entry 55 (OID 65212)
-- Name: step_id_particulars_key; Type: INDEX; Schema: public; Owner: calpp
--

CREATE INDEX step_id_particulars_key ON particulars USING btree (step_id);


--
-- TOC entry 58 (OID 65213)
-- Name: proceeding_id_events_key; Type: INDEX; Schema: public; Owner: calpp
--

CREATE INDEX proceeding_id_events_key ON events USING btree (proceeding_id);


--
-- TOC entry 60 (OID 65214)
-- Name: event_id_assertions_key; Type: INDEX; Schema: public; Owner: calpp
--

CREATE INDEX event_id_assertions_key ON assertions USING btree (event_id);


\connect - ramanraj

SET search_path = public, pg_catalog;

--
-- TOC entry 79 (OID 65226)
-- Name: event_id_details_key; Type: INDEX; Schema: public; Owner: ramanraj
--

CREATE INDEX event_id_details_key ON details USING btree (event_id);


--
-- TOC entry 80 (OID 65227)
-- Name: particular_id_details_key; Type: INDEX; Schema: public; Owner: ramanraj
--

CREATE INDEX particular_id_details_key ON details USING btree (particular_id);


\connect - calpp

SET search_path = public, pg_catalog;

--
-- TOC entry 49 (OID 39367)
-- Name: contacts_pkey; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY contacts
    ADD CONSTRAINT contacts_pkey PRIMARY KEY (contact_id);


--
-- TOC entry 50 (OID 39369)
-- Name: procedures_pkey; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY procedures
    ADD CONSTRAINT procedures_pkey PRIMARY KEY (procedure_id);


--
-- TOC entry 51 (OID 39371)
-- Name: procedures_procedure_code_key; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY procedures
    ADD CONSTRAINT procedures_procedure_code_key UNIQUE (procedure_code);


--
-- TOC entry 53 (OID 39373)
-- Name: steps_pkey; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY steps
    ADD CONSTRAINT steps_pkey PRIMARY KEY (step_id);


--
-- TOC entry 84 (OID 39375)
-- Name: $1; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY steps
    ADD CONSTRAINT "$1" FOREIGN KEY (procedure_code) REFERENCES procedures(procedure_code) ON UPDATE NO ACTION ON DELETE CASCADE;


--
-- TOC entry 54 (OID 39379)
-- Name: particulars_pkey; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY particulars
    ADD CONSTRAINT particulars_pkey PRIMARY KEY (particular_id);


--
-- TOC entry 85 (OID 39381)
-- Name: $1; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY particulars
    ADD CONSTRAINT "$1" FOREIGN KEY (step_id) REFERENCES steps(step_id) ON UPDATE NO ACTION ON DELETE CASCADE;


--
-- TOC entry 62 (OID 39385)
-- Name: acheads_pkey; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY acheads
    ADD CONSTRAINT acheads_pkey PRIMARY KEY (achead_id);


--
-- TOC entry 63 (OID 39387)
-- Name: accounts_pkey; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY accounts
    ADD CONSTRAINT accounts_pkey PRIMARY KEY (account_id);


--
-- TOC entry 86 (OID 39389)
-- Name: $1; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY accounts
    ADD CONSTRAINT "$1" FOREIGN KEY (achead_id) REFERENCES acheads(achead_id) ON UPDATE NO ACTION ON DELETE RESTRICT;


--
-- TOC entry 87 (OID 39393)
-- Name: $2; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY accounts
    ADD CONSTRAINT "$2" FOREIGN KEY (entity_id) REFERENCES contacts(contact_id) ON UPDATE NO ACTION ON DELETE RESTRICT;


--
-- TOC entry 64 (OID 39397)
-- Name: bills_pkey; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY bills
    ADD CONSTRAINT bills_pkey PRIMARY KEY (bill_id);


--
-- TOC entry 88 (OID 39399)
-- Name: $1; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY bills
    ADD CONSTRAINT "$1" FOREIGN KEY (payee_id) REFERENCES contacts(contact_id) ON UPDATE NO ACTION ON DELETE RESTRICT;


--
-- TOC entry 89 (OID 39403)
-- Name: $2; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY bills
    ADD CONSTRAINT "$2" FOREIGN KEY (entity_id) REFERENCES contacts(contact_id) ON UPDATE NO ACTION ON DELETE RESTRICT;


--
-- TOC entry 65 (OID 39407)
-- Name: bill_items_pkey; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY bill_items
    ADD CONSTRAINT bill_items_pkey PRIMARY KEY (bill_item_id);


--
-- TOC entry 90 (OID 39409)
-- Name: $2; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY bill_items
    ADD CONSTRAINT "$2" FOREIGN KEY (bill_id) REFERENCES bills(bill_id) ON UPDATE NO ACTION ON DELETE CASCADE;


--
-- TOC entry 91 (OID 39413)
-- Name: $3; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY bill_items
    ADD CONSTRAINT "$3" FOREIGN KEY (bill_ac_id) REFERENCES accounts(account_id) ON UPDATE NO ACTION ON DELETE NO ACTION;


--
-- TOC entry 66 (OID 39417)
-- Name: ledgers_pkey; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY ledgers
    ADD CONSTRAINT ledgers_pkey PRIMARY KEY (ledger_id);


--
-- TOC entry 92 (OID 39419)
-- Name: $2; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY ledgers
    ADD CONSTRAINT "$2" FOREIGN KEY (bill_item_id) REFERENCES bill_items(bill_item_id) ON UPDATE NO ACTION ON DELETE CASCADE;


--
-- TOC entry 93 (OID 39423)
-- Name: $3; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY ledgers
    ADD CONSTRAINT "$3" FOREIGN KEY (ledger_ac_id) REFERENCES accounts(account_id) ON UPDATE NO ACTION ON DELETE NO ACTION;


--
-- TOC entry 94 (OID 39427)
-- Name: $4; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY ledgers
    ADD CONSTRAINT "$4" FOREIGN KEY (ledger_detail_ac_id) REFERENCES accounts(account_id) ON UPDATE NO ACTION ON DELETE NO ACTION;


--
-- TOC entry 67 (OID 39431)
-- Name: cheques_pkey; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY cheques
    ADD CONSTRAINT cheques_pkey PRIMARY KEY (cheque_id);


--
-- TOC entry 95 (OID 39433)
-- Name: $1; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY cheques
    ADD CONSTRAINT "$1" FOREIGN KEY (bill_id) REFERENCES bills(bill_id) ON UPDATE NO ACTION ON DELETE CASCADE;


--
-- TOC entry 68 (OID 39437)
-- Name: chitgrouptypes_pkey; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY chitgrouptypes
    ADD CONSTRAINT chitgrouptypes_pkey PRIMARY KEY (chitgrouptype_id);


--
-- TOC entry 69 (OID 39439)
-- Name: chitgroups_pkey; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY chitgroups
    ADD CONSTRAINT chitgroups_pkey PRIMARY KEY (chitgroup_id);


--
-- TOC entry 70 (OID 39441)
-- Name: chit_subscribers_pkey; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY chit_subscribers
    ADD CONSTRAINT chit_subscribers_pkey PRIMARY KEY (chit_subscriber_id);


--
-- TOC entry 71 (OID 39443)
-- Name: chit_transfers_pkey; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY chit_transfers
    ADD CONSTRAINT chit_transfers_pkey PRIMARY KEY (chit_transfer_id);


--
-- TOC entry 72 (OID 39445)
-- Name: auctions_pkey; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY auctions
    ADD CONSTRAINT auctions_pkey PRIMARY KEY (auction_id);


--
-- TOC entry 73 (OID 39447)
-- Name: cheque_returns_pkey; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY cheque_returns
    ADD CONSTRAINT cheque_returns_pkey PRIMARY KEY (cheque_return_id);


--
-- TOC entry 74 (OID 39449)
-- Name: lists_pkey; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY lists
    ADD CONSTRAINT lists_pkey PRIMARY KEY (list_id);


--
-- TOC entry 75 (OID 39451)
-- Name: list_sql_pkey; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY list_sql
    ADD CONSTRAINT list_sql_pkey PRIMARY KEY (list_sql_id);


--
-- TOC entry 61 (OID 39453)
-- Name: facts_pkey; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY facts
    ADD CONSTRAINT facts_pkey PRIMARY KEY (fact_id);


--
-- TOC entry 76 (OID 39455)
-- Name: tests_pkey; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY tests
    ADD CONSTRAINT tests_pkey PRIMARY KEY (test_id);


--
-- TOC entry 77 (OID 39457)
-- Name: dtps_pkey; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY dtps
    ADD CONSTRAINT dtps_pkey PRIMARY KEY (dtp_id);


--
-- TOC entry 57 (OID 39459)
-- Name: events_pkey; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY events
    ADD CONSTRAINT events_pkey PRIMARY KEY (event_id);


--
-- TOC entry 56 (OID 39461)
-- Name: proceedings_pkey; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY proceedings
    ADD CONSTRAINT proceedings_pkey PRIMARY KEY (proceeding_id);


--
-- TOC entry 59 (OID 39463)
-- Name: assertions_pkey; Type: CONSTRAINT; Schema: public; Owner: calpp
--

ALTER TABLE ONLY assertions
    ADD CONSTRAINT assertions_pkey PRIMARY KEY (assertion_id);


\connect - ramanraj

SET search_path = public, pg_catalog;

--
-- TOC entry 82 (OID 65245)
-- Name: index_sqls_pkey; Type: CONSTRAINT; Schema: public; Owner: ramanraj
--

ALTER TABLE ONLY index_sqls
    ADD CONSTRAINT index_sqls_pkey PRIMARY KEY (index_sql_id);


--
-- TOC entry 81 (OID 65247)
-- Name: index_sqls_index_name_key; Type: CONSTRAINT; Schema: public; Owner: ramanraj
--

ALTER TABLE ONLY index_sqls
    ADD CONSTRAINT index_sqls_index_name_key UNIQUE (index_name);


--
-- TOC entry 83 (OID 65259)
-- Name: index_headings_pkey; Type: CONSTRAINT; Schema: public; Owner: ramanraj
--

ALTER TABLE ONLY index_headings
    ADD CONSTRAINT index_headings_pkey PRIMARY KEY (index_heading_id);


