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 `holidays` text default NULL, # holidays specification
39 `workday_minutes` smallint(4) default 480, # number of work minutes in a regular working day
40 `custom_logo` tinyint(4) default 0, # whether to use a custom logo or not
41 `config` text default NULL, # miscellaneous group configuration settings
42 `created` datetime default NULL, # creation timestamp
43 `created_ip` varchar(45) default NULL, # creator ip
44 `created_by` int(11) default NULL, # creator user_id
45 `modified` datetime default NULL, # modification timestamp
46 `modified_ip` varchar(45) default NULL, # modifier ip
47 `modified_by` int(11) default NULL, # modifier user_id
48 `status` tinyint(4) default 1, # group status
54 # Structure for table tt_roles. This table stores group roles.
56 CREATE TABLE `tt_roles` (
57 `id` int(11) NOT NULL auto_increment, # Role id. Identifies roles for all groups on the server.
58 `group_id` int(11) NOT NULL, # Group id the role is defined for.
59 `org_id` int(11) default NULL, # Organization id.
60 `name` varchar(80) default NULL, # Role name - custom role name. In case we are editing a
61 # predefined role (USER, etc.), we can rename the role here.
62 `description` varchar(255) default NULL, # Role description.
63 `rank` int(11) default 0, # Role rank, an integer value between 0-512. Predefined role ranks:
64 # User - 4, Supervisor - 12, Client - 16,
65 # Co-manager - 68, Manager - 324, Top manager - 512.
66 # Rank is used to determine what "lesser roles" are in each group
67 # for situations such as "manage_users".
68 `rights` text default NULL, # Comma-separated list of rights assigned to a role.
69 # NULL here for predefined roles (4, 16, 68, 324 - manager)
70 # means a hard-coded set of default access rights.
71 `status` tinyint(4) default 1, # Role status.
75 # Create an index that guarantees unique active and inactive role ranks in each group.
76 create unique index role_idx on tt_roles(group_id, rank, status);
78 # Insert site-wide roles - site administrator and top manager.
79 INSERT INTO `tt_roles` (`group_id`, `name`, `rank`, `rights`) VALUES (0, 'Site administrator', 1024, 'administer_site');
80 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');
84 # Structure for table tt_users. This table is used to store user properties.
86 CREATE TABLE `tt_users` (
87 `id` int(11) NOT NULL auto_increment, # user id
88 `login` varchar(50) COLLATE utf8mb4_bin NOT NULL,# user login
89 `password` varchar(50) default NULL, # password hash
90 `name` varchar(100) default NULL, # user name
91 `group_id` int(11) NOT NULL, # group id
92 `org_id` int(11) default NULL, # organization id
93 `role_id` int(11) default NULL, # role id
94 `client_id` int(11) default NULL, # client id for "client" user role
95 `rate` float(6,2) NOT NULL default '0.00', # default hourly rate
96 `quota_percent` float(6,2) NOT NULL default '100.00', # percent of time quota
97 `email` varchar(100) default NULL, # user email
98 `created` datetime default NULL, # creation timestamp
99 `created_ip` varchar(45) default NULL, # creator ip
100 `created_by` int(11) default NULL, # creator user_id (null for self)
101 `modified` datetime default NULL, # modification timestamp
102 `modified_ip` varchar(45) default NULL, # modifier ip
103 `modified_by` int(11) default NULL, # modifier user_id
104 `accessed` datetime default NULL, # last access timestamp
105 `accessed_ip` varchar(45) default NULL, # last access ip
106 `status` tinyint(4) default 1, # user status
110 # Create an index that guarantees unique active and inactive logins.
111 create unique index login_idx on tt_users(login, status);
113 # Create admin account with password 'secret'. Admin is a superuser who can create groups.
114 DELETE from `tt_users` WHERE login = 'admin';
115 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));
119 # Structure for table tt_projects.
121 CREATE TABLE `tt_projects` (
122 `id` int(11) NOT NULL auto_increment, # project id
123 `group_id` int(11) NOT NULL, # group id
124 `org_id` int(11) default NULL, # organization id
125 `name` varchar(80) COLLATE utf8mb4_bin NOT NULL, # project name
126 `description` varchar(255) default NULL, # project description
127 `tasks` text default NULL, # comma-separated list of task ids associated with this project
128 `status` tinyint(4) default 1, # project status
132 # Create an index that guarantees unique active and inactive projects per group.
133 create unique index project_idx on tt_projects(group_id, name, status);
137 # Structure for table tt_tasks.
139 CREATE TABLE `tt_tasks` (
140 `id` int(11) NOT NULL auto_increment, # task id
141 `group_id` int(11) NOT NULL, # group id
142 `org_id` int(11) default NULL, # organization id
143 `name` varchar(80) COLLATE utf8mb4_bin NOT NULL, # task name
144 `description` varchar(255) default NULL, # task description
145 `status` tinyint(4) default 1, # task status
149 # Create an index that guarantees unique active and inactive tasks per group.
150 create unique index task_idx on tt_tasks(group_id, name, status);
154 # Structure for table tt_user_project_binds. This table maps users to assigned projects.
156 CREATE TABLE `tt_user_project_binds` (
157 `id` int(11) NOT NULL auto_increment, # bind id
158 `user_id` int(11) NOT NULL, # user id
159 `project_id` int(11) NOT NULL, # project id
160 `group_id` int(11) default NULL, # group id
161 `org_id` int(11) default NULL, # organization id
162 `rate` float(6,2) default '0.00', # rate for this user when working on this project
163 `status` tinyint(4) default 1, # bind status
167 # Create an index that guarantees unique user to project binds.
168 create unique index bind_idx on tt_user_project_binds(user_id, project_id);
172 # Structure for table tt_project_task_binds. This table maps projects to assigned tasks.
174 CREATE TABLE `tt_project_task_binds` (
175 `project_id` int(11) NOT NULL, # project id
176 `task_id` int(11) NOT NULL, # task id
177 `group_id` int(11) default NULL, # group id
178 `org_id` int(11) default NULL # organization id
181 # Indexes for tt_project_task_binds.
182 create index project_idx on tt_project_task_binds(project_id);
183 create index task_idx on tt_project_task_binds(task_id);
184 create unique index project_task_idx on tt_project_task_binds(project_id, task_id);
188 # Structure for table tt_log. This is the table where time entries for users are stored.
189 # If you use custom fields, additional info for each record may exist in tt_custom_field_log.
191 CREATE TABLE `tt_log` (
192 `id` bigint NOT NULL auto_increment, # time record id
193 `user_id` int(11) NOT NULL, # user id
194 `group_id` int(11) default NULL, # group id
195 `org_id` int(11) default NULL, # organization id
196 `date` date NOT NULL, # date the record is for
197 `start` time default NULL, # record start time (for example, 09:00)
198 `duration` time default NULL, # record duration (for example, 1 hour)
199 `client_id` int(11) default NULL, # client id
200 `project_id` int(11) default NULL, # project id
201 `task_id` int(11) default NULL, # task id
202 `timesheet_id` int(11) default NULL, # timesheet id
203 `invoice_id` int(11) default NULL, # invoice id
204 `comment` text, # user provided comment for time record
205 `billable` tinyint(4) default 0, # whether the record is billable or not
206 `approved` tinyint(4) default 0, # whether the record is approved
207 `paid` tinyint(4) default 0, # whether the record is paid
208 `created` datetime default NULL, # creation timestamp
209 `created_ip` varchar(45) default NULL, # creator ip
210 `created_by` int(11) default NULL, # creator user_id
211 `modified` datetime default NULL, # modification timestamp
212 `modified_ip` varchar(45) default NULL, # modifier ip
213 `modified_by` int(11) default NULL, # modifier user_id
214 `status` tinyint(4) default 1, # time record status
218 # Create indexes on tt_log for performance.
219 create index date_idx on tt_log(date);
220 create index user_idx on tt_log(user_id);
221 create index group_idx on tt_log(group_id);
222 create index client_idx on tt_log(client_id);
223 create index invoice_idx on tt_log(invoice_id);
224 create index project_idx on tt_log(project_id);
225 create index task_idx on tt_log(task_id);
226 create index timesheet_idx on tt_log(timesheet_id);
230 # Structure for table tt_invoices. Invoices are issued to clients for billable work.
232 CREATE TABLE `tt_invoices` (
233 `id` int(11) NOT NULL auto_increment, # invoice id
234 `group_id` int(11) NOT NULL, # group id
235 `org_id` int(11) default NULL, # organization id
236 `name` varchar(80) COLLATE utf8mb4_bin NOT NULL, # invoice name
237 `date` date NOT NULL, # invoice date
238 `client_id` int(11) NOT NULL, # client id
239 `status` tinyint(4) default 1, # invoice status
243 # Create an index that guarantees unique invoice names per group.
244 create unique index name_idx on tt_invoices(group_id, name, status);
248 # Structure for table tt_tmp_refs. Used for reset password mechanism.
250 CREATE TABLE `tt_tmp_refs` (
251 `created` datetime default NULL, # creation timestamp
252 `ref` char(32) NOT NULL default '', # unique reference for user, used in urls
253 `user_id` int(11) NOT NULL # user id
258 # Structure for table tt_fav_reports. Favorite reports are pre-configured report configurations.
260 CREATE TABLE `tt_fav_reports` (
261 `id` int(11) NOT NULL auto_increment, # favorite report id
262 `name` varchar(200) NOT NULL, # favorite report name
263 `user_id` int(11) NOT NULL, # user id favorite report belongs to
264 `group_id` int(11) default NULL, # group id
265 `org_id` int(11) default NULL, # organization id
266 `report_spec` text default NULL, # future replacement field for all report settings
267 `client_id` int(11) default NULL, # client id (if selected)
268 `cf_1_option_id` int(11) default NULL, # custom field 1 option id (if selected)
269 `project_id` int(11) default NULL, # project id (if selected)
270 `task_id` int(11) default NULL, # task id (if selected)
271 `billable` tinyint(4) default NULL, # whether to include billable, not billable, or all records
272 `approved` tinyint(4) default NULL, # whether to include approved, unapproved, or all records
273 `invoice` tinyint(4) default NULL, # whether to include invoiced, not invoiced, or all records
274 `timesheet` tinyint(4) default NULL, # include records with a specific timesheet status, or all records
275 `paid_status` tinyint(4) default NULL, # whether to include paid, not paid, or all records
276 `users` text default NULL, # Comma-separated list of user ids. Nothing here means "all" users.
277 `period` tinyint(4) default NULL, # selected period type for report
278 `period_start` date default NULL, # period start
279 `period_end` date default NULL, # period end
280 `show_client` tinyint(4) NOT NULL default 0, # whether to show client column
281 `show_invoice` tinyint(4) NOT NULL default 0, # whether to show invoice column
282 `show_paid` tinyint(4) NOT NULL default 0, # whether to show paid column
283 `show_ip` tinyint(4) NOT NULL default 0, # whether to show ip column
284 `show_project` tinyint(4) NOT NULL default 0, # whether to show project column
285 `show_timesheet` tinyint(4) NOT NULL default 0, # whether to show timesheet column
286 `show_start` tinyint(4) NOT NULL default 0, # whether to show start field
287 `show_duration` tinyint(4) NOT NULL default 0, # whether to show duration field
288 `show_cost` tinyint(4) NOT NULL default 0, # whether to show cost field
289 `show_task` tinyint(4) NOT NULL default 0, # whether to show task column
290 `show_end` tinyint(4) NOT NULL default 0, # whether to show end field
291 `show_note` tinyint(4) NOT NULL default 0, # whether to show note column
292 `show_approved` tinyint(4) NOT NULL default 0, # whether to show approved column
293 `show_custom_field_1` tinyint(4) NOT NULL default 0, # whether to show custom field 1
294 `show_work_units` tinyint(4) NOT NULL default 0, # whether to show work units
295 `show_totals_only` tinyint(4) NOT NULL default 0, # whether to show totals only
296 `group_by1` varchar(20) default NULL, # group by field 1
297 `group_by2` varchar(20) default NULL, # group by field 2
298 `group_by3` varchar(20) default NULL, # group by field 3
299 `status` tinyint(4) default 1, # favorite report status
305 # Structure for table tt_cron. It is used to email favorite reports on schedule.
307 CREATE TABLE `tt_cron` (
308 `id` int(11) NOT NULL auto_increment, # entry id
309 `group_id` int(11) NOT NULL, # group id
310 `org_id` int(11) default NULL, # organization id
311 `cron_spec` varchar(255) NOT NULL, # cron specification, "0 1 * * *" for "daily at 01:00"
312 `last` int(11) default NULL, # UNIX timestamp of when job was last run
313 `next` int(11) default NULL, # UNIX timestamp of when to run next job
314 `report_id` int(11) default NULL, # report id from tt_fav_reports, a report to mail on schedule
315 `email` varchar(100) default NULL, # email to send results to
316 `cc` varchar(100) default NULL, # cc email to send results to
317 `subject` varchar(100) default NULL, # email subject
318 `report_condition` varchar(255) default NULL, # report condition, "count > 0" for sending not empty reports
319 `status` tinyint(4) default 1, # entry status
325 # Structure for table tt_clients. A client is an entity for whom work is performed and who may be invoiced.
327 CREATE TABLE `tt_clients` (
328 `id` int(11) NOT NULL AUTO_INCREMENT, # client id
329 `group_id` int(11) NOT NULL, # group id
330 `org_id` int(11) default NULL, # organization id
331 `name` varchar(80) COLLATE utf8mb4_bin NOT NULL, # client name
332 `address` varchar(255) default NULL, # client address
333 `tax` float(6,2) default '0.00', # applicable tax for this client
334 `projects` text default NULL, # comma-separated list of project ids assigned to this client
335 `status` tinyint(4) default 1, # client status
339 # Create an index that guarantees unique active and inactive clients per group.
340 create unique index client_name_idx on tt_clients(group_id, name, status);
344 # Structure for table tt_client_project_binds. This table maps clients to assigned projects.
346 CREATE TABLE `tt_client_project_binds` (
347 `client_id` int(11) NOT NULL, # client id
348 `project_id` int(11) NOT NULL, # project id
349 `group_id` int(11) default NULL, # group id
350 `org_id` int(11) default NULL # organization id
353 # Indexes for tt_client_project_binds.
354 create index client_idx on tt_client_project_binds(client_id);
355 create index project_idx on tt_client_project_binds(project_id);
356 create unique index client_project_idx on tt_client_project_binds(client_id, project_id);
360 # Structure for table tt_config. This table is used to store configuration info for users.
361 # For example, last_report_email parameter stores an email for user last report was emailed to.
363 CREATE TABLE `tt_config` (
364 `user_id` int(11) NOT NULL, # user id
365 `group_id` int(11) default NULL, # group id
366 `org_id` int(11) default NULL, # organization id
367 `param_name` varchar(32) NOT NULL, # parameter name
368 `param_value` varchar(80) default NULL # parameter value
371 # Create an index that guarantees unique parameter names per user.
372 create unique index param_idx on tt_config(user_id, param_name);
375 # Below are the tables used by CustomFields plugin.
378 # Structure for table tt_custom_fields. This table contains definitions of custom fields.
380 CREATE TABLE `tt_custom_fields` (
381 `id` int(11) NOT NULL auto_increment, # custom field id
382 `group_id` int(11) NOT NULL, # group id
383 `org_id` int(11) default NULL, # organization id
384 `type` tinyint(4) NOT NULL default 0, # custom field type (text or dropdown)
385 `label` varchar(32) NOT NULL default '', # custom field label
386 `required` tinyint(4) default 0, # whether this custom field is mandatory for time records
387 `status` tinyint(4) default 1, # custom field status
393 # Structure for table tt_custom_field_options. This table defines options for dropdown custom fields.
395 CREATE TABLE `tt_custom_field_options` (
396 `id` int(11) NOT NULL auto_increment, # option id
397 `group_id` int(11) default NULL, # group id
398 `org_id` int(11) default NULL, # organization id
399 `field_id` int(11) NOT NULL, # custom field id
400 `value` varchar(32) NOT NULL default '', # option value
401 `status` tinyint(4) default 1, # option status
407 # Structure for table tt_custom_field_log.
408 # This table supplements tt_log and contains custom field values for records.
410 CREATE TABLE `tt_custom_field_log` (
411 `id` bigint NOT NULL auto_increment, # custom field log id
412 `group_id` int(11) default NULL, # group id
413 `org_id` int(11) default NULL, # organization id
414 `log_id` bigint NOT NULL, # id of a record in tt_log this record corresponds to
415 `field_id` int(11) NOT NULL, # custom field id
416 `option_id` int(11) default NULL, # Option id. Used for dropdown custom fields.
417 `value` varchar(255) default NULL, # Text value. Used for text custom fields.
418 `status` tinyint(4) default 1, # custom field log entry status
422 create index log_idx on tt_custom_field_log(log_id);
426 # Structure for table tt_expense_items.
427 # This table lists expense items.
429 CREATE TABLE `tt_expense_items` (
430 `id` bigint NOT NULL auto_increment, # expense item id
431 `date` date NOT NULL, # date the record is for
432 `user_id` int(11) NOT NULL, # user id the expense item is reported by
433 `group_id` int(11) default NULL, # group id
434 `org_id` int(11) default NULL, # organization id
435 `client_id` int(11) default NULL, # client id
436 `project_id` int(11) default NULL, # project id
437 `name` text NOT NULL, # expense item name (what is an expense for)
438 `cost` decimal(10,2) default '0.00', # item cost (including taxes, etc.)
439 `invoice_id` int(11) default NULL, # invoice id
440 `approved` tinyint(4) default 0, # whether the item is approved
441 `paid` tinyint(4) default 0, # whether the item is paid
442 `created` datetime default NULL, # creation timestamp
443 `created_ip` varchar(45) default NULL, # creator ip
444 `created_by` int(11) default NULL, # creator user_id
445 `modified` datetime default NULL, # modification timestamp
446 `modified_ip` varchar(45) default NULL, # modifier ip
447 `modified_by` int(11) default NULL, # modifier user_id
448 `status` tinyint(4) default 1, # item status
452 # Create indexes on tt_expense_items for performance.
453 create index date_idx on tt_expense_items(date);
454 create index user_idx on tt_expense_items(user_id);
455 create index group_idx on tt_expense_items(group_id);
456 create index client_idx on tt_expense_items(client_id);
457 create index project_idx on tt_expense_items(project_id);
458 create index invoice_idx on tt_expense_items(invoice_id);
462 # Structure for table tt_predefined_expenses.
463 # This table keeps names and costs for predefined expenses.
465 CREATE TABLE `tt_predefined_expenses` (
466 `id` int(11) NOT NULL auto_increment, # predefined expense id
467 `group_id` int(11) NOT NULL, # group id
468 `org_id` int(11) default NULL, # organization id
469 `name` varchar(255) NOT NULL, # predefined expense name, such as mileage
470 `cost` decimal(10,2) default '0.00', # cost for one unit
476 # Structure for table tt_monthly_quotas.
477 # This table keeps monthly work hour quotas for groups.
479 CREATE TABLE `tt_monthly_quotas` (
480 `group_id` int(11) NOT NULL, # group id
481 `org_id` int(11) default NULL, # organization id
482 `year` smallint(5) UNSIGNED NOT NULL, # quota year
483 `month` tinyint(3) UNSIGNED NOT NULL, # quota month
484 `minutes` int(11) default NULL, # quota in minutes in specified month and year
485 PRIMARY KEY (`group_id`,`year`,`month`)
490 # Structure for table tt_timesheets. This table keeps timesheet related information.
492 CREATE TABLE `tt_timesheets` (
493 `id` int(11) NOT NULL auto_increment, # timesheet id
494 `user_id` int(11) NOT NULL, # user id
495 `group_id` int(11) default NULL, # group id
496 `org_id` int(11) default NULL, # organization id
497 `client_id` int(11) default NULL, # client id
498 `project_id` int(11) default NULL, # project id
499 `name` varchar(80) COLLATE utf8mb4_bin NOT NULL, # timesheet name
500 `comment` text, # timesheet comment
501 `start_date` date NOT NULL, # timesheet start date
502 `end_date` date NOT NULL, # timesheet end date
503 `submit_status` tinyint(4) default NULL, # submit status
504 `approve_status` tinyint(4) default NULL, # approve status
505 `approve_comment` text, # approve comment
506 `created` datetime default NULL, # creation timestamp
507 `created_ip` varchar(45) default NULL, # creator ip
508 `created_by` int(11) default NULL, # creator user_id
509 `modified` datetime default NULL, # modification timestamp
510 `modified_ip` varchar(45) default NULL, # modifier ip
511 `modified_by` int(11) default NULL, # modifier user_id
512 `status` tinyint(4) default 1, # timesheet status
518 # Structure for table tt_templates.
519 # This table keeps templates used in groups.
521 CREATE TABLE `tt_templates` (
522 `id` int(11) NOT NULL auto_increment, # template id
523 `group_id` int(11) default NULL, # group id
524 `org_id` int(11) default NULL, # organization id
525 `name` varchar(80) COLLATE utf8mb4_bin NOT NULL, # template name
526 `description` varchar(255) default NULL, # template description
527 `content` text, # template content
528 `created` datetime default NULL, # creation timestamp
529 `created_ip` varchar(45) default NULL, # creator ip
530 `created_by` int(11) default NULL, # creator user_id
531 `modified` datetime default NULL, # modification timestamp
532 `modified_ip` varchar(45) default NULL, # modifier ip
533 `modified_by` int(11) default NULL, # modifier user_id
534 `status` tinyint(4) default 1, # template status
540 # Structure for table tt_files.
541 # This table keeps file attachment information.
543 CREATE TABLE `tt_files` (
544 `id` int(10) unsigned NOT NULL auto_increment, # file id
545 `group_id` int(10) unsigned, # group id
546 `org_id` int(10) unsigned, # organization id
547 `remote_id` bigint(20) unsigned, # file id in storage facility
548 `file_key` varchar(32), # file key
549 `entity_type` varchar(32), # type of entity file is associated with (project, task, etc.)
550 `entity_id` int(10) unsigned, # entity id
551 `file_name` varchar(80) COLLATE utf8mb4_bin NOT NULL, # file name
552 `description` varchar(255) default NULL, # file description
553 `created` datetime default NULL, # creation timestamp
554 `created_ip` varchar(45) default NULL, # creator ip
555 `created_by` int(10) unsigned, # creator user_id
556 `modified` datetime default NULL, # modification timestamp
557 `modified_ip` varchar(45) default NULL, # modifier ip
558 `modified_by` int(10) unsigned, # modifier user_id
559 `status` tinyint(1) default 1, # file status
565 # Structure for table tt_work_currencies.
566 # This table keeps currencies supported by remote work plugin.
568 CREATE TABLE `tt_work_currencies` (
569 `id` int(10) unsigned NOT NULL, # currency id
570 `name` varchar(10) NOT NULL, # currency name (USD, CAD, etc.)
574 # Create an index that guarantees unique work currencies.
575 create unique index currency_idx on tt_work_currencies(`name`);
577 INSERT INTO `tt_work_currencies` (`id`, `name`) VALUES ('1', 'USD'), ('2', 'CAD'), ('3', 'AUD'), ('4', 'EUR'), ('5', 'NZD');
581 # Structure for table tt_work_categories.
582 # This table keeps work categories supported by remote work plugin.
584 CREATE TABLE `tt_work_categories` (
585 `id` int(10) unsigned NOT NULL, # Category id.
586 `parents` text default NULL, # Comma-separated list of parent ids associated with this category.
587 `name` varchar(64) NOT NULL, # English category name.
588 `name_localized` text default NULL, # Comma-separated list of localized category names in other languages.
589 # Example: es:Codificación,ru:Кодирование.
593 # Insert some default categories. Table content to be updated at run time, though.
594 INSERT INTO `tt_work_categories` (`id`, `parents`, `name`, `name_localized`) VALUES ('1', NULL, 'Coding', 'es:Codificación,ru:Кодирование');
595 INSERT INTO `tt_work_categories` (`id`, `parents`, `name`, `name_localized`) VALUES ('2', NULL, 'Other', 'es:Otra,ru:Другое');
596 INSERT INTO `tt_work_categories` (`id`, `parents`, `name`, `name_localized`) VALUES ('3', '1', 'PHP', NULL);
597 INSERT INTO `tt_work_categories` (`id`, `parents`, `name`, `name_localized`) VALUES ('4', '1', 'C/C++', NULL);
601 # Structure for table tt_site_config. This table stores configuration data
602 # for Time Tracker site as a whole.
603 # For example, database version, code version, site language, etc.
605 CREATE TABLE `tt_site_config` (
606 `param_name` varchar(32) NOT NULL, # parameter name
607 `param_value` text default NULL, # parameter value
608 `created` datetime default NULL, # creation timestamp
609 `modified` datetime default NULL, # modification timestamp
610 PRIMARY KEY (`param_name`)
613 INSERT INTO `tt_site_config` (`param_name`, `param_value`, `created`) VALUES ('version_db', '1.19.4', now()); # TODO: change when structure changes.