summaryrefslogtreecommitdiff
path: root/internal/database/schema.sql
blob: 31a5d0a1e3008453ed703d31aafa96b51c205b91 (plain)
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
50
create table if not exists client (
    id integer primary key autoincrement,
    name text not null unique,
    email text,
    billable_rate integer,
    archived integer not null default 0,
    created_at datetime default current_timestamp
);

create table if not exists project (
    id integer primary key autoincrement,
    name text not null unique,
    client_id integer not null,
    billable_rate integer,
    archived integer not null default 0,
    created_at datetime default current_timestamp,
    foreign key (client_id) references client(id)
);

create table if not exists contractor (
    id integer primary key autoincrement,
    name text not null,
    label text not null,
    email text not null,
    created_at datetime default current_timestamp
);

create table if not exists invoice (
    id integer primary key autoincrement,
    year integer not null,
    month integer not null,
    number integer not null,
    client_id integer not null,
    total_amount integer not null,
    created_at datetime default current_timestamp,
    unique(year, month, number),
    foreign key (client_id) references client(id)
);

create table if not exists time_entry (
    id integer primary key autoincrement,
    start_time datetime not null,
    end_time datetime,
    description text,
    client_id integer not null,
    project_id integer,
    billable_rate integer,
    foreign key (client_id) references client(id),
    foreign key (project_id) references project(id)
);