Introduced menu.group into translation files.
[timetracker.git] / mysql.sql
index 07b17a2..9d2f1e7 100644 (file)
--- a/mysql.sql
+++ b/mysql.sql
 
 #
 # Structure for table tt_teams. A team is a group of users for whom we are tracking work time.
-# This table stores settings common to all team members such as language, week start day, etc.
+# This table stores settings common to all group members such as language, week start day, etc.
 #
 CREATE TABLE `tt_teams` (
-  `id` int(11) NOT NULL auto_increment,                      # team id
-  `timestamp` timestamp default CURRENT_TIMESTAMP,           # Modification timestamp. TODO: redo all timestamps to survive beyond 2038.
-  `name` varchar(80) default NULL,                           # team name
-  `currency` varchar(7) default NULL,                        # team currency symbol
-  `decimal_mark` char(1) NOT NULL default '.',               # separator in decimals
-  `lang` varchar(10) NOT NULL default 'en',                  # language
-  `date_format` varchar(20) NOT NULL default '%Y-%m-%d',     # date format
-  `time_format` varchar(20) NOT NULL default '%H:%M',        # time format
-  `week_start` smallint(2) NOT NULL default 0,               # Week start day, 0 == Sunday.
-  `tracking_mode` smallint(2) NOT NULL default 1,            # tracking mode ("time", "projects" or "projects and tasks")
-  `project_required` smallint(2) NOT NULL default 0,         # whether a project selection is required or optional
-  `task_required` smallint(2) NOT NULL default 0,            # whether a task selection is required or optional
-  `record_type` smallint(2) NOT NULL default 0,              # time record type ("start and finish", "duration", or both)
-  `bcc_email` varchar(100) default NULL,                     # bcc email to copy all reports to
-  `plugins` varchar(255) default NULL,                       # a list of enabled plugins for team
-  `lock_spec` varchar(255) default NULL,                     # Cron specification for record locking,
-                                                             # for example: "0 10 * * 1" for "weekly on Mon at 10:00".
-  `workday_minutes` smallint(4) default 480,                 # number of work minutes in a regular working day
-  `custom_logo` tinyint(4) default 0,                        # whether to use a custom logo or not
-  `config` text default NULL,                                # miscellaneous team configuration settings
-  `status` tinyint(4) default 1,                             # team status
+  `id` int(11) NOT NULL auto_increment,                  # group id
+  `parent_id` int(11) default NULL,                      # parent group id
+  `org_id` int(11) default NULL,                         # organization id (id of top group)
+  `name` varchar(80) default NULL,                       # group name
+  `currency` varchar(7) default NULL,                    # currency symbol
+  `decimal_mark` char(1) NOT NULL default '.',           # separator in decimals
+  `lang` varchar(10) NOT NULL default 'en',              # language
+  `date_format` varchar(20) NOT NULL default '%Y-%m-%d', # date format
+  `time_format` varchar(20) NOT NULL default '%H:%M',    # time format
+  `week_start` smallint(2) NOT NULL default 0,           # Week start day, 0 == Sunday.
+  `tracking_mode` smallint(2) NOT NULL default 1,        # tracking mode ("time", "projects" or "projects and tasks")
+  `project_required` smallint(2) NOT NULL default 0,     # whether a project selection is required or optional
+  `task_required` smallint(2) NOT NULL default 0,        # whether a task selection is required or optional
+  `record_type` smallint(2) NOT NULL default 0,          # time record type ("start and finish", "duration", or both)
+  `bcc_email` varchar(100) default NULL,                 # bcc email to copy all reports to
+  `plugins` varchar(255) default NULL,                   # a list of enabled plugins for team
+  `lock_spec` varchar(255) default NULL,                 # Cron specification for record locking,
+                                                         # for example: "0 10 * * 1" for "weekly on Mon at 10:00".
+  `workday_minutes` smallint(4) default 480,             # number of work minutes in a regular working day
+  `custom_logo` tinyint(4) default 0,                    # whether to use a custom logo or not
+  `config` text default NULL,                            # miscellaneous group configuration settings
+  `created` datetime default NULL,                       # creation timestamp
+  `created_ip` varchar(45) default NULL,                 # creator ip
+  `created_by` int(11) default NULL,                     # creator user_id
+  `modified` datetime default NULL,                      # modification timestamp
+  `modified_ip` varchar(45) default NULL,                # modifier ip
+  `modified_by` int(11) default NULL,                    # modifier user_id
+  `status` tinyint(4) default 1,                         # group status
   PRIMARY KEY (`id`)
 );
 
