-- email-channels

CREATE TABLE email_channels
(
    id NUMBER(19) primary key NOT NULL references channels(id),
    uuid varchar2(36),
    deleted NUMBER(0) NOT NULL,
    project_id NUMBER(19) NOT NULL references projects(id),
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    deleted_at timestamp with time zone,
    restored_at timestamp with time zone
);

CREATE UNIQUE INDEX email_channels_uuid_uniq
    ON email_channels(uuid);

-- email configs

CREATE TABLE email_channel_configs
(
    channel_id NUMBER(19) PRIMARY KEY NOT NULL,
    smtp_addr varchar2(255),
    smtp_port varchar2(10),
    imap_addr varchar2(255),
    imap_port varchar2(10),
    login varchar2(125),
    password varchar2(1000),
    email varchar2(225),
    signature_template varchar2(4000),
    header_template varchar2(4000),
    delete_after NUMBER(1)
);

CREATE UNIQUE INDEX email_channels_configs_channel_id_uniq
    ON email_channel_configs(channel_id);

