-- email-channels

CREATE TABLE email_channels
(
    id bigint primary key NOT NULL references channels(id),
    uuid character varying(36),
    deleted boolean NOT NULL,
    project_id BIGINT 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 bigint PRIMARY KEY NOT NULL,
    smtp_addr varchar(255),
    smtp_port varchar(10),
    imap_addr varchar(255),
    imap_port varchar(10),
    login varchar(125),
    password varchar,
    email varchar(225),
    signature_template varchar(4000),
    header_template varchar(4000),
    delete_after boolean
);

CREATE UNIQUE INDEX email_channels_configs_channel_id_uniq
    ON email_channel_configs(channel_id);

