File size: 1,270 Bytes
4744c71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
-- Campaigns table to track email campaigns
create table campaigns (
    id serial primary key,
    name varchar(255) not null,
    start_date date,
    end_date date,
    status varchar(50) default 'pending'
);

-- Email templates table to store fixed email content
create table email_templates (
    id serial primary key,
    subject varchar(255),
    body_html text
);

-- Leads table to store scraped lead data
create table leads (
    id serial primary key,
    search_query varchar(255),
    name varchar(255),
    email varchar(255),
    url varchar(1000),
    foreign key (search_query) references search_terms(term)
);

-- Generated_emails table to store AI-generated or fixed emails
create table generated_emails (
    id serial primary key,
    lead_id integer,
    search_term varchar(255),
    email varchar(255),
    url varchar(1000),
    generated_email text,
    subject varchar(255),
    sent_status boolean default false,
    sent_at timestamp,
    email_sent boolean default false,
    foreign key (lead_id) references leads(id)
);

-- Search_terms table to store and track search queries
create table search_terms (
    id serial primary key,
    term varchar(255),
    status varchar(50) default 'pending',
    fetched_emails integer default 0
);