Newer
Older
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { Knex } from "knex";
export async function up(database: Knex): Promise<void> {
return database.schema
.createTable('users', table => {
table.uuid('id').notNullable().primary();
table.string('user_name').unique().notNullable();
table.string('passwd_hash', 60).notNullable();
table.text('email');
table.text('real_name');
})
.createTable('teams', table => {
table.uuid('id').notNullable().primary();
table.text('name').notNullable();
})
.createTable('team_members', table => {
table.uuid('user_id').notNullable().references('users.id');
table.uuid('team_id').notNullable().references('teams.id');
table.primary(['user_id', 'team_id']);
table.uuid('role_id').notNullable().references('roles.id');
})
.createTable('roles', table => {
table.uuid('id').notNullable().primary();
table.uuid('team_id').notNullable().references('teams.id');
table.text('name').notNullable();
})
.createTable('projects', table => {
table.uuid('id').notNullable().primary();
table.text('name').notNullable();
})
.createTable('team_projects', table => {
table.uuid('project_id').notNullable().references('projects.id');
table.uuid('team_id').notNullable().references('teams.id');
table.primary(['project_id', 'team_id']);
})
.createTable('tasks', table => {
table.uuid('id').notNullable().primary();
table.uuid('project_id').notNullable().references('projects.id');
table.text('name').notNullable();
table.text('text').notNullable();
table.enum('status', [ 'open', 'closed', 'suspended' ]).notNullable();
})
.createTable('task_requirements', table => {
table.uuid('task_id').notNullable().references('tasks.id');
table.uuid('role_id').notNullable().references('users.id');
table.primary(['task_id', 'role_id']);
table.integer('time').notNullable();
})
.createTable('task_assignees', table => {
table.uuid('user_id').notNullable().references('users.id');
table.uuid('task_id').notNullable().references('tasks.id');
table.primary(['user_id', 'task_id']);
table.integer('time').notNullable();
table.boolean('assigned').notNullable();
table.boolean('working').notNullable();
})
.createTable('comments', table => {
table.uuid('id').notNullable().primary();
table.uuid('task_id').notNullable().references('tasks.id');
table.uuid('user_id').notNullable().references('users.id');
table.text('text').notNullable();
});
}
export async function down(database: Knex): Promise<void> {
return database.schema
.dropTable('comments')
.dropTable('task_assignees')
.dropTable('task_requirements')
.dropTable('tasks')
.dropTable('team_projects')
.dropTable('projects')
.dropTable('roles')
.dropTable('team_members')
.dropTable('teams')
.dropTable('users');
}