package Daje::Database::Mail;
use Mojo::Base -base;
use v5.42;

our $VERSION = '1';

1;

__DATA__

@@ mail

-- 1 up

-- Autogenerated file, any changes to this file will be over written.
-- Last generated 2026-02-13 15:59:42

    
CREATE TABLE IF NOT EXISTS mail_mails
(
    mail_mails_pkey  SERIAL NOT NULL,
    editnum bigint NOT NULL DEFAULT 1,
    insby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    insdatetime timestamp without time zone NOT NULL DEFAULT now(),
    modby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    moddatetime timestamp without time zone NOT NULL DEFAULT now(),
                recipients  VARCHAR  NOT NULL ,
                        carboncopy  VARCHAR  NOT NULL DEFAULT '' ,
                        subject  VARCHAR  NOT NULL ,
                        message  VARCHAR  NOT NULL DEFAULT '' ,
                    companies_companies_fkey BIGINT  NOT NULL,
                    users_users_fkey BIGINT  NOT NULL,
                    mail_status_fkey BIGINT  NOT NULL,
                CONSTRAINT mail_mails_pkey PRIMARY KEY (mail_mails_pkey)
);
    
CREATE TABLE IF NOT EXISTS mail_attachements
(
    mail_attachements_pkey  SERIAL NOT NULL,
    editnum bigint NOT NULL DEFAULT 1,
    insby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    insdatetime timestamp without time zone NOT NULL DEFAULT now(),
    modby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    moddatetime timestamp without time zone NOT NULL DEFAULT now(),
                filename  VARCHAR  NOT NULL ,
                    mail_mails_fkey BIGINT  NOT NULL,
                CONSTRAINT mail_attachements_pkey PRIMARY KEY (mail_attachements_pkey)
);
    
CREATE TABLE IF NOT EXISTS mail_status
(
    mail_status_pkey  SERIAL NOT NULL,
    editnum bigint NOT NULL DEFAULT 1,
    insby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    insdatetime timestamp without time zone NOT NULL DEFAULT now(),
    modby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    moddatetime timestamp without time zone NOT NULL DEFAULT now(),
                status  VARCHAR  NOT NULL ,
                        description  VARCHAR  NOT NULL DEFAULT '' ,
                    companies_companies_fkey BIGINT  NOT NULL,
                CONSTRAINT mail_status_pkey PRIMARY KEY (mail_status_pkey)
);
    
CREATE TABLE IF NOT EXISTS mail_settings
(
    mail_settings_pkey  SERIAL NOT NULL,
    editnum bigint NOT NULL DEFAULT 1,
    insby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    insdatetime timestamp without time zone NOT NULL DEFAULT now(),
    modby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    moddatetime timestamp without time zone NOT NULL DEFAULT now(),
                host  VARCHAR  NOT NULL ,
                        port  BIGINT  NOT NULL ,
                        username  VARCHAR  NOT NULL ,
                        password  VARCHAR  NOT NULL ,
                    companies_companies_fkey BIGINT  NOT NULL,
                CONSTRAINT mail_settings_pkey PRIMARY KEY (mail_settings_pkey)
);
    
CREATE TABLE IF NOT EXISTS mail_fallback_settings
(
    mail_fallback_settings_pkey  SERIAL NOT NULL,
    editnum bigint NOT NULL DEFAULT 1,
    insby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    insdatetime timestamp without time zone NOT NULL DEFAULT now(),
    modby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    moddatetime timestamp without time zone NOT NULL DEFAULT now(),
                host  VARCHAR  NOT NULL ,
                        port  BIGINT  NOT NULL ,
                        username  VARCHAR  NOT NULL ,
                        password  VARCHAR  NOT NULL ,
                CONSTRAINT mail_fallback_settings_pkey PRIMARY KEY (mail_fallback_settings_pkey)
);
    

CREATE OR REPLACE VIEW v_mail_mails AS
    SELECT mail_mails_pkey, editnum, insby, insdatetime, modby, moddatetime, recipients,
      carboncopy,
      subject,
      message,
     companies_companies_fkey,
     users_users_fkey,
     mail_status_fkey
          FROM mail_mails;
