From 6669a074347f1962bd57589bc2f5b58df3dcf971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Serman?= Date: Fri, 24 Aug 2012 15:05:22 +0000 Subject: [PATCH] Modified database for piwik: added an uniq index to user, and a piwik_sites table --- install/mysql.sql | 27 +++++++++++++++++++++------ install/upgrades/1.1.sql | 30 +++++++++++++++++++++++------- 2 files changed, 44 insertions(+), 13 deletions(-) diff --git a/install/mysql.sql b/install/mysql.sql index 50920047..5852c60c 100644 --- a/install/mysql.sql +++ b/install/mysql.sql @@ -693,10 +693,25 @@ where (`v`.`name` = 'mailname_bounce'); -- Structure de la table `piwik_users` -- -CREATE TABLE IF NOT EXISTS `piwik_users` ( -`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , -`uid` INT NOT NULL , -`login` VARCHAR( 255 ) NOT NULL , -`created_date` TIMESTAMP NOT NULL -) ENGINE = MYISAM ; +CREATE TABLE IF NOT EXISTS `piwik_users` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `uid` int(11) NOT NULL, + `login` varchar(255) NOT NULL, + `created_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE KEY `uniq_user` (`login`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=18 ; + +-- +-- Structure de la table `piwik_sites` +-- + +CREATE TABLE IF NOT EXISTS `piwik_sites` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `uid` int(11) NOT NULL, + `piwik_id` int(11) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `unique_site_per_user` (`uid`,`piwik_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; + diff --git a/install/upgrades/1.1.sql b/install/upgrades/1.1.sql index 2e997fd8..79b34098 100644 --- a/install/upgrades/1.1.sql +++ b/install/upgrades/1.1.sql @@ -166,12 +166,28 @@ CREATE TABLE IF NOT EXISTS `cron` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Piwik user tables +-- Structure de la table `piwik_users` -- -CREATE TABLE IF NOT EXISTS `piwik_users` ( -`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , -`uid` INT NOT NULL , -`login` VARCHAR( 255 ) NOT NULL , -`created_date` TIMESTAMP NOT NULL -) ENGINE = MYISAM ; + +CREATE TABLE IF NOT EXISTS `piwik_users` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `uid` int(11) NOT NULL, + `login` varchar(255) NOT NULL, + `created_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE KEY `uniq_user` (`login`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=18 ; + +-- +-- Structure de la table `piwik_sites` +-- + +CREATE TABLE IF NOT EXISTS `piwik_sites` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `uid` int(11) NOT NULL, + `piwik_id` int(11) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `unique_site_per_user` (`uid`,`piwik_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; +