@@ -66,7 +73,7 @@ create unique index role_idx on tt_roles(team_id, rank, status);
 
 # Insert site-wide roles - site administrator and top manager.
 INSERT INTO `tt_roles` (`team_id`, `name`, `rank`, `rights`) VALUES (0, 'Site administrator', 1024, 'administer_site');
-INSERT INTO `tt_roles` (`team_id`, `name`, `rank`, `rights`) VALUES (0, 'Top manager', 512, 'track_own_time,track_own_expenses,view_own_reports,view_own_charts,view_own_invoices,manage_own_settings,view_users,track_time,track_expenses,view_reports,view_charts,override_punch_mode,override_own_punch_mode,override_date_lock,override_own_date_lock,swap_roles,approve_timesheets,manage_users,manage_projects,manage_tasks,manage_custom_fields,manage_clients,manage_invoices,manage_features,manage_basic_settings,manage_advanced_settings,manage_roles,export_data,manage_subgroups');
+INSERT INTO `tt_roles` (`team_id`, `name`, `rank`, `rights`) VALUES (0, 'Top manager', 512, 'track_own_time,track_own_expenses,view_own_reports,view_own_charts,view_own_invoices,view_own_projects,manage_own_settings,view_users,track_time,track_expenses,view_reports,view_charts,override_punch_mode,override_own_punch_mode,override_date_lock,override_own_date_lock,swap_roles,approve_timesheets,manage_own_account,manage_users,manage_projects,manage_tasks,manage_custom_fields,manage_clients,manage_invoices,manage_features,manage_basic_settings,manage_advanced_settings,manage_roles,export_data,manage_subgroups');
 
 
 #
