Skip to content

Commit

Permalink
Fixed timestamps order.
Browse files Browse the repository at this point in the history
  • Loading branch information
ptdorf committed Jun 19, 2012
1 parent f1f67b5 commit 3de41f1
Showing 1 changed file with 140 additions and 136 deletions.
276 changes: 140 additions & 136 deletions resources/schema.sql
Original file line number Diff line number Diff line change
@@ -1,106 +1,110 @@
--
-- NeoInvoice Database
--
DROP DATABASE IF EXISTS neoinvoice;
CREATE DATABASE neoinvoice;

USE neoinvoice;

CREATE TABLE `affiliate` (
`id` int(10) unsigned not null auto_increment,
`name` varchar(63) not null,
`email` varchar(63) not null,
`phone` varchar(15) not null,
`commission` decimal(3,2) not null default '0.00',
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(63) NOT NULL,
`email` VARCHAR(63) NOT NULL,
`phone` VARCHAR(15) NOT NULL,
`commission` DECIMAL(3,2) NOT NULL DEFAULT '0.00',
PRIMARY KEY (`id`),
UNIQUE KEY (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
) ENGINE=INNODB DEFAULT CHARSET=latin1;

CREATE TABLE `ci_sessions` (
`session_id` varchar(40) not null default '0',
`ip_address` varchar(16) not null default '0',
`user_agent` varchar(50) not null,
`last_activity` int(10) unsigned not null default '0',
`user_data` varchar(512) not null,
`session_id` VARCHAR(40) NOT NULL DEFAULT '0',
`ip_address` VARCHAR(16) NOT NULL DEFAULT '0',
`user_agent` VARCHAR(50) NOT NULL,
`last_activity` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`user_data` VARCHAR(512) NOT NULL,
PRIMARY KEY (`session_id`)
) ENGINE=MEMORY DEFAULT CHARSET=latin1;

CREATE TABLE `client` (
`id` int(10) unsigned not null auto_increment,
`company_id` int(10) unsigned not null,
`active` tinyint(3) unsigned not null default '1',
`name` varchar(64) not null,
`email` varchar(64) not null,
`phone` varchar(16) not null,
`address` varchar(64) not null,
`created` timestamp not null default CURRENT_TIMESTAMP,
`modified` timestamp not null default '0000-00-00 00:00:00',
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`company_id` INT(10) UNSIGNED NOT NULL,
`active` TINYINT(3) UNSIGNED NOT NULL DEFAULT '1',
`name` VARCHAR(64) NOT NULL,
`email` VARCHAR(64) NOT NULL,
`phone` VARCHAR(16) NOT NULL,
`address` VARCHAR(64) NOT NULL,
`created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`modified` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`),
KEY `company_id` (`company_id`,`created`,`modified`),
KEY `active` (`active`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
) ENGINE=INNODB DEFAULT CHARSET=latin1;

CREATE TABLE `company` (
`id` int(10) unsigned not null auto_increment,
`name` varchar(127) not null,
`service_id` int(10) unsigned not null default '1',
`coupon_id` int(10) unsigned,
`service_expire` timestamp,
`delete_date` date,
`preferences` text not null,
`invoice_address` varchar(512) not null,
`created` timestamp not null default CURRENT_TIMESTAMP,
`modified` timestamp not null default '0000-00-00 00:00:00',
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(127) NOT NULL,
`service_id` INT(10) UNSIGNED NOT NULL DEFAULT '1',
`coupon_id` INT(10) UNSIGNED,
`created` TIMESTAMP NOT NULL DEFAULT NOW(),
`modified` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
`service_expire` TIMESTAMP,
`delete_date` DATE,
`preferences` TEXT NOT NULL,
`invoice_address` VARCHAR(512) NOT NULL,
PRIMARY KEY (`id`),
KEY `owner_id` (`service_id`),
KEY `service_expire` (`service_expire`),
KEY `coupon_id` (`coupon_id`),
KEY `delete_date` (`delete_date`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
) ENGINE=INNODB DEFAULT CHARSET=latin1;

CREATE TABLE `coupon` (
`id` int(10) unsigned not null auto_increment,
`name` varchar(16) not null,
`price` decimal(5,2) not null,
`default_service_id` int(10) unsigned not null default '0',
`default_service_expire` mediumint(8) unsigned not null default '0',
`affiliate_id` int(10) unsigned,
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(16) NOT NULL,
`price` DECIMAL(5,2) NOT NULL,
`default_service_id` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`default_service_expire` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
`affiliate_id` INT(10) UNSIGNED,
PRIMARY KEY (`id`),
UNIQUE KEY (`name`),
KEY `default_service_id` (`default_service_id`),
KEY `affiliate_id` (`affiliate_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
) ENGINE=INNODB DEFAULT CHARSET=latin1;

CREATE TABLE `emailsent` (
`id` int(10) unsigned not null auto_increment,
`company_id` int(10) unsigned not null,
`invoice_id` int(10) unsigned,
`email` varchar(63) not null,
`created` timestamp not null default CURRENT_TIMESTAMP,
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`company_id` INT(10) UNSIGNED NOT NULL,
`invoice_id` INT(10) UNSIGNED,
`email` VARCHAR(63) NOT NULL,
`created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `invoice_id` (`invoice_id`),
KEY `company_id` (`company_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
) ENGINE=INNODB DEFAULT CHARSET=latin1;

CREATE TABLE `expense` (
`id` int(10) unsigned not null auto_increment,
`company_id` int(10) unsigned not null,
`project_id` int(10) unsigned not null,
`invoice_id` int(10) unsigned,
`expensetype_id` int(10) unsigned not null,
`billable` tinyint(3) unsigned not null default '1',
`amount` decimal(8,2) not null default '0.00',
`date` date not null default '0000-00-00',
`content` text not null,
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`company_id` INT(10) UNSIGNED NOT NULL,
`project_id` INT(10) UNSIGNED NOT NULL,
`invoice_id` INT(10) UNSIGNED,
`expensetype_id` INT(10) UNSIGNED NOT NULL,
`billable` TINYINT(3) UNSIGNED NOT NULL DEFAULT '1',
`amount` DECIMAL(8,2) NOT NULL DEFAULT '0.00',
`date` DATE NOT NULL DEFAULT '0000-00-00',
`content` TEXT NOT NULL,
PRIMARY KEY (`id`),
KEY `project_id` (`project_id`,`billable`,`date`),
KEY `invoice_id` (`invoice_id`),
KEY `company_id` (`company_id`),
KEY `expensetype_id` (`expensetype_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
) ENGINE=INNODB DEFAULT CHARSET=latin1;

CREATE TABLE `expensetype` (
`id` int(10) unsigned not null auto_increment,
`company_id` int(10) unsigned not null,
`name` varchar(64) not null,
`content` text not null,
`taxable` int(2) not null,
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`company_id` INT(10) UNSIGNED NOT NULL,
`name` VARCHAR(64) NOT NULL,
`content` TEXT NOT NULL,
`taxable` INT(2) NOT NULL,
PRIMARY KEY (`id`),
KEY `company_id` (`company_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Expand Down Expand Up @@ -171,57 +175,57 @@ CREATE TABLE `project` (

CREATE TABLE `segment` (
`id` int(10) unsigned not null auto_increment,
`company_id` int(10) unsigned not null,
`project_id` int(10) unsigned not null,
`user_id` int(10) unsigned not null,
`worktype_id` int(10) unsigned not null,
`invoice_id` int(10) unsigned,
`ticket_id` int(10) unsigned,
`billable` tinyint(3) unsigned not null default '1',
`date` date not null default '0000-00-00',
`time_start` time not null default '00:00:00',
`duration` time not null default '00:00:00',
`content` text not null,
`company_id` INT(10) UNSIGNED NOT NULL,
`project_id` INT(10) UNSIGNED NOT NULL,
`user_id` INT(10) UNSIGNED NOT NULL,
`worktype_id` INT(10) UNSIGNED NOT NULL,
`invoice_id` INT(10) UNSIGNED,
`ticket_id` INT(10) UNSIGNED,
`billable` TINYINT(3) UNSIGNED NOT NULL DEFAULT '1',
`date` DATE NOT NULL DEFAULT '0000-00-00',
`time_start` TIME NOT NULL DEFAULT '00:00:00',
`duration` TIME NOT NULL DEFAULT '00:00:00',
`content` TEXT NOT NULL,
PRIMARY KEY (`id`),
KEY `project_id` (`project_id`,`user_id`,`worktype_id`,`billable`,`date`,`time_start`),
KEY `invoice_id` (`invoice_id`),
KEY `company_id` (`company_id`),
KEY `user_id` (`user_id`),
KEY `worktype_id` (`worktype_id`),
KEY `ticket_id` (`ticket_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
) ENGINE=INNODB DEFAULT CHARSET=latin1;

CREATE TABLE `service` (
`id` int(10) unsigned not null auto_increment,
`name` varchar(127) not null,
`price` decimal(6,2) unsigned not null default '0.00',
`pref_max_user` mediumint(9) unsigned not null,
`pref_max_email` mediumint(8) unsigned not null default '0',
`pref_custom_logo` tinyint(4) not null default '0',
`pref_custom_motd` tinyint(4) not null default '0',
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(127) NOT NULL,
`price` DECIMAL(6,2) UNSIGNED NOT NULL DEFAULT '0.00',
`pref_max_user` MEDIUMINT(9) UNSIGNED NOT NULL,
`pref_max_email` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
`pref_custom_logo` TINYINT(4) NOT NULL DEFAULT '0',
`pref_custom_motd` TINYINT(4) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4;
) ENGINE=INNODB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4;

INSERT INTO `service` (`id`, `name`, `price`, `pref_max_user`, `pref_max_email`, `pref_custom_logo`, `pref_custom_motd`) VALUES
('1', 'Free', '0.00', '10', '100', '1', '0'),
('2', 'Agency', '9.99', '100', '250', '1', '0'),
('3', 'Corporation', '49.99', '1000', '1500', '1', '1');

CREATE TABLE `ticket` (
`id` int(10) unsigned not null auto_increment,
`company_id` int(10) unsigned not null,
`project_id` int(10) unsigned not null,
`assigned_user_id` int(10) unsigned,
`assigned_usergroup_id` int(10) unsigned,
`created_user_id` int(10) unsigned,
`ticket_stage_id` int(10) unsigned,
`ticket_category_id` int(10) unsigned,
`name` varchar(127) not null,
`description` text not null,
`due` date,
`closed` timestamp,
`created` timestamp not null default CURRENT_TIMESTAMP,
`modified` timestamp not null default '0000-00-00 00:00:00',
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`company_id` INT(10) UNSIGNED NOT NULL,
`project_id` INT(10) UNSIGNED NOT NULL,
`assigned_user_id` INT(10) UNSIGNED,
`assigned_usergroup_id` INT(10) UNSIGNED,
`created_user_id` INT(10) UNSIGNED,
`ticket_stage_id` INT(10) UNSIGNED,
`ticket_category_id` INT(10) UNSIGNED,
`name` VARCHAR(127) NOT NULL,
`description` TEXT NOT NULL,
`due` DATE,
`created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`modified` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
`closed` TIMESTAMP,
PRIMARY KEY (`id`),
KEY `company_id` (`company_id`),
KEY `project_id` (`project_id`),
Expand All @@ -230,70 +234,70 @@ CREATE TABLE `ticket` (
KEY `created_user_id` (`created_user_id`),
KEY `ticket_stage_id` (`ticket_stage_id`),
KEY `ticket_category_id` (`ticket_category_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
) ENGINE=INNODB DEFAULT CHARSET=latin1;

CREATE TABLE `ticket_category` (
`id` int(10) unsigned not null auto_increment,
`company_id` int(10) unsigned not null,
`name` varchar(127) not null,
`description` text not null,
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`company_id` INT(10) UNSIGNED NOT NULL,
`name` VARCHAR(127) NOT NULL,
`description` TEXT NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY (`company_id`,`name`),
UNIQUE KEY `company_id_name`(`company_id`,`name`),
KEY `company_id` (`company_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
) ENGINE=INNODB DEFAULT CHARSET=latin1;

CREATE TABLE `ticket_stage` (
`id` int(10) unsigned not null auto_increment,
`company_id` int(10) unsigned not null,
`ticket_category_id` int(10) unsigned not null,
`name` varchar(127) not null,
`closed` tinyint(1) not null default '0',
`description` text not null,
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`company_id` INT(10) UNSIGNED NOT NULL,
`ticket_category_id` INT(10) UNSIGNED NOT NULL,
`name` VARCHAR(127) NOT NULL,
`closed` TINYINT(1) NOT NULL DEFAULT '0',
`description` TEXT NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY (`ticket_category_id`,`name`),
KEY `company_id` (`company_id`,`ticket_category_id`),
KEY `closed` (`closed`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
) ENGINE=INNODB DEFAULT CHARSET=latin1;

CREATE TABLE `user` (
`id` int(10) unsigned not null auto_increment,
`company_id` int(10) unsigned not null,
`usergroup_id` int(10) unsigned,
`active` tinyint(3) unsigned not null default '1',
`username` varchar(32) not null,
`password` varchar(40) not null,
`lost_password` varchar(40) not null,
`name` varchar(64) not null,
`permissions` text not null,
`preferences` text not null,
`email` varchar(64) not null,
`warning` int(10) unsigned not null default '0',
`created` timestamp not null default CURRENT_TIMESTAMP,
`modified` timestamp not null default '0000-00-00 00:00:00',
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`company_id` INT(10) UNSIGNED NOT NULL,
`usergroup_id` INT(10) UNSIGNED,
`active` TINYINT(3) UNSIGNED NOT NULL DEFAULT '1',
`username` VARCHAR(32) NOT NULL,
`password` VARCHAR(40) NOT NULL,
`lost_password` VARCHAR(40) NOT NULL,
`name` VARCHAR(64) NOT NULL,
`permissions` TEXT NOT NULL,
`preferences` TEXT NOT NULL,
`email` VARCHAR(64) NOT NULL,
`warning` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`modified` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`),
UNIQUE KEY (`username`,`email`),
KEY `company_id` (`company_id`),
KEY `active` (`active`),
KEY `usergroup_id` (`usergroup_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
) ENGINE=INNODB DEFAULT CHARSET=latin1;

CREATE TABLE `usergroup` (
`id` int(10) unsigned not null auto_increment,
`company_id` int(11) unsigned not null,
`name` varchar(127) not null,
`content` text not null,
`permissions` text not null,
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`company_id` INT(11) UNSIGNED NOT NULL,
`name` VARCHAR(127) NOT NULL,
`content` TEXT NOT NULL,
`permissions` TEXT NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY (`company_id`,`name`),
UNIQUE KEY `company_id_name` (`company_id`,`name`),
KEY `company_id` (`company_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
) ENGINE=INNODB DEFAULT CHARSET=latin1;

CREATE TABLE `worktype` (
`id` int(10) unsigned not null auto_increment,
`company_id` int(10) unsigned not null,
`name` varchar(64) not null,
`content` text not null,
`hourlyrate` double(6,2) not null,
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`company_id` INT(10) UNSIGNED NOT NULL,
`name` VARCHAR(64) NOT NULL,
`content` TEXT NOT NULL,
`hourlyrate` DOUBLE(6,2) NOT NULL,
PRIMARY KEY (`id`),
KEY `company_id` (`company_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
) ENGINE=INNODB DEFAULT CHARSET=latin1;

0 comments on commit 3de41f1

Please sign in to comment.