diff options
author | nikrou <nikrou@piwigo.org> | 2009-12-02 20:27:06 +0000 |
---|---|---|
committer | nikrou <nikrou@piwigo.org> | 2009-12-02 20:27:06 +0000 |
commit | fdfaefd17a7b3c91d214a60a27524bb138df3552 (patch) | |
tree | 56b7379da093bf2b6fc948215f6091a0cd988433 /install | |
parent | b8c33dcf2035f4cd5a67d918f1a5c490b128f9ae (diff) |
Feature 1255 :
- add postgres database engine
- change installation process to allow postgres or mysql database
git-svn-id: http://piwigo.org/svn/trunk@4410 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r-- | install.php | 117 | ||||
-rw-r--r-- | install/config.sql | 1 | ||||
-rw-r--r-- | install/piwigo_structure-mysql.sql (renamed from install/piwigo_structure.sql) | 0 | ||||
-rw-r--r-- | install/piwigo_structure-pgsql.sql | 649 |
4 files changed, 691 insertions, 76 deletions
diff --git a/install.php b/install.php index 727d1f954..2f66dc7b7 100644 --- a/install.php +++ b/install.php @@ -24,53 +24,7 @@ //----------------------------------------------------------- include define('PHPWG_ROOT_PATH','./'); -/** - * loads an sql file and executes all queries - * - * Before executing a query, $replaced is... replaced by $replacing. This is - * useful when the SQL file contains generic words. Drop table queries are - * not executed. - * - * @param string filepath - * @param string replaced - * @param string replacing - * @return void - */ -function execute_sqlfile($filepath, $replaced, $replacing) -{ - $sql_lines = file($filepath); - $query = ''; - foreach ($sql_lines as $sql_line) - { - $sql_line = trim($sql_line); - if (preg_match('/(^--|^$)/', $sql_line)) - { - continue; - } - $query.= ' '.$sql_line; - // if we reached the end of query, we execute it and reinitialize the - // variable "query" - if (preg_match('/;$/', $sql_line)) - { - $query = trim($query); - $query = str_replace($replaced, $replacing, $query); - // we don't execute "DROP TABLE" queries - if (!preg_match('/^DROP TABLE/i', $query)) - { - global $install_charset_collate; - if ( !empty($install_charset_collate) ) - { - if ( preg_match('/^(CREATE TABLE .*)[\s]*;[\s]*/im', $query, $matches) ) - { - $query = $matches[1].' '.$install_charset_collate.';'; - } - } - pwg_query($query); - } - $query = ''; - } - } -} +include(PHPWG_ROOT_PATH . 'admin/include/functions_install.inc.php'); @set_magic_quotes_runtime(0); // Disable magic_quotes_runtime // @@ -149,6 +103,7 @@ $dbhost = (!empty($_POST['dbhost'])) ? $_POST['dbhost'] : 'localhost'; $dbuser = (!empty($_POST['dbuser'])) ? $_POST['dbuser'] : ''; $dbpasswd = (!empty($_POST['dbpasswd'])) ? $_POST['dbpasswd'] : ''; $dbname = (!empty($_POST['dbname'])) ? $_POST['dbname'] : ''; +$dblayer = (!empty($_POST['dblayer'])) ? $_POST['dblayer'] : 'mysql'; if (isset($_POST['install'])) { @@ -182,7 +137,7 @@ if (@file_exists($config_file)) $prefixeTable = $table_prefix; include(PHPWG_ROOT_PATH . 'include/config_default.inc.php'); @include(PHPWG_ROOT_PATH. 'include/config_local.inc.php'); -include(PHPWG_ROOT_PATH . 'include/dblayer/functions_mysql.inc.php'); +include(PHPWG_ROOT_PATH .'include/dblayer/functions_'.$dblayer.'.inc.php'); include(PHPWG_ROOT_PATH . 'include/constants.php'); include(PHPWG_ROOT_PATH . 'include/functions.inc.php'); include(PHPWG_ROOT_PATH . 'admin/include/functions.php'); @@ -232,34 +187,36 @@ if (version_compare(PHP_VERSION, REQUIRED_PHP_VERSION, '<')) //----------------------------------------------------- template initialization include( PHPWG_ROOT_PATH .'include/template.class.php'); -$template=new Template(PHPWG_ROOT_PATH.'admin/template/goto', 'roma'); +$template = new Template(PHPWG_ROOT_PATH.'admin/template/goto', 'roma'); $template->set_filenames( array('install'=>'install.tpl') ); $step = 1; //---------------------------------------------------------------- form analyze if ( isset( $_POST['install'] )) { - if ( @mysql_connect( $_POST['dbhost'], - $_POST['dbuser'], - $_POST['dbpasswd'] ) ) + if (($pwg_db_link = pwg_db_connect($_POST['dbhost'], $_POST['dbuser'], + $_POST['dbpasswd'], $_POST['dbname']))!==false) { - if ( @mysql_select_db($_POST['dbname'] ) ) - { - array_push( $infos, l10n('step1_confirmation') ); - } - else - { - array_push( $errors, l10n('step1_err_db') ); - } - if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) + + array_push( $infos, l10n('step1_confirmation') ); + + $required_version = constant('REQUIRED_'.strtoupper($conf['dblayer']).'_VERSION'); + if ( version_compare(pwg_get_db_version(), $required_version, '>=') ) { - $pwg_charset='utf-8'; - $pwg_db_charset='utf8'; - $install_charset_collate = "DEFAULT CHARACTER SET $pwg_db_charset"; + $pwg_charset = 'utf-8'; + $pwg_db_charset = 'utf8'; + if ($dblayer=='mysql') + { + $install_charset_collate = "DEFAULT CHARACTER SET $pwg_db_charset"; + } + else + { + $install_charset_collate = ''; + } } else { - $pwg_charset='iso-8859-1'; - $pwg_db_charset='latin1'; + $pwg_charset = 'iso-8859-1'; + $pwg_db_charset = 'latin1'; $install_charset_collate = ''; if ( !array_key_exists($language, get_languages($pwg_charset) ) ) { @@ -292,7 +249,7 @@ if ( isset( $_POST['install'] )) { $step = 2; $file_content = '<?php -$conf[\'dblayer\'] = \'mysql\'; +$conf[\'dblayer\'] = \''.$dblayer.'\'; $conf[\'db_base\'] = \''.$dbname.'\'; $conf[\'db_user\'] = \''.$dbuser.'\'; $conf[\'db_password\'] = \''.$dbpasswd.'\'; @@ -326,7 +283,7 @@ define(\'DB_COLLATE\', \'\'); // tables creation, based on piwigo_structure.sql execute_sqlfile( - PHPWG_ROOT_PATH.'install/piwigo_structure.sql', + PHPWG_ROOT_PATH.'install/piwigo_structure-'.$dblayer.'.sql', DEFAULT_PREFIX_TABLE, $table_prefix ); @@ -337,6 +294,12 @@ define(\'DB_COLLATE\', \'\'); $table_prefix ); + $query = ' +INSERT INTO piwigo_config (param,value,comment) + VALUES (\'secret_key\',\'md5('.pwg_db_cast_to_text(DB_RANDOM_FUNCTION.'()').')\', + \'a secret key specific to the gallery for internal use\');'; + pwg_query($query); + // fill $conf global array load_conf_from_db(); @@ -389,6 +352,8 @@ define(\'DB_COLLATE\', \'\'); } //------------------------------------------------------ start template output +$dbengines = available_engines(); + foreach (get_languages('utf-8') as $language_code => $language_name) { if ($language == $language_code) @@ -402,15 +367,17 @@ $template->assign('language_options', $languages_options); $template->assign( array( 'T_CONTENT_ENCODING' => 'utf-8', - 'RELEASE'=>PHPWG_VERSION, + 'RELEASE' => PHPWG_VERSION, 'F_ACTION' => 'install.php?language=' . $language, - 'F_DB_HOST'=>$dbhost, - 'F_DB_USER'=>$dbuser, - 'F_DB_NAME'=>$dbname, + 'F_DB_ENGINES' => $dbengines, + 'F_DB_LAYER' => $dblayer, + 'F_DB_HOST' => $dbhost, + 'F_DB_USER' => $dbuser, + 'F_DB_NAME' => $dbname, 'F_DB_PREFIX' => $table_prefix, - 'F_ADMIN'=>$admin_name, - 'F_ADMIN_EMAIL'=>$admin_mail, - 'L_INSTALL_HELP'=>sprintf(l10n('install_help'), PHPWG_URL.'/forum'), + 'F_ADMIN' => $admin_name, + 'F_ADMIN_EMAIL' => $admin_mail, + 'L_INSTALL_HELP' => sprintf(l10n('install_help'), PHPWG_URL.'/forum'), )); //------------------------------------------------------ errors & infos display diff --git a/install/config.sql b/install/config.sql index 76c7bd6ae..107accdd2 100644 --- a/install/config.sql +++ b/install/config.sql @@ -17,7 +17,6 @@ INSERT INTO piwigo_config (param,value,comment) VALUES ('page_banner','<h1>Piwig INSERT INTO piwigo_config (param,value,comment) VALUES ('history_admin','false','keep a history of administrator visits on your website'); INSERT INTO piwigo_config (param,value,comment) VALUES ('history_guest','true','keep a history of guest visits on your website'); INSERT INTO piwigo_config (param,value,comment) VALUES ('allow_user_registration','true','allow visitors to register?'); -INSERT INTO piwigo_config (param,value,comment) VALUES ('secret_key', MD5(RAND()), 'a secret key specific to the gallery for internal use'); INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_send_html_mail','true','Send mail on HTML format for notification by mail'); INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_send_mail_as','','Send mail as param value for notification by mail'); INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_send_detailed_content','true','Send detailed content for notification by mail'); diff --git a/install/piwigo_structure.sql b/install/piwigo_structure-mysql.sql index 559addfc4..559addfc4 100644 --- a/install/piwigo_structure.sql +++ b/install/piwigo_structure-mysql.sql diff --git a/install/piwigo_structure-pgsql.sql b/install/piwigo_structure-pgsql.sql new file mode 100644 index 000000000..ec61ce0db --- /dev/null +++ b/install/piwigo_structure-pgsql.sql @@ -0,0 +1,649 @@ +----------------------------------------------------------------------------- +-- piwigo_caddie +----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS piwigo_caddie; +CREATE TABLE "piwigo_caddie" +( + "user_id" INTEGER default 0 NOT NULL, + "element_id" INTEGER default 0 NOT NULL, + PRIMARY KEY ("user_id","element_id") +); + +COMMENT ON TABLE "piwigo_caddie" IS ''; + + +SET search_path TO public; +----------------------------------------------------------------------------- +-- piwigo_categories +----------------------------------------------------------------------------- + +DROP TYPE IF EXISTS CATEGORIES_STATUS; +CREATE TYPE CATEGORIES_STATUS AS ENUM('public', 'private'); + +DROP TABLE IF EXISTS "piwigo_categories" CASCADE; +CREATE TABLE "piwigo_categories" +( + "id" serial NOT NULL, + "name" VARCHAR(255) default '' NOT NULL, + "id_uppercat" INTEGER, + "comment" TEXT, + "dir" VARCHAR(255), + "rank" INTEGER, + "status" CATEGORIES_STATUS default 'public'::CATEGORIES_STATUS, + "site_id" INTEGER default 1, + "visible" BOOLEAN default true, + "uploadable" BOOLEAN default false, + "representative_picture_id" INTEGER, + "uppercats" TEXT, + "commentable" BOOLEAN default true, + "global_rank" VARCHAR(255), + "image_order" VARCHAR(128), + "permalink" VARCHAR(64), + PRIMARY KEY ("id"), + CONSTRAINT "categories_i3" UNIQUE ("permalink") +); + +COMMENT ON TABLE "piwigo_categories" IS ''; + + +SET search_path TO public; +CREATE INDEX "categories_i2" ON "piwigo_categories" ("id_uppercat"); + +----------------------------------------------------------------------------- +-- piwigo_config +----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS "piwigo_config" CASCADE; +CREATE TABLE "piwigo_config" +( + "param" VARCHAR(40) default '' NOT NULL, + "value" TEXT, + "comment" VARCHAR(255), + PRIMARY KEY ("param") +); + +COMMENT ON TABLE "piwigo_config" IS ''; + + +SET search_path TO public; +----------------------------------------------------------------------------- +-- piwigo_favorites +----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS "piwigo_favorites" CASCADE; +CREATE TABLE "piwigo_favorites" +( + "user_id" INTEGER default 0 NOT NULL, + "image_id" INTEGER default 0 NOT NULL, + PRIMARY KEY ("user_id","image_id") +); + +COMMENT ON TABLE "piwigo_favorites" IS ''; + + +SET search_path TO public; +----------------------------------------------------------------------------- +-- piwigo_group_access +----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS "piwigo_group_access" CASCADE; +CREATE TABLE "piwigo_group_access" +( + "group_id" INTEGER default 0 NOT NULL, + "cat_id" INTEGER default 0 NOT NULL, + PRIMARY KEY ("group_id","cat_id") +); + +COMMENT ON TABLE "piwigo_group_access" IS ''; + + +SET search_path TO public; +----------------------------------------------------------------------------- +-- piwigo_groups +----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS "piwigo_groups" CASCADE; +CREATE TABLE "piwigo_groups" +( + "id" serial NOT NULL, + "name" VARCHAR(255) default '' NOT NULL, + "is_default" BOOLEAN default false, + PRIMARY KEY ("id"), + CONSTRAINT "groups_ui1" UNIQUE ("name") +); + +COMMENT ON TABLE "piwigo_groups" IS ''; + + +SET search_path TO public; +----------------------------------------------------------------------------- +-- piwigo_history +----------------------------------------------------------------------------- + +DROP TYPE IF EXISTS HISTORY_SECTION; +CREATE TYPE HISTORY_SECTION AS ENUM('categories','tags','search','list','favorites','most_visited','best_rated','recent_pics','recent_cats'); +DROP TYPE IF EXISTS HISTORY_IMAGE_TYPE; +CREATE TYPE HISTORY_IMAGE_TYPE AS ENUM('picture','high','other'); + +DROP TABLE IF EXISTS "piwigo_history" CASCADE; +CREATE TABLE "piwigo_history" +( + "id" serial NOT NULL, + "date" DATE NOT NULL, + "time" TIME NOT NULL, + "user_id" INTEGER default 0 NOT NULL, + "ip" VARCHAR(15) default '' NOT NULL, + "section" HISTORY_SECTION default NULL, + "category_id" INTEGER, + "tag_ids" VARCHAR(50), + "image_id" INTEGER, + "summarized" BOOLEAN default false, + "image_type" HISTORY_IMAGE_TYPE default NULL, + PRIMARY KEY ("id") +); + +COMMENT ON TABLE "piwigo_history" IS ''; + + +SET search_path TO public; +CREATE INDEX "history_i1" ON "piwigo_history" ("summarized"); + +----------------------------------------------------------------------------- +-- piwigo_history_summary +----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS "piwigo_history_summary" CASCADE; +CREATE TABLE "piwigo_history_summary" +( + "year" INTEGER default 0 NOT NULL, + "month" INTEGER, + "day" INTEGER, + "hour" INTEGER, + "nb_pages" INTEGER, + "id" serial NOT NULL, + PRIMARY KEY ("id"), + CONSTRAINT "history_summary_ymdh" UNIQUE ("year","month","day","hour") +); + +COMMENT ON TABLE "piwigo_history_summary" IS ''; + + +SET search_path TO public; +----------------------------------------------------------------------------- +-- piwigo_image_category +----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS "piwigo_image_category" CASCADE; +CREATE TABLE "piwigo_image_category" +( + "image_id" INTEGER default 0 NOT NULL, + "category_id" INTEGER default 0 NOT NULL, + "rank" INTEGER, + PRIMARY KEY ("image_id","category_id") +); + +COMMENT ON TABLE "piwigo_image_category" IS ''; + + +SET search_path TO public; +CREATE INDEX "image_category_i1" ON "piwigo_image_category" ("category_id"); + +----------------------------------------------------------------------------- +-- piwigo_image_tag +----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS "piwigo_image_tag" CASCADE; +CREATE TABLE "piwigo_image_tag" +( + "image_id" INTEGER default 0 NOT NULL, + "tag_id" INTEGER default 0 NOT NULL, + PRIMARY KEY ("image_id","tag_id") +); + +COMMENT ON TABLE "piwigo_image_tag" IS ''; + + +SET search_path TO public; +CREATE INDEX "image_tag_i1" ON "piwigo_image_tag" ("tag_id"); + +----------------------------------------------------------------------------- +-- piwigo_images +----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS "piwigo_images" CASCADE; +CREATE TABLE "piwigo_images" +( + "id" serial NOT NULL, + "file" VARCHAR(255) default '' NOT NULL, + "date_available" TIMESTAMP NOT NULL, + "date_creation" TIMESTAMP, + "tn_ext" VARCHAR(4) default '', + "name" VARCHAR(255), + "comment" TEXT, + "author" VARCHAR(255), + "hit" INTEGER default 0 NOT NULL, + "filesize" INTEGER, + "width" INTEGER, + "height" INTEGER, + "representative_ext" VARCHAR(4), + "date_metadata_update" DATE, + "average_rate" FLOAT, + "has_high" BOOLEAN default false, + "path" VARCHAR(255) default '' NOT NULL, + "storage_category_id" INTEGER, + "high_filesize" INTEGER, + "level" INTEGER default 0 NOT NULL, + "md5sum" CHAR(32), + PRIMARY KEY ("id") +); + +COMMENT ON TABLE "piwigo_images" IS ''; + + +SET search_path TO public; +CREATE INDEX "images_i2" ON "piwigo_images" ("date_available"); + +CREATE INDEX "images_i3" ON "piwigo_images" ("average_rate"); + +CREATE INDEX "images_i4" ON "piwigo_images" ("hit"); + +CREATE INDEX "images_i5" ON "piwigo_images" ("date_creation"); + +CREATE INDEX "images_i1" ON "piwigo_images" ("storage_category_id"); + +----------------------------------------------------------------------------- +-- piwigo_old_permalinks +----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS "piwigo_old_permalinks" CASCADE; +CREATE TABLE "piwigo_old_permalinks" +( + "cat_id" INTEGER default 0 NOT NULL, + "permalink" VARCHAR(64) default '' NOT NULL, + "date_deleted" TIMESTAMP NOT NULL, + "last_hit" TIMESTAMP, + "hit" INTEGER default 0 NOT NULL, + PRIMARY KEY ("permalink") +); + +COMMENT ON TABLE "piwigo_old_permalinks" IS ''; + + +SET search_path TO public; +----------------------------------------------------------------------------- +-- piwigo_plugins +----------------------------------------------------------------------------- + +DROP TYPE IF EXISTS PLUGINS_STATE; +CREATE TYPE PLUGINS_STATE AS ENUM('active', 'inactive'); + +DROP TABLE IF EXISTS "piwigo_plugins" CASCADE; +CREATE TABLE "piwigo_plugins" +( + "id" VARCHAR(64) default '' NOT NULL, + "state" PLUGINS_STATE default 'inactive'::PLUGINS_STATE, + "version" VARCHAR(64) default '0' NOT NULL, + PRIMARY KEY ("id") +); + +COMMENT ON TABLE "piwigo_plugins" IS ''; + + +SET search_path TO public; +----------------------------------------------------------------------------- +-- piwigo_rate +----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS "piwigo_rate" CASCADE; +CREATE TABLE "piwigo_rate" +( + "user_id" INTEGER default 0 NOT NULL, + "element_id" INTEGER default 0 NOT NULL, + "anonymous_id" VARCHAR(45) default '' NOT NULL, + "rate" INTEGER default 0 NOT NULL, + "date" DATE NOT NULL, + PRIMARY KEY ("user_id","element_id","anonymous_id") +); + +COMMENT ON TABLE "piwigo_rate" IS ''; + + +SET search_path TO public; +----------------------------------------------------------------------------- +-- piwigo_search +----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS "piwigo_search" CASCADE; +CREATE TABLE "piwigo_search" +( + "id" serial NOT NULL, + "last_seen" DATE, + "rules" TEXT, + PRIMARY KEY ("id") +); + +COMMENT ON TABLE "piwigo_search" IS ''; + + +SET search_path TO public; +----------------------------------------------------------------------------- +-- piwigo_sessions +----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS "piwigo_sessions" CASCADE; +CREATE TABLE "piwigo_sessions" +( + "id" VARCHAR(255) default '' NOT NULL, + "data" TEXT NOT NULL, + "expiration" TIMESTAMP NOT NULL, + PRIMARY KEY ("id") +); + +COMMENT ON TABLE "piwigo_sessions" IS ''; + + +SET search_path TO public; +----------------------------------------------------------------------------- +-- piwigo_sites +----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS "piwigo_sites" CASCADE; +CREATE TABLE "piwigo_sites" +( + "id" serial NOT NULL, + "galleries_url" VARCHAR(255) default '' NOT NULL, + PRIMARY KEY ("id"), + CONSTRAINT "sites_ui1" UNIQUE ("galleries_url") +); + +COMMENT ON TABLE "piwigo_sites" IS ''; + + +SET search_path TO public; +----------------------------------------------------------------------------- +-- piwigo_stuffs +----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS "piwigo_stuffs" CASCADE; +CREATE TABLE "piwigo_stuffs" +( + "id" INTEGER NOT NULL, + "pos" INTEGER NOT NULL, + "name" TEXT NOT NULL, + "descr" VARCHAR(255), + "type" VARCHAR(255) NOT NULL, + "datas" TEXT, + "users" VARCHAR(255), + "groups" VARCHAR(255), + "show_title" CHAR NOT NULL, + "on_home" CHAR NOT NULL, + "on_cats" CHAR NOT NULL, + "on_picture" CHAR NOT NULL, + "id_line" VARCHAR(1), + "width" INTEGER, + PRIMARY KEY ("id") +); + +COMMENT ON TABLE "piwigo_stuffs" IS ''; + + +SET search_path TO public; +CREATE INDEX "on_home" ON "piwigo_stuffs" ("on_home"); + +CREATE INDEX "on_cats" ON "piwigo_stuffs" ("on_cats"); + +CREATE INDEX "on_picture" ON "piwigo_stuffs" ("on_picture"); + +----------------------------------------------------------------------------- +-- piwigo_tags +----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS "piwigo_tags" CASCADE; +CREATE TABLE "piwigo_tags" +( + "id" serial NOT NULL, + "name" VARCHAR(255) default '' NOT NULL, + "url_name" VARCHAR(255) default '' NOT NULL, + PRIMARY KEY ("id") +); + +COMMENT ON TABLE "piwigo_tags" IS ''; + + +SET search_path TO public; +CREATE INDEX "tags_i1" ON "piwigo_tags" ("url_name"); + +----------------------------------------------------------------------------- +-- piwigo_upgrade +----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS "piwigo_upgrade" CASCADE; +CREATE TABLE "piwigo_upgrade" +( + "id" VARCHAR(20) default '' NOT NULL, + "applied" TIMESTAMP NOT NULL, + "description" VARCHAR(255), + PRIMARY KEY ("id") +); + +COMMENT ON TABLE "piwigo_upgrade" IS ''; + + +SET search_path TO public; +----------------------------------------------------------------------------- +-- piwigo_user_access +----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS "piwigo_user_access" CASCADE; +CREATE TABLE "piwigo_user_access" +( + "user_id" INTEGER default 0 NOT NULL, + "cat_id" INTEGER default 0 NOT NULL, + PRIMARY KEY ("user_id","cat_id") +); + +COMMENT ON TABLE "piwigo_user_access" IS ''; + + +SET search_path TO public; +----------------------------------------------------------------------------- +-- piwigo_user_cache +----------------------------------------------------------------------------- + +DROP TYPE IF EXISTS USER_CACHE_IMAGE_ACCESS_TYPE; +CREATE TYPE USER_CACHE_IMAGE_ACCESS_TYPE AS ENUM('NOT IN','IN'); + +DROP TABLE IF EXISTS "piwigo_user_cache" CASCADE; +CREATE TABLE "piwigo_user_cache" +( + "user_id" INTEGER default 0 NOT NULL, + "need_update" BOOLEAN default true, + "cache_update_time" INTEGER default 0 NOT NULL, + "forbidden_categories" TEXT, + "nb_total_images" INTEGER, + "image_access_type" USER_CACHE_IMAGE_ACCESS_TYPE default 'NOT IN'::USER_CACHE_IMAGE_ACCESS_TYPE, + "image_access_list" TEXT, + PRIMARY KEY ("user_id") +); + +COMMENT ON TABLE "piwigo_user_cache" IS ''; + + +SET search_path TO public; +----------------------------------------------------------------------------- +-- piwigo_user_cache_categories +----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS "piwigo_user_cache_categories" CASCADE; +CREATE TABLE "piwigo_user_cache_categories" +( + "user_id" INTEGER default 0 NOT NULL, + "cat_id" INTEGER default 0 NOT NULL, + "date_last" TIMESTAMP, + "max_date_last" TIMESTAMP, + "nb_images" INTEGER default 0 NOT NULL, + "count_images" INTEGER default 0, + "count_categories" INTEGER default 0, + PRIMARY KEY ("user_id","cat_id") +); + +COMMENT ON TABLE "piwigo_user_cache_categories" IS ''; + + +SET search_path TO public; +----------------------------------------------------------------------------- +-- piwigo_user_feed +----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS "piwigo_user_feed" CASCADE; +CREATE TABLE "piwigo_user_feed" +( + "id" VARCHAR(50) default '' NOT NULL, + "user_id" INTEGER default 0 NOT NULL, + "last_check" TIMESTAMP, + PRIMARY KEY ("id") +); + +COMMENT ON TABLE "piwigo_user_feed" IS ''; + + +SET search_path TO public; +----------------------------------------------------------------------------- +-- piwigo_user_group +----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS "piwigo_user_group" CASCADE; +CREATE TABLE "piwigo_user_group" +( + "user_id" INTEGER default 0 NOT NULL, + "group_id" INTEGER default 0 NOT NULL, + PRIMARY KEY ("user_id","group_id") +); + +COMMENT ON TABLE "piwigo_user_group" IS ''; + + +SET search_path TO public; +----------------------------------------------------------------------------- +-- piwigo_user_infos +----------------------------------------------------------------------------- + +DROP TYPE IF EXISTS USER_INFOS_STATUS; +CREATE TYPE USER_INFOS_STATUS AS ENUM('webmaster','admin','normal','generic','guest'); + +DROP TABLE IF EXISTS "piwigo_user_infos" CASCADE; +CREATE TABLE "piwigo_user_infos" +( + "user_id" INTEGER default 0 NOT NULL, + "nb_image_line" INTEGER default 5 NOT NULL, + "nb_line_page" INTEGER default 3 NOT NULL, + "status" USER_INFOS_STATUS default 'guest'::USER_INFOS_STATUS, + "adviser" BOOLEAN default false, + "language" VARCHAR(50) default 'en_UK' NOT NULL, + "maxwidth" INTEGER, + "maxheight" INTEGER, + "expand" BOOLEAN default false, + "show_nb_comments" BOOLEAN default false, + "show_nb_hits" BOOLEAN default false, + "recent_period" INTEGER default 7 NOT NULL, + "template" VARCHAR(255) default 'yoga/Sylvia' NOT NULL, + "registration_date" TIMESTAMP NOT NULL, + "enabled_high" BOOLEAN default true, + "level" INTEGER default 0 NOT NULL, + PRIMARY KEY ("user_id"), + CONSTRAINT "user_infos_ui1" UNIQUE ("user_id") +); + +COMMENT ON TABLE "piwigo_user_infos" IS ''; + + +SET search_path TO public; +----------------------------------------------------------------------------- +-- piwigo_user_mail_notification +----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS "piwigo_user_mail_notification" CASCADE; +CREATE TABLE "piwigo_user_mail_notification" +( + "user_id" INTEGER default 0 NOT NULL, + "check_key" VARCHAR(16) default '' NOT NULL, + "enabled" BOOLEAN default false, + "last_send" TIMESTAMP, + PRIMARY KEY ("user_id"), + CONSTRAINT "user_mail_notification_ui1" UNIQUE ("check_key") +); + +COMMENT ON TABLE "piwigo_user_mail_notification" IS ''; + + +SET search_path TO public; +----------------------------------------------------------------------------- +-- piwigo_users +----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS "piwigo_users" CASCADE; +CREATE TABLE "piwigo_users" +( + "id" serial NOT NULL, + "username" VARCHAR(100) default '' NOT NULL, + "password" VARCHAR(32), + "mail_address" VARCHAR(255), + PRIMARY KEY ("id"), + CONSTRAINT "users_ui1" UNIQUE ("username") +); + +COMMENT ON TABLE "piwigo_users" IS ''; + + +SET search_path TO public; + +----------------------------------------------------------------------------- +-- piwigo_comments +----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS "piwigo_comments" CASCADE; +CREATE TABLE "piwigo_comments" +( + "id" serial NOT NULL, + "image_id" INTEGER default 0 NOT NULL, + "date" TIMESTAMP NOT NULL, + "author" VARCHAR(255), + "content" TEXT, + "validated" BOOLEAN default false, + "validation_date" TIMESTAMP, + "author_id" INTEGER REFERENCES "piwigo_users" (id), + PRIMARY KEY ("id") +); + +COMMENT ON TABLE "piwigo_comments" IS ''; + + +SET search_path TO public; +CREATE INDEX "comments_i2" ON "piwigo_comments" ("validation_date"); + +CREATE INDEX "comments_i1" ON "piwigo_comments" ("image_id"); + +----------------------------------------------------------------------------- +-- piwigo_waiting +----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS "piwigo_waiting" CASCADE; +CREATE TABLE "piwigo_waiting" +( + "id" serial NOT NULL, + "storage_category_id" INTEGER default 0 NOT NULL, + "file" VARCHAR(255) default '' NOT NULL, + "username" VARCHAR(255) default '' NOT NULL, + "mail_address" VARCHAR(255) default '' NOT NULL, + "date" INTEGER default 0 NOT NULL, + "tn_ext" CHAR(3), + "validated" BOOLEAN default false, + "infos" TEXT, + PRIMARY KEY ("id") +); + +COMMENT ON TABLE "piwigo_waiting" IS ''; + + +SET search_path TO public;
\ No newline at end of file |