@@ -74,7 +81,6 @@ INSERT INTO `tt_roles` (`team_id`, `name`, `rank`, `rights`) VALUES (0, 'Top man
 #
 CREATE TABLE `tt_users` (
   `id` int(11) NOT NULL auto_increment,            # user id
-  `timestamp` timestamp default CURRENT_TIMESTAMP, # modification timestamp
   `login` varchar(50) COLLATE utf8_bin NOT NULL,   # user login
   `password` varchar(50) default NULL,             # password hash
   `name` varchar(100) default NULL,                # user name
@@ -84,10 +90,10 @@ CREATE TABLE `tt_users` (
   `rate` float(6,2) NOT NULL default '0.00',       # default hourly rate
   `email` varchar(100) default NULL,               # user email
   `created` datetime default NULL,                 # creation timestamp
-  `created_ip` varchar(45) default NULL,           # creation ip
+  `created_ip` varchar(45) default NULL,           # creator ip
   `created_by` int(11) default NULL,               # creator user_id (null for self)
   `modified` datetime default NULL,                # modification timestamp
-  `modified_ip` varchar(45) default NULL,          # modification ip
+  `modified_ip` varchar(45) default NULL,          # modifier ip
   `modified_by` int(11) default NULL,              # modifier user_id
   `accessed` datetime default NULL,                # last access timestamp
   `accessed_ip` varchar(45) default NULL,          # last access ip
@@ -171,7 +177,6 @@ create index task_idx on tt_project_task_binds(task_id);
 #
 CREATE TABLE `tt_log` (
   `id` bigint NOT NULL auto_increment,             # time record id
-  `timestamp` timestamp default CURRENT_TIMESTAMP, # modification timestamp
   `user_id` int(11) NOT NULL,                      # user id
   `date` date NOT NULL,                            # date the record is for
   `start` time default NULL,                       # record start time (for example, 09:00)
@@ -183,6 +188,12 @@ CREATE TABLE `tt_log` (
   `comment` text,                                  # user provided comment for time record
   `billable` tinyint(4) default 0,                 # whether the record is billable or not
   `paid` tinyint(4) default 0,                     # whether the record is paid
+  `created` datetime default NULL,                 # creation timestamp
+  `created_ip` varchar(45) default NULL,           # creator ip
+  `created_by` int(11) default NULL,               # creator user_id
+  `modified` datetime default NULL,                # modification timestamp
+  `modified_ip` varchar(45) default NULL,          # modifier ip
+  `modified_by` int(11) default NULL,              # modifier user_id
   `status` tinyint(4) default 1,                   # time record status
   PRIMARY KEY (`id`)
 );
@@ -217,7 +228,7 @@ create unique index name_idx on tt_invoices(team_id, name, status);
 # Structure for table tt_tmp_refs. Used for reset password mechanism.
 #
 CREATE TABLE `tt_tmp_refs` (
-  `timestamp` timestamp default CURRENT_TIMESTAMP, # creation timestamp
+  `created` datetime default NULL,                 # creation timestamp
   `ref` char(32) NOT NULL default '',              # unique reference for user, used in urls
   `user_id` int(11) NOT NULL                       # user id
 );
@@ -245,6 +256,7 @@ CREATE TABLE `tt_fav_reports` (
   `show_client` tinyint(4) NOT NULL default 0,           # whether to show client column
   `show_invoice` tinyint(4) NOT NULL default 0,          # whether to show invoice column
   `show_paid` tinyint(4) NOT NULL default 0,             # whether to show paid column
+  `show_ip` tinyint(4) NOT NULL default 0,               # whether to show ip column
   `show_project` tinyint(4) NOT NULL default 0,          # whether to show project column
   `show_start` tinyint(4) NOT NULL default 0,            # whether to show start field
   `show_duration` tinyint(4) NOT NULL default 0,         # whether to show duration field
@@ -371,16 +383,22 @@ CREATE TABLE `tt_custom_field_log` (
 # This table lists expense items.
 #
 CREATE TABLE `tt_expense_items` (
-  `id` bigint NOT NULL auto_increment, # expense item id
-  `date` date NOT NULL,                # date the record is for
-  `user_id` int(11) NOT NULL,          # user id the expense item is reported by
-  `client_id` int(11) default NULL,    # client id
-  `project_id` int(11) default NULL,   # project id
-  `name` text NOT NULL,                # expense item name (what is an expense for)   
-  `cost` decimal(10,2) default '0.00', # item cost (including taxes, etc.)
-  `invoice_id` int(11) default NULL,   # invoice id
-  `paid` tinyint(4) default 0,         # whether the item is paid
-  `status` tinyint(4) default 1,       # item status
+  `id` bigint NOT NULL auto_increment,    # expense item id
+  `date` date NOT NULL,                   # date the record is for
+  `user_id` int(11) NOT NULL,             # user id the expense item is reported by
+  `client_id` int(11) default NULL,       # client id
+  `project_id` int(11) default NULL,      # project id
+  `name` text NOT NULL,                   # expense item name (what is an expense for)
+  `cost` decimal(10,2) default '0.00',    # item cost (including taxes, etc.)
+  `invoice_id` int(11) default NULL,      # invoice id
+  `paid` tinyint(4) default 0,            # whether the item is paid
+  `created` datetime default NULL,        # creation timestamp
+  `created_ip` varchar(45) default NULL,  # creator ip
+  `created_by` int(11) default NULL,      # creator user_id
+  `modified` datetime default NULL,       # modification timestamp
+  `modified_ip` varchar(45) default NULL, # modifier ip
+  `modified_by` int(11) default NULL,     # modifier user_id
+  `status` tinyint(4) default 1,          # item status
   PRIMARY KEY  (`id`)
 );
 
@@ -434,4 +452,4 @@ CREATE TABLE `tt_site_config` (
   PRIMARY KEY  (`param_name`)
 );
 
-INSERT INTO `tt_site_config` (`param_name`, `param_value`, `created`) VALUES ('version_db', '1.17.53', now()); # TODO: change when structure changes.
+INSERT INTO `tt_site_config` (`param_name`, `param_value`, `created`) VALUES ('version_db', '1.17.79', now()); # TODO: change when structure changes.