2 # 1) Create a database using the "CREATE DATABASE" mysql command.
3 # 2) Then, execute this script from command prompt with a command like this:
4 # mysql -h host -u user -p -D db_name < mysql.sql
6 # create database timetracker character set = 'utf8mb4';
12 # Structure for table tt_groups. A group is a unit of users for whom we are tracking work time.
13 # This table stores settings common to all group members such as language, week start day, etc.
15 CREATE TABLE `tt_groups` (
16 `id` int(11) NOT NULL auto_increment, # group id
17 `parent_id` int(11) default NULL, # parent group id
18 `org_id` int(11) default NULL, # organization id (id of top group)
19 `group_key` varchar(32) default NULL, # group key
20 `name` varchar(80) default NULL, # group name
21 `description` varchar(255) default NULL, # group description
22 `currency` varchar(7) default NULL, # currency symbol
23 `decimal_mark` char(1) NOT NULL default '.', # separator in decimals
24 `lang` varchar(10) NOT NULL default 'en', # language
25 `date_format` varchar(20) NOT NULL default '%Y-%m-%d', # date format
26 `time_format` varchar(20) NOT NULL default '%H:%M', # time format
27 `week_start` smallint(2) NOT NULL default 0, # Week start day, 0 == Sunday.
28 `tracking_mode` smallint(2) NOT NULL default 1, # tracking mode ("time", "projects" or "projects and tasks")
29 `project_required` smallint(2) NOT NULL default 0, # whether a project selection is required or optional
30 `task_required` smallint(2) NOT NULL default 0, # whether a task selection is required or optional
31 `record_type` smallint(2) NOT NULL default 0, # time record type ("start and finish", "duration", or both)
32 `bcc_email` varchar(100) default NULL, # bcc email to copy all reports to
33 `allow_ip` varchar(255) default NULL, # specification from where users are allowed access
34 `password_complexity` varchar(64) default NULL, # password example that defines required complexity
35 `plugins` varchar(255) default NULL, # a list of enabled plugins for group
36 `lock_spec` varchar(255) default NULL, # Cron specification for record locking,
37 # for example: "0 10 * * 1" for "weekly on Mon at 10:00".
38 `workday_minutes` smallint(4) default 480, # number of work minutes in a regular working day
39 `custom_logo` tinyint(4) default 0, # whether to use a custom logo or not
40 `config` text default NULL, # miscellaneous group configuration settings
41 `created` datetime default NULL, # creation timestamp
42 `created_ip` varchar(45) default NULL, # creator ip
43 `created_by` int(11) default NULL, # creator user_id
44 `modified` datetime default NULL, # modification timestamp
45 `modified_ip` varchar(45) default NULL, # modifier ip
46 `modified_by` int(11) default NULL, # modifier user_id
47 `status` tinyint(4) default 1, # group status
53 # Structure for table tt_roles. This table stores group roles.
55 CREATE TABLE `tt_roles` (
56 `id` int(11) NOT NULL auto_increment, # Role id. Identifies roles for all groups on the server.
57 `group_id` int(11) NOT NULL, # Group id the role is defined for.
58 `org_id` int(11) default NULL, # Organization id.
59 `name` varchar(80) default NULL, # Role name - custom role name. In case we are editing a
60 # predefined role (USER, etc.), we can rename the role here.
61 `description` varchar(255) default NULL, # Role description.
62 `rank` int(11) default 0, # Role rank, an integer value between 0-512. Predefined role ranks:
63 # User - 4, Supervisor - 12, Client - 16,
64 # Co-manager - 68, Manager - 324, Top manager - 512.
65 # Rank is used to determine what "lesser roles" are in each group
66 # for situations such as "manage_users".
67 `rights` text default NULL, # Comma-separated list of rights assigned to a role.
68 # NULL here for predefined roles (4, 16, 68, 324 - manager)
69 # means a hard-coded set of default access rights.
70 `status` tinyint(4) default 1, # Role status.
74 # Create an index that guarantees unique active and inactive role ranks in each group.
75 create unique index role_idx on tt_roles(group_id, rank, status);
77 # Insert site-wide roles - site administrator and top manager.
78 INSERT INTO `tt_roles` (`group_id`, `name`, `rank`, `rights`) VALUES (0, 'Site administrator', 1024, 'administer_site');
79 INSERT INTO `tt_roles` (`group_id`, `name`, `rank`, `rights`) VALUES (0, 'Top manager', 512, 'track_own_time,track_own_expenses,view_own_reports,view_own_charts,view_own_projects,view_own_tasks,manage_own_settings,view_users,view_client_reports,view_client_invoices,track_time,track_expenses,view_reports,approve_reports,approve_timesheets,view_charts,view_own_clients,override_punch_mode,override_own_punch_mode,override_date_lock,override_own_date_lock,swap_roles,update_work,manage_own_account,manage_users,manage_projects,manage_tasks,manage_custom_fields,manage_clients,manage_invoices,override_allow_ip,manage_basic_settings,view_all_reports,manage_work,bid_on_work,manage_features,manage_advanced_settings,manage_roles,export_data,approve_all_reports,approve_own_timesheets,manage_subgroups,view_client_unapproved,delete_group');
83 # Structure for table tt_users. This table is used to store user properties.
85 CREATE TABLE `tt_users` (
86 `id` int(11) NOT NULL auto_increment, # user id
87 `login` varchar(50) COLLATE utf8mb4_bin NOT NULL,# user login
88 `password` varchar(50) default NULL, # password hash
89 `name` varchar(100) default NULL, # user name
90 `group_id` int(11) NOT NULL, # group id
91 `org_id` int(11) default NULL, # organization id
92 `role_id` int(11) default NULL, # role id
93 `client_id` int(11) default NULL, # client id for "client" user role
94 `rate` float(6,2) NOT NULL default '0.00', # default hourly rate
95 `quota_percent` float(6,2) NOT NULL default '100.00', # percent of time quota
96 `email` varchar(100) default NULL, # user email
97 `created` datetime default NULL, # creation timestamp
98 `created_ip` varchar(45) default NULL, # creator ip
99 `created_by` int(11) default NULL, # creator user_id (null for self)
100 `modified` datetime default NULL, # modification timestamp
101 `modified_ip` varchar(45) default NULL, # modifier ip
102 `modified_by` int(11) default NULL, # modifier user_id
103 `accessed` datetime default NULL, # last access timestamp
104 `accessed_ip` varchar(45) default NULL, # last access ip
105 `status` tinyint(4) default 1, # user status
109 # Create an index that guarantees unique active and inactive logins.
110 create unique index login_idx on tt_users(login, status);
112 # Create admin account with password 'secret'. Admin is a superuser who can create groups.
113 DELETE from `tt_users` WHERE login = 'admin';
114 INSERT INTO `tt_users` (`login`, `password`, `name`, `group_id`, `role_id`) VALUES ('admin', md5('secret'), 'Admin', '0', (select id from tt_roles where rank = 1024));
118 # Structure for table tt_projects.
120 CREATE TABLE `tt_projects` (
121 `id` int(11) NOT NULL auto_increment, # project id
122 `group_id` int(11) NOT NULL, # group id
123 `org_id` int(11) default NULL, # organization id
124 `name` varchar(80) COLLATE utf8mb4_bin NOT NULL, # project name
125 `description` varchar(255) default NULL, # project description
126 `tasks` text default NULL, # comma-separated list of task ids associated with this project
127 `status` tinyint(4) default 1, # project status
131 # Create an index that guarantees unique active and inactive projects per group.
132 create unique index project_idx on tt_projects(group_id, name, status);
136 # Structure for table tt_tasks.
138 CREATE TABLE `tt_tasks` (
139 `id` int(11) NOT NULL auto_increment, # task id
140 `group_id` int(11) NOT NULL, # group id
141 `org_id` int(11) default NULL, # organization id
142 `name` varchar(80) COLLATE utf8mb4_bin NOT NULL, # task name
143 `description` varchar(255) default NULL, # task description
144 `status` tinyint(4) default 1, # task status
148 # Create an index that guarantees unique active and inactive tasks per group.
149 create unique index task_idx on tt_tasks(group_id, name, status);
153 # Structure for table tt_user_project_binds. This table maps users to assigned projects.
155 CREATE TABLE `tt_user_project_binds` (
156 `id` int(11) NOT NULL auto_increment, # bind id
157 `user_id` int(11) NOT NULL, # user id
158 `project_id` int(11) NOT NULL, # project id
159 `group_id` int(11) default NULL, # group id
160 `org_id` int(11) default NULL, # organization id
161 `rate` float(6,2) default '0.00', # rate for this user when working on this project
162 `status` tinyint(4) default 1, # bind status
166 # Create an index that guarantees unique user to project binds.
167 create unique index bind_idx on tt_user_project_binds(user_id, project_id);
171 # Structure for table tt_project_task_binds. This table maps projects to assigned tasks.
173 CREATE TABLE `tt_project_task_binds` (
174 `project_id` int(11) NOT NULL, # project id
175 `task_id` int(11) NOT NULL, # task id
176 `group_id` int(11) default NULL, # group id
177 `org_id` int(11) default NULL # organization id
180 # Indexes for tt_project_task_binds.
181 create index project_idx on tt_project_task_binds(project_id);
182 create index task_idx on tt_project_task_binds(task_id);
183 create unique index project_task_idx on tt_project_task_binds(project_id, task_id);
187 # Structure for table tt_log. This is the table where time entries for users are stored.
188 # If you use custom fields, additional info for each record may exist in tt_custom_field_log.
190 CREATE TABLE `tt_log` (
191 `id` bigint NOT NULL auto_increment, # time record id
192 `user_id` int(11) NOT NULL, # user id
193 `group_id` int(11) default NULL, # group id
194 `org_id` int(11) default NULL, # organization id
195 `date` date NOT NULL, # date the record is for
196 `start` time default NULL, # record start time (for example, 09:00)
197 `duration` time default NULL, # record duration (for example, 1 hour)
198 `client_id` int(11) default NULL, # client id
199 `project_id` int(11) default NULL, # project id
200 `task_id` int(11) default NULL, # task id
201 `timesheet_id` int(11) default NULL, # timesheet id
202 `invoice_id` int(11) default NULL, # invoice id
203 `comment` text, # user provided comment for time record
204 `billable` tinyint(4) default 0, # whether the record is billable or not
205 `approved` tinyint(4) default 0, # whether the record is approved
206 `paid` tinyint(4) default 0, # whether the record is paid
207 `created` datetime default NULL, # creation timestamp
208 `created_ip` varchar(45) default NULL, # creator ip
209 `created_by` int(11) default NULL, # creator user_id
210 `modified` datetime default NULL, # modification timestamp
211 `modified_ip` varchar(45) default NULL, # modifier ip
212 `modified_by` int(11) default NULL, # modifier user_id
213 `status` tinyint(4) default 1, # time record status
217 # Create indexes on tt_log for performance.
218 create index date_idx on tt_log(date);
219 create index user_idx on tt_log(user_id);
220 create index group_idx on tt_log(group_id);
221 create index client_idx on tt_log(client_id);
222 create index invoice_idx on tt_log(invoice_id);
223 create index project_idx on tt_log(project_id);
224 create index task_idx on tt_log(task_id);
225 create index timesheet_idx on tt_log(timesheet_id);
229 # Structure for table tt_invoices. Invoices are issued to clients for billable work.
231 CREATE TABLE `tt_invoices` (
232 `id` int(11) NOT NULL auto_increment, # invoice id
233 `group_id` int(11) NOT NULL, # group id
234 `org_id` int(11) default NULL, # organization id
235 `name` varchar(80) COLLATE utf8mb4_bin NOT NULL, # invoice name
236 `date` date NOT NULL, # invoice date
237 `client_id` int(11) NOT NULL, # client id
238 `status` tinyint(4) default 1, # invoice status
242 # Create an index that guarantees unique invoice names per group.
243 create unique index name_idx on tt_invoices(group_id, name, status);
247 # Structure for table tt_tmp_refs. Used for reset password mechanism.
249 CREATE TABLE `tt_tmp_refs` (
250 `created` datetime default NULL, # creation timestamp
251 `ref` char(32) NOT NULL default '', # unique reference for user, used in urls
252 `user_id` int(11) NOT NULL # user id
257 # Structure for table tt_fav_reports. Favorite reports are pre-configured report configurations.
259 CREATE TABLE `tt_fav_reports` (
260 `id` int(11) NOT NULL auto_increment, # favorite report id
261 `name` varchar(200) NOT NULL, # favorite report name
262 `user_id` int(11) NOT NULL, # user id favorite report belongs to
263 `group_id` int(11) default NULL, # group id
264 `org_id` int(11) default NULL, # organization id
265 `report_spec` text default NULL, # future replacement field for all report settings
266 `client_id` int(11) default NULL, # client id (if selected)
267 `cf_1_option_id` int(11) default NULL, # custom field 1 option id (if selected)
268 `project_id` int(11) default NULL, # project id (if selected)
269 `task_id` int(11) default NULL, # task id (if selected)
270 `billable` tinyint(4) default NULL, # whether to include billable, not billable, or all records
271 `approved` tinyint(4) default NULL, # whether to include approved, unapproved, or all records
272 `invoice` tinyint(4) default NULL, # whether to include invoiced, not invoiced, or all records
273 `timesheet` tinyint(4) default NULL, # include records with a specific timesheet status, or all records
274 `paid_status` tinyint(4) default NULL, # whether to include paid, not paid, or all records
275 `users` text default NULL, # Comma-separated list of user ids. Nothing here means "all" users.
276 `period` tinyint(4) default NULL, # selected period type for report
277 `period_start` date default NULL, # period start
278 `period_end` date default NULL, # period end
279 `show_client` tinyint(4) NOT NULL default 0, # whether to show client column
280 `show_invoice` tinyint(4) NOT NULL default 0, # whether to show invoice column
281 `show_paid` tinyint(4) NOT NULL default 0, # whether to show paid column
282 `show_ip` tinyint(4) NOT NULL default 0, # whether to show ip column
283 `show_project` tinyint(4) NOT NULL default 0, # whether to show project column
284 `show_timesheet` tinyint(4) NOT NULL default 0, # whether to show timesheet column
285 `show_start` tinyint(4) NOT NULL default 0, # whether to show start field
286 `show_duration` tinyint(4) NOT NULL default 0, # whether to show duration field
287 `show_cost` tinyint(4) NOT NULL default 0, # whether to show cost field
288 `show_task` tinyint(4) NOT NULL default 0, # whether to show task column
289 `show_end` tinyint(4) NOT NULL default 0, # whether to show end field
290 `show_note` tinyint(4) NOT NULL default 0, # whether to show note column
291 `show_approved` tinyint(4) NOT NULL default 0, # whether to show approved column
292 `show_custom_field_1` tinyint(4) NOT NULL default 0, # whether to show custom field 1
293 `show_work_units` tinyint(4) NOT NULL default 0, # whether to show work units
294 `show_totals_only` tinyint(4) NOT NULL default 0, # whether to show totals only
295 `group_by1` varchar(20) default NULL, # group by field 1
296 `group_by2` varchar(20) default NULL, # group by field 2
297 `group_by3` varchar(20) default NULL, # group by field 3
298 `status` tinyint(4) default 1, # favorite report status
304 # Structure for table tt_cron. It is used to email favorite reports on schedule.
306 CREATE TABLE `tt_cron` (
307 `id` int(11) NOT NULL auto_increment, # entry id
308 `group_id` int(11) NOT NULL, # group id
309 `org_id` int(11) default NULL, # organization id
310 `cron_spec` varchar(255) NOT NULL, # cron specification, "0 1 * * *" for "daily at 01:00"
311 `last` int(11) default NULL, # UNIX timestamp of when job was last run
312 `next` int(11) default NULL, # UNIX timestamp of when to run next job
313 `report_id` int(11) default NULL, # report id from tt_fav_reports, a report to mail on schedule
314 `email` varchar(100) default NULL, # email to send results to
315 `cc` varchar(100) default NULL, # cc email to send results to
316 `subject` varchar(100) default NULL, # email subject
317 `report_condition` varchar(255) default NULL, # report condition, "count > 0" for sending not empty reports
318 `status` tinyint(4) default 1, # entry status
324 # Structure for table tt_clients. A client is an entity for whom work is performed and who may be invoiced.
326 CREATE TABLE `tt_clients` (
327 `id` int(11) NOT NULL AUTO_INCREMENT, # client id
328 `group_id` int(11) NOT NULL, # group id
329 `org_id` int(11) default NULL, # organization id
330 `name` varchar(80) COLLATE utf8mb4_bin NOT NULL, # client name
331 `address` varchar(255) default NULL, # client address
332 `tax` float(6,2) default '0.00', # applicable tax for this client
333 `projects` text default NULL, # comma-separated list of project ids assigned to this client
334 `status` tinyint(4) default 1, # client status
338 # Create an index that guarantees unique active and inactive clients per group.
339 create unique index client_name_idx on tt_clients(group_id, name, status);
343 # Structure for table tt_client_project_binds. This table maps clients to assigned projects.
345 CREATE TABLE `tt_client_project_binds` (
346 `client_id` int(11) NOT NULL, # client id
347 `project_id` int(11) NOT NULL, # project id
348 `group_id` int(11) default NULL, # group id
349 `org_id` int(11) default NULL # organization id
352 # Indexes for tt_client_project_binds.
353 create index client_idx on tt_client_project_binds(client_id);
354 create index project_idx on tt_client_project_binds(project_id);
355 create unique index client_project_idx on tt_client_project_binds(client_id, project_id);
359 # Structure for table tt_config. This table is used to store configuration info for users.
360 # For example, last_report_email parameter stores an email for user last report was emailed to.
362 CREATE TABLE `tt_config` (
363 `user_id` int(11) NOT NULL, # user id
364 `group_id` int(11) default NULL, # group id
365 `org_id` int(11) default NULL, # organization id
366 `param_name` varchar(32) NOT NULL, # parameter name
367 `param_value` varchar(80) default NULL # parameter value
370 # Create an index that guarantees unique parameter names per user.
371 create unique index param_idx on tt_config(user_id, param_name);
374 # Below are the tables used by CustomFields plugin.
377 # Structure for table tt_custom_fields. This table contains definitions of custom fields.
379 CREATE TABLE `tt_custom_fields` (
380 `id` int(11) NOT NULL auto_increment, # custom field id
381 `group_id` int(11) NOT NULL, # group id
382 `org_id` int(11) default NULL, # organization id
383 `type` tinyint(4) NOT NULL default 0, # custom field type (text or dropdown)
384 `label` varchar(32) NOT NULL default '', # custom field label
385 `required` tinyint(4) default 0, # whether this custom field is mandatory for time records
386 `status` tinyint(4) default 1, # custom field status
392 # Structure for table tt_custom_field_options. This table defines options for dropdown custom fields.
394 CREATE TABLE `tt_custom_field_options` (
395 `id` int(11) NOT NULL auto_increment, # option id
396 `group_id` int(11) default NULL, # group id
397 `org_id` int(11) default NULL, # organization id
398 `field_id` int(11) NOT NULL, # custom field id
399 `value` varchar(32) NOT NULL default '', # option value
400 `status` tinyint(4) default 1, # option status
406 # Structure for table tt_custom_field_log.
407 # This table supplements tt_log and contains custom field values for records.
409 CREATE TABLE `tt_custom_field_log` (
410 `id` bigint NOT NULL auto_increment, # custom field log id
411 `group_id` int(11) default NULL, # group id
412 `org_id` int(11) default NULL, # organization id
413 `log_id` bigint NOT NULL, # id of a record in tt_log this record corresponds to
414 `field_id` int(11) NOT NULL, # custom field id
415 `option_id` int(11) default NULL, # Option id. Used for dropdown custom fields.
416 `value` varchar(255) default NULL, # Text value. Used for text custom fields.
417 `status` tinyint(4) default 1, # custom field log entry status
421 create index log_idx on tt_custom_field_log(log_id);
425 # Structure for table tt_expense_items.
426 # This table lists expense items.
428 CREATE TABLE `tt_expense_items` (
429 `id` bigint NOT NULL auto_increment, # expense item id
430 `date` date NOT NULL, # date the record is for
431 `user_id` int(11) NOT NULL, # user id the expense item is reported by
432 `group_id` int(11) default NULL, # group id
433 `org_id` int(11) default NULL, # organization id
434 `client_id` int(11) default NULL, # client id
435 `project_id` int(11) default NULL, # project id
436 `name` text NOT NULL, # expense item name (what is an expense for)
437 `cost` decimal(10,2) default '0.00', # item cost (including taxes, etc.)
438 `invoice_id` int(11) default NULL, # invoice id
439 `approved` tinyint(4) default 0, # whether the item is approved
440 `paid` tinyint(4) default 0, # whether the item is paid
441 `created` datetime default NULL, # creation timestamp
442 `created_ip` varchar(45) default NULL, # creator ip
443 `created_by` int(11) default NULL, # creator user_id
444 `modified` datetime default NULL, # modification timestamp
445 `modified_ip` varchar(45) default NULL, # modifier ip
446 `modified_by` int(11) default NULL, # modifier user_id
447 `status` tinyint(4) default 1, # item status
451 # Create indexes on tt_expense_items for performance.
452 create index date_idx on tt_expense_items(date);
453 create index user_idx on tt_expense_items(user_id);
454 create index group_idx on tt_expense_items(group_id);
455 create index client_idx on tt_expense_items(client_id);
456 create index project_idx on tt_expense_items(project_id);
457 create index invoice_idx on tt_expense_items(invoice_id);
461 # Structure for table tt_predefined_expenses.
462 # This table keeps names and costs for predefined expenses.
464 CREATE TABLE `tt_predefined_expenses` (
465 `id` int(11) NOT NULL auto_increment, # predefined expense id
466 `group_id` int(11) NOT NULL, # group id
467 `org_id` int(11) default NULL, # organization id
468 `name` varchar(255) NOT NULL, # predefined expense name, such as mileage
469 `cost` decimal(10,2) default '0.00', # cost for one unit
475 # Structure for table tt_monthly_quotas.
476 # This table keeps monthly work hour quotas for groups.
478 CREATE TABLE `tt_monthly_quotas` (
479 `group_id` int(11) NOT NULL, # group id
480 `org_id` int(11) default NULL, # organization id
481 `year` smallint(5) UNSIGNED NOT NULL, # quota year
482 `month` tinyint(3) UNSIGNED NOT NULL, # quota month
483 `minutes` int(11) default NULL, # quota in minutes in specified month and year
484 PRIMARY KEY (`group_id`,`year`,`month`)
489 # Structure for table tt_timesheets. This table keeps timesheet related information.
491 CREATE TABLE `tt_timesheets` (
492 `id` int(11) NOT NULL auto_increment, # timesheet id
493 `user_id` int(11) NOT NULL, # user id
494 `group_id` int(11) default NULL, # group id
495 `org_id` int(11) default NULL, # organization id
496 `client_id` int(11) default NULL, # client id
497 `project_id` int(11) default NULL, # project id
498 `name` varchar(80) COLLATE utf8mb4_bin NOT NULL, # timesheet name
499 `comment` text, # timesheet comment
500 `start_date` date NOT NULL, # timesheet start date
501 `end_date` date NOT NULL, # timesheet end date
502 `submit_status` tinyint(4) default NULL, # submit status
503 `approve_status` tinyint(4) default NULL, # approve status
504 `approve_comment` text, # approve comment
505 `created` datetime default NULL, # creation timestamp
506 `created_ip` varchar(45) default NULL, # creator ip
507 `created_by` int(11) default NULL, # creator user_id
508 `modified` datetime default NULL, # modification timestamp
509 `modified_ip` varchar(45) default NULL, # modifier ip
510 `modified_by` int(11) default NULL, # modifier user_id
511 `status` tinyint(4) default 1, # timesheet status
517 # Structure for table tt_templates.
518 # This table keeps templates used in groups.
520 CREATE TABLE `tt_templates` (
521 `id` int(11) NOT NULL auto_increment, # template id
522 `group_id` int(11) default NULL, # group id
523 `org_id` int(11) default NULL, # organization id
524 `name` varchar(80) COLLATE utf8mb4_bin NOT NULL, # template name
525 `description` varchar(255) default NULL, # template description
526 `content` text, # template content
527 `created` datetime default NULL, # creation timestamp
528 `created_ip` varchar(45) default NULL, # creator ip
529 `created_by` int(11) default NULL, # creator user_id
530 `modified` datetime default NULL, # modification timestamp
531 `modified_ip` varchar(45) default NULL, # modifier ip
532 `modified_by` int(11) default NULL, # modifier user_id
533 `status` tinyint(4) default 1, # template status
539 # Structure for table tt_files.
540 # This table keeps file attachment information.
542 CREATE TABLE `tt_files` (
543 `id` int(10) unsigned NOT NULL auto_increment, # file id
544 `group_id` int(10) unsigned, # group id
545 `org_id` int(10) unsigned, # organization id
546 `remote_id` bigint(20) unsigned, # file id in storage facility
547 `file_key` varchar(32), # file key
548 `entity_type` varchar(32), # type of entity file is associated with (project, task, etc.)
549 `entity_id` int(10) unsigned, # entity id
550 `file_name` varchar(80) COLLATE utf8mb4_bin NOT NULL, # file name
551 `description` varchar(255) default NULL, # file description
552 `created` datetime default NULL, # creation timestamp
553 `created_ip` varchar(45) default NULL, # creator ip
554 `created_by` int(10) unsigned, # creator user_id
555 `modified` datetime default NULL, # modification timestamp
556 `modified_ip` varchar(45) default NULL, # modifier ip
557 `modified_by` int(10) unsigned, # modifier user_id
558 `status` tinyint(1) default 1, # file status
564 # Structure for table tt_work_currencies.
565 # This table keeps currencies supported by remote work plugin.
567 CREATE TABLE `tt_work_currencies` (
568 `id` int(10) unsigned NOT NULL, # currency id
569 `name` varchar(10) NOT NULL, # currency name (USD, CAD, etc.)
573 # Create an index that guarantees unique work currencies.
574 create unique index currency_idx on tt_work_currencies(`name`);
576 INSERT INTO `tt_work_currencies` (`id`, `name`) VALUES ('1', 'USD'), ('2', 'CAD'), ('3', 'AUD'), ('4', 'EUR'), ('5', 'NZD');
580 # Structure for table tt_work_categories.
581 # This table keeps work categories supported by remote work plugin.
583 CREATE TABLE `tt_work_categories` (
584 `id` int(10) unsigned NOT NULL, # Category id.
585 `parents` text default NULL, # Comma-separated list of parent ids associated with this category.
586 `name` varchar(64) NOT NULL, # English category name.
587 `name_localized` text default NULL, # Comma-separated list of localized category names in other languages.
588 # Example: es:Codificación,ru:Кодирование.
592 # Insert some default categories. Table content to be updated at run time, though.
593 INSERT INTO `tt_work_categories` (`id`, `parents`, `name`, `name_localized`) VALUES ('1', NULL, 'Coding', 'es:Codificación,ru:Кодирование');
594 INSERT INTO `tt_work_categories` (`id`, `parents`, `name`, `name_localized`) VALUES ('2', NULL, 'Other', 'es:Otra,ru:Другое');
595 INSERT INTO `tt_work_categories` (`id`, `parents`, `name`, `name_localized`) VALUES ('3', '1', 'PHP', NULL);
596 INSERT INTO `tt_work_categories` (`id`, `parents`, `name`, `name_localized`) VALUES ('4', '1', 'C/C++', NULL);
600 # Structure for table tt_site_config. This table stores configuration data
601 # for Time Tracker site as a whole.
602 # For example, database version, code version, site language, etc.
604 CREATE TABLE `tt_site_config` (
605 `param_name` varchar(32) NOT NULL, # parameter name
606 `param_value` text default NULL, # parameter value
607 `created` datetime default NULL, # creation timestamp
608 `modified` datetime default NULL, # modification timestamp
609 PRIMARY KEY (`param_name`)
612 INSERT INTO `tt_site_config` (`param_name`, `param_value`, `created`) VALUES ('version_db', '1.19.2', now()); # TODO: change when structure changes.