CREATE OR REPLACE VIEW v_mail_attachements AS
    SELECT mail_attachements_pkey, editnum, insby, insdatetime, modby, moddatetime, filename,
     mail_mails_fkey
          FROM mail_attachements;
CREATE OR REPLACE VIEW v_mail_status AS
    SELECT mail_status_pkey, editnum, insby, insdatetime, modby, moddatetime, status,
      description,
     companies_companies_fkey
          FROM mail_status;
CREATE OR REPLACE VIEW v_mail_settings AS
    SELECT mail_settings_pkey, editnum, insby, insdatetime, modby, moddatetime, host,
      port,
      username,
      password,
     companies_companies_fkey
          FROM mail_settings;
CREATE OR REPLACE VIEW v_mail_fallback_settings AS
    SELECT mail_fallback_settings_pkey, editnum, insby, insdatetime, modby, moddatetime, host,
      port,
      username,
      password
          FROM mail_fallback_settings;


CREATE OR REPLACE VIEW v_mail_mails_list AS
    SELECT mail_mails_pkey, editnum, insby, insdatetime, modby, moddatetime, recipients, carboncopy, subject, message,companies_companies_fkey,users_users_fkey,mail_status_fkey     FROM mail_mails;

CREATE OR REPLACE VIEW v_mail_attachements_list AS
    SELECT mail_attachements_pkey, editnum, insby, insdatetime, modby, moddatetime, filename,mail_mails_fkey     FROM mail_attachements;

CREATE OR REPLACE VIEW v_mail_status_list AS
    SELECT mail_status_pkey, editnum, insby, insdatetime, modby, moddatetime, status, description,companies_companies_fkey     FROM mail_status;

CREATE OR REPLACE VIEW v_mail_settings_list AS
    SELECT mail_settings_pkey, editnum, insby, insdatetime, modby, moddatetime, host, port, username, password,companies_companies_fkey     FROM mail_settings;

CREATE OR REPLACE VIEW v_mail_fallback_settings_list AS
    SELECT mail_fallback_settings_pkey, editnum, insby, insdatetime, modby, moddatetime, host, port, username, password     FROM mail_fallback_settings;





  
  
  
  ALTER TABLE mail_mails
    ADD CONSTRAINT companies_mails_companies_companies_fkey
        FOREIGN KEY (companies_companies_fkey)    REFERENCES companies_companies (companies_companies_pkey);


CREATE INDEX ind_companies_mails_companies_fkey
    ON mail_mails(companies_companies_fkey);

  
  ALTER TABLE mail_mails
    ADD CONSTRAINT users_mails_users_users_fkey
        FOREIGN KEY (users_users_fkey)    REFERENCES users_users (users_users_pkey);


CREATE INDEX ind_users_mails_users_fkey
    ON mail_mails(users_users_fkey);

  
  ALTER TABLE mail_mails
    ADD CONSTRAINT mail_mails_mail_status_fkey
        FOREIGN KEY (mail_status_fkey)    REFERENCES mail_status (mail_status_pkey);

CREATE INDEX ind_mail_mails_status_fkey
    ON mail_mails(mail_status_fkey);

    
  ALTER TABLE mail_attachements
    ADD CONSTRAINT mail_attachements_mail_mails_fkey
        FOREIGN KEY (mail_mails_fkey)    REFERENCES mail_mails (mail_mails_pkey);

CREATE INDEX ind_mail_attachements_mails_fkey
    ON mail_attachements(mail_mails_fkey);

    
  
  ALTER TABLE mail_status
    ADD CONSTRAINT companies_status_companies_companies_fkey
        FOREIGN KEY (companies_companies_fkey)    REFERENCES companies_companies (companies_companies_pkey);


CREATE INDEX ind_companies_status_companies_fkey
    ON mail_status(companies_companies_fkey);

  
    
  
  
  
  ALTER TABLE mail_settings
    ADD CONSTRAINT companies_settings_companies_companies_fkey
        FOREIGN KEY (companies_companies_fkey)    REFERENCES companies_companies (companies_companies_pkey);


CREATE INDEX ind_companies_settings_companies_fkey
    ON mail_settings(companies_companies_fkey);

  
    
  
  
  
    


-- 1 down



@@ the_end


