Skip to content
Snippets Groups Projects
structure.sql 4.69 KiB
Newer Older
  • Learn to ignore specific revisions
  • Florian Azizian's avatar
    Florian Azizian committed
    -- core/sql/structure/core.postgresql.sql
    
    SET client_encoding = 'UTF8';
    SET standard_conforming_strings = off;
    SET check_function_bodies = false;
    SET client_min_messages = warning;
    SET escape_string_warning = off;
    SET search_path = public, pg_catalog;
    SET default_tablespace = '';
    SET default_with_oids = false;
    
    
    
    DROP TABLE IF EXISTS main_documents;
    CREATE TABLE main_documents
    
    Florian Azizian's avatar
    Florian Azizian committed
    (
    
    Damien's avatar
    Damien committed
      id serial NOT NULL,
    
      external_id character varying(255),
      reference character varying(255),
      subject text,
      doc_date timestamp without time zone,
      status integer NOT NULL,
      priority character varying(255),
      sender text NOT NULL,
      sender_entity text,
      processing_user integer NOT NULL,
      recipient text,
      creation_date timestamp without time zone NOT NULL DEFAULT NOW(),
      modification_date timestamp without time zone DEFAULT NOW(),
      CONSTRAINT main_documents_pkey PRIMARY KEY (id)
    
    Florian Azizian's avatar
    Florian Azizian committed
    )
    WITH (OIDS=FALSE);
    
    
    DROP TABLE IF EXISTS attachments;
    CREATE TABLE attachments
    
    Florian Azizian's avatar
    Florian Azizian committed
    (
    
    Florian Azizian's avatar
    Florian Azizian committed
      id serial NOT NULL,
    
    Damien's avatar
    Damien committed
      main_document_id bigint NOT NULL,
    
      reference character varying(255),
    
    Damien's avatar
    Damien committed
      subject text,
      creation_date timestamp without time zone NOT NULL DEFAULT NOW(),
      modification_date timestamp without time zone DEFAULT NOW(),
    
      CONSTRAINT attachments_pkey PRIMARY KEY (id)
    
    Florian Azizian's avatar
    Florian Azizian committed
    )
    WITH (OIDS=FALSE);
    
    
    DROP TABLE IF EXISTS status;
    
    Florian Azizian's avatar
    Florian Azizian committed
    CREATE TABLE status
    (
    
    Damien's avatar
    Damien committed
      id serial,
    
      reference character varying(10) NOT NULL,
    
    Damien's avatar
    Damien committed
      label character varying(50) NOT NULL,
      CONSTRAINT status_pkey PRIMARY KEY (id),
    
      CONSTRAINT status_reference_key UNIQUE (reference)
    
    Florian Azizian's avatar
    Florian Azizian committed
    )
    WITH (OIDS=FALSE);
    
    
    DROP TABLE IF EXISTS users;
    
    Florian Azizian's avatar
    Florian Azizian committed
    CREATE TABLE users
    (
      id serial NOT NULL,
    
    Damien's avatar
    Damien committed
      login character varying(128) NOT NULL,
    
    Florian Azizian's avatar
    Florian Azizian committed
      "password" character varying(255) DEFAULT NULL::character varying,
      firstname character varying(255) DEFAULT NULL::character varying,
      lastname character varying(255) DEFAULT NULL::character varying,
      phone character varying(32) DEFAULT NULL::character varying,
      mail character varying(255) DEFAULT NULL::character varying,
      initials character varying(32) DEFAULT NULL::character varying,
      status character varying(10) NOT NULL DEFAULT 'OK'::character varying,
      enabled character(1) NOT NULL DEFAULT 'Y'::bpchar,
      password_modification_date timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
      loginmode character varying(50) DEFAULT NULL::character varying,
      cookie_key character varying(255) DEFAULT NULL::character varying,
      cookie_date timestamp without time zone,
    
      CONSTRAINT users_pkey PRIMARY KEY (id),
      CONSTRAINT users_login_key UNIQUE (login)
    
    Damien's avatar
    Damien committed
    )
    WITH (OIDS=FALSE);
    
    DROP TABLE IF EXISTS docservers;
    CREATE TABLE docservers
    
    Florian Azizian's avatar
    Florian Azizian committed
    (
    
    Damien's avatar
    Damien committed
      id serial NOT NULL,
    
      type character varying(32) NOT NULL,
      label character varying(255),
      is_readonly character(1) NOT NULL DEFAULT 'N'::bpchar,
      size_limit_number bigint NOT NULL DEFAULT (0)::bigint,
      actual_size_number bigint NOT NULL DEFAULT (0)::bigint,
      path character varying(255) NOT NULL,
      CONSTRAINT docservers_pkey PRIMARY KEY (id),
      CONSTRAINT docservers_type_key UNIQUE (type)
    
    Florian Azizian's avatar
    Florian Azizian committed
    )
    WITH (OIDS=FALSE);
    
    
    DROP TABLE IF EXISTS adr_main_documents;
    
    Damien's avatar
    Damien committed
    CREATE TABLE adr_main_documents
    
    Florian Azizian's avatar
    Florian Azizian committed
    (
      id serial NOT NULL,
    
    Damien's avatar
    Damien committed
      main_document_id bigint NOT NULL,
    
    Florian Azizian's avatar
    Florian Azizian committed
      type character varying(32) NOT NULL,
      path character varying(255) NOT NULL,
      filename character varying(255) NOT NULL,
    
    Damien's avatar
    Damien committed
      fingerprint character varying(255) NOT NULL,
    
    Florian Azizian's avatar
    Florian Azizian committed
      CONSTRAINT adr_letterbox_pkey PRIMARY KEY (id),
    
    Damien's avatar
    Damien committed
      CONSTRAINT adr_letterbox_unique_key UNIQUE (main_document_id, type)
    
    Florian Azizian's avatar
    Florian Azizian committed
    )
    WITH (OIDS=FALSE);
    
    
    DROP TABLE IF EXISTS adr_attachments;
    
    Damien's avatar
    Damien committed
    CREATE TABLE adr_attachments
    (
      id serial NOT NULL,
      attachment_id bigint NOT NULL,
      type character varying(32) NOT NULL,
      path character varying(255) NOT NULL,
      filename character varying(255) NOT NULL,
    
    Damien's avatar
    Damien committed
      fingerprint character varying(255) NOT NULL,
    
    Damien's avatar
    Damien committed
      CONSTRAINT adr_attachments_pkey PRIMARY KEY (id),
      CONSTRAINT adr_attachments_unique_key UNIQUE (attachment_id, type)
    )
    WITH (OIDS=FALSE);
    
    
    DROP TABLE IF EXISTS signatures;
    CREATE TABLE signatures
    
    Florian Azizian's avatar
    Florian Azizian committed
    (
    
    Florian Azizian's avatar
    Florian Azizian committed
      id serial NOT NULL,
    
      user_id integer NOT NULL,
    
      path character varying(255) NOT NULL,
      filename character varying(255) NOT NULL,
      fingerprint character varying(255) NOT NULL,
      CONSTRAINT signatures_pkey PRIMARY KEY (id)
    
    Florian Azizian's avatar
    Florian Azizian committed
    )
    WITH (OIDS=FALSE);
    
    
    DROP TABLE IF EXISTS history;
    CREATE TABLE history
    (
      id serial NOT NULL,
      table_name character varying(32) DEFAULT NULL::character varying,
      record_id character varying(255) DEFAULT NULL::character varying,
      event_type character varying(32) NOT NULL,
      user_id character varying(128) NOT NULL,
      event_date timestamp without time zone NOT NULL,
      info text,
      id_module character varying(50) NOT NULL DEFAULT 'admin'::character varying,
      remote_ip character varying(32) DEFAULT NULL,
      event_id character varying(50),
      CONSTRAINT history_pkey PRIMARY KEY (id)
    )
    WITH (OIDS=FALSE);