From 385ace71579b2184612373470e5da5e5b74bd648 Mon Sep 17 00:00:00 2001 From: dfrankow Date: Thu, 22 Jul 2004 16:50:07 +0000 Subject: [PATCH] Separate into 'initialize' and 'destroy' SQL git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@3908 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- schemas/minisql-destroy.sql | 12 ++ .../{minisql.sql => minisql-initialize.sql} | 12 +- schemas/mysql-destroy.sql | 17 +++ schemas/{mysql.sql => mysql-initialize.sql} | 12 +- schemas/oci8-destroy.sql | 112 ++++++++++++++++++ schemas/{oci8.sql => oci8-initialize.sql} | 22 +--- schemas/psql-destroy.sql | 89 ++++++++++++++ schemas/{psql.sql => psql-initialize.sql} | 16 +-- schemas/sqlite-destroy.sql | 5 + schemas/{sqlite.sql => sqlite-initialize.sql} | 2 +- 10 files changed, 240 insertions(+), 59 deletions(-) create mode 100644 schemas/minisql-destroy.sql rename schemas/{minisql.sql => minisql-initialize.sql} (88%) create mode 100644 schemas/mysql-destroy.sql rename schemas/{mysql.sql => mysql-initialize.sql} (87%) create mode 100644 schemas/oci8-destroy.sql rename schemas/{oci8.sql => oci8-initialize.sql} (89%) create mode 100644 schemas/psql-destroy.sql rename schemas/{psql.sql => psql-initialize.sql} (90%) create mode 100644 schemas/sqlite-destroy.sql rename schemas/{sqlite.sql => sqlite-initialize.sql} (95%) diff --git a/schemas/minisql-destroy.sql b/schemas/minisql-destroy.sql new file mode 100644 index 000000000..d8caa08a3 --- /dev/null +++ b/schemas/minisql-destroy.sql @@ -0,0 +1,12 @@ +# $Id: minisql-destroy.sql,v 1.1 2004-07-22 16:49:19 dfrankow Exp $ + +drop table wiki\g +drop table wikipages\g +drop table archive\g +drop table archivepages\g + +drop table wikilinks\g +drop table hottopics\g +drop table hitcount\g +drop table wikiscore\g + diff --git a/schemas/minisql.sql b/schemas/minisql-initialize.sql similarity index 88% rename from schemas/minisql.sql rename to schemas/minisql-initialize.sql index 7fff7e12b..387487750 100644 --- a/schemas/minisql.sql +++ b/schemas/minisql-initialize.sql @@ -1,14 +1,4 @@ -# $Id: minisql.sql,v 1.1 2001-12-03 04:05:38 wainstead Exp $ - -drop table wiki\g -drop table wikipages\g -drop table archive\g -drop table archivepages\g - -drop table wikilinks\g -drop table hottopics\g -drop table hitcount\g -drop table wikiscore\g +# $Id: minisql-initialize.sql,v 1.1 2004-07-22 16:49:19 dfrankow Exp $ # metadata about the page diff --git a/schemas/mysql-destroy.sql b/schemas/mysql-destroy.sql new file mode 100644 index 000000000..808e2750e --- /dev/null +++ b/schemas/mysql-destroy.sql @@ -0,0 +1,17 @@ +-- $Id: mysql-destroy.sql,v 1.1 2004-07-22 16:49:19 dfrankow Exp $ + +drop table if exists page; +drop table if exists version; +drop table if exists recent; +drop table if exists nonempty; +drop table if exists link; +drop table if exists session; + +-- upgrade from 1.3.7: + +drop table if exists pref; +drop table if exists user; +drop table if exists member; + +-- if you plan to use the wikilens theme +drop table if exists rating; diff --git a/schemas/mysql.sql b/schemas/mysql-initialize.sql similarity index 87% rename from schemas/mysql.sql rename to schemas/mysql-initialize.sql index eb8605f57..9cfb575be 100644 --- a/schemas/mysql.sql +++ b/schemas/mysql-initialize.sql @@ -1,6 +1,5 @@ --- $Id: mysql.sql,v 1.13 2004-04-21 04:31:10 rurban Exp $ +-- $Id: mysql-initialize.sql,v 1.1 2004-07-22 16:49:20 dfrankow Exp $ -drop table if exists page; CREATE TABLE page ( id INT NOT NULL AUTO_INCREMENT, pagename VARCHAR(100) BINARY NOT NULL, @@ -10,7 +9,6 @@ CREATE TABLE page ( UNIQUE KEY (pagename) ); -drop table if exists version; CREATE TABLE version ( id INT NOT NULL, version INT NOT NULL, @@ -22,7 +20,6 @@ CREATE TABLE version ( INDEX (mtime) ); -drop table if exists recent; CREATE TABLE recent ( id INT NOT NULL, latestversion INT, @@ -31,13 +28,11 @@ CREATE TABLE recent ( PRIMARY KEY (id) ); -drop table if exists nonempty; CREATE TABLE nonempty ( id INT NOT NULL, PRIMARY KEY (id) ); -drop table if exists link; CREATE TABLE link ( linkfrom INT NOT NULL, linkto INT NOT NULL, @@ -45,7 +40,6 @@ CREATE TABLE link ( INDEX (linkto) ); -drop table if exists session; CREATE TABLE session ( sess_id CHAR(32) NOT NULL DEFAULT '', sess_data BLOB NOT NULL, @@ -63,7 +57,6 @@ CREATE TABLE session ( -- For these tables below the default table prefix must be used -- in the DBAuthParam SQL statements also. -drop table if exists pref; CREATE TABLE pref ( userid CHAR(48) BINARY NOT NULL UNIQUE, prefs TEXT NULL DEFAULT '', @@ -72,7 +65,6 @@ CREATE TABLE pref ( -- better use the extra pref table where such users can be created easily -- without password. -drop table if exists user; CREATE TABLE user ( userid CHAR(48) BINARY NOT NULL UNIQUE, passwd CHAR(48) BINARY DEFAULT '', @@ -81,7 +73,6 @@ CREATE TABLE user ( PRIMARY KEY (userid) ) TYPE=MyISAM; -drop table if exists member; CREATE TABLE member ( userid CHAR(48) BINARY NOT NULL, groupname CHAR(48) BINARY NOT NULL DEFAULT 'users', @@ -90,7 +81,6 @@ CREATE TABLE member ( ) TYPE=MyISAM; -- if you plan to use the wikilens theme -drop table if exists rating; CREATE TABLE rating ( dimension INT(4) NOT NULL, raterpage INT(11) NOT NULL, diff --git a/schemas/oci8-destroy.sql b/schemas/oci8-destroy.sql new file mode 100644 index 000000000..43a7b455b --- /dev/null +++ b/schemas/oci8-destroy.sql @@ -0,0 +1,112 @@ +-- $Id: oci8-destroy.sql,v 1.1 2004-07-22 16:50:07 dfrankow Exp $ + +set verify off +set feedback off + +--================================================================ +-- Prefix for table names. +-- +-- You should set this to the same value you specify for +-- $DBParams['prefix'] in index.php. +-- +-- You have to use a prefix, because some phpWiki tablenames are +-- Oracle reserved words! + +define prefix=phpwiki_ + +--================================================================ +-- +-- Don't modify below this point unless you know what you are doing. +-- +--================================================================ + +--================================================================ +-- Note on Oracle datatypes... +-- +-- Most of the 'NOT NULL' constraints on the character columns have been +-- dropped since they can contain empty strings which are seen by +-- Oracle as NULL. +-- Oracle CLOBs are used for TEXTs/MEDUIMTEXTs columns. + + +prompt Initializing PhpWiki tables with: +prompt prefix = &prefix +prompt +prompt Expect some 'ORA-00942: table or view does not exist' unless you are +prompt overwriting existing tables. +prompt + +define page_tbl=&prefix.page +define page_id=&prefix.page_id +define page_nm=&prefix.page_nm + +define version_tbl=&prefix.version +define vers_id=&prefix.vers_id +define vers_mtime=&prefix.vers_mtime + +define recent_tbl=&prefix.recent +define recent_id=&prefix.recent_id + +define nonempty_tbl=&prefix.nonempty +define nonmt_id=&prefix.nonmt_id + +define link_tbl=&prefix.link +define link_from=&prefix.link_from +define link_to=&prefix.link_to + +define session_tbl=&prefix.session +define sess_id=&prefix.sess_id +define sess_date=&prefix.sess_date +define sess_ip=&prefix.sess_ip + +define pref_tbl=&prefix.pref +define pref_id=&prefix.pref_id + +define user_tbl=&prefix.user +define user_id=&prefix.user_id + +define member_tbl=&prefix.member +define member_userid=&prefix.member_userid +define member_groupname=&prefix.member_groupname + +define rating_tbl=&prefix.rating +define rating_id=&prefix.rating_id + + +prompt Dropping &page_tbl +DROP TABLE &page_tbl; + +prompt Dropping &version_tbl +DROP TABLE &version_tbl; + +prompt Dropping &recent_tbl +DROP TABLE &recent_tbl; + +prompt Dropping &nonempty_tbl +DROP TABLE &nonempty_tbl; + +prompt Dropping &link_tbl +DROP TABLE &link_tbl; + +prompt Dropping &session_tbl +DROP TABLE &session_tbl; + +-- Optional DB Auth and Prefs +-- For these tables below the default table prefix must be used +-- in the DBAuthParam SQL statements also. + +prompt Dropping &pref_tbl +DROP TABLE &pref_tbl; + +-- better use the extra pref table where such users can be created easily +-- without password. + +prompt Dropping &user_tbl +DROP TABLE &user_tbl; + +prompt Dropping &member_tbl +DROP TABLE &member_tbl; + +-- if you plan to use the wikilens theme +prompt Dropping &rating_tbl +DROP TABLE &rating_tbl; diff --git a/schemas/oci8.sql b/schemas/oci8-initialize.sql similarity index 89% rename from schemas/oci8.sql rename to schemas/oci8-initialize.sql index 4788b9dea..94f2324bb 100644 --- a/schemas/oci8.sql +++ b/schemas/oci8-initialize.sql @@ -1,4 +1,4 @@ --- $Id: oci8.sql,v 1.1 2004-06-27 10:26:03 rurban Exp $ +-- $Id: oci8-initialize.sql,v 1.1 2004-07-22 16:50:07 dfrankow Exp $ set verify off set feedback off @@ -73,8 +73,6 @@ define rating_tbl=&prefix.rating define rating_id=&prefix.rating_id -prompt Dropping &page_tbl -DROP TABLE &page_tbl; prompt Creating &page_tbl CREATE TABLE &page_tbl ( id INT NOT NULL, @@ -85,8 +83,6 @@ CREATE TABLE &page_tbl ( CONSTRAINT &page_nm UNIQUE (pagename) ); -prompt Dropping &version_tbl -DROP TABLE &version_tbl; prompt Creating &version_tbl CREATE TABLE &version_tbl ( id INT NOT NULL, @@ -99,8 +95,6 @@ CREATE TABLE &version_tbl ( ); CREATE INDEX &vers_mtime ON &version_tbl (mtime); -prompt Dropping &recent_tbl -DROP TABLE &recent_tbl; prompt Creating &recent_tbl CREATE TABLE &recent_tbl ( id INT NOT NULL, @@ -110,16 +104,12 @@ CREATE TABLE &recent_tbl ( CONSTRAINT &recent_id PRIMARY KEY (id) ); -prompt Dropping &nonempty_tbl -DROP TABLE &nonempty_tbl; prompt Creating &nonempty_tbl CREATE TABLE &nonempty_tbl ( id INT NOT NULL, CONSTRAINT &nonempty_tbl PRIMARY KEY (id) ); -prompt Dropping &link_tbl -DROP TABLE &link_tbl; prompt Creating &link_tbl CREATE TABLE &link_tbl ( linkfrom INT NOT NULL, @@ -128,8 +118,6 @@ CREATE TABLE &link_tbl ( CREATE INDEX &link_from ON &link_tbl (linkfrom); CREATE INDEX &link_to ON &link_tbl (linkto); -prompt Dropping &session_tbl -DROP TABLE &session_tbl; prompt Creating &session_tbl CREATE TABLE &session_tbl ( sess_id CHAR(32) DEFAULT '', @@ -145,8 +133,6 @@ CREATE INDEX &sess_ip ON &session_tbl (sess_ip); -- For these tables below the default table prefix must be used -- in the DBAuthParam SQL statements also. -prompt Dropping &pref_tbl -DROP TABLE &pref_tbl; prompt Creating &pref_tbl CREATE TABLE &pref_tbl ( userid CHAR(48) NOT NULL, @@ -157,8 +143,6 @@ CREATE TABLE &pref_tbl ( -- better use the extra pref table where such users can be created easily -- without password. -prompt Dropping &user_tbl -DROP TABLE &user_tbl; prompt Creating &user_tbl CREATE TABLE &user_tbl ( userid CHAR(48) NOT NULL, @@ -168,8 +152,6 @@ CREATE TABLE &user_tbl ( CONSTRAINT &user_id PRIMARY KEY (userid) ); -prompt Dropping &member_tbl -DROP TABLE &member_tbl; prompt Creating &member_tbl CREATE TABLE &member_tbl ( userid CHAR(48) NOT NULL, @@ -179,8 +161,6 @@ CREATE INDEX &member_userid ON &member_tbl (userid); CREATE INDEX &member_groupname ON &member_tbl (groupname); -- if you plan to use the wikilens theme -prompt Dropping &rating_tbl -DROP TABLE &rating_tbl; prompt Creating &rating_tbl CREATE TABLE &rating_tbl ( dimension NUMBER(4) NOT NULL, diff --git a/schemas/psql-destroy.sql b/schemas/psql-destroy.sql new file mode 100644 index 000000000..f9bfe6e68 --- /dev/null +++ b/schemas/psql-destroy.sql @@ -0,0 +1,89 @@ +-- $Id: psql-destroy.sql,v 1.1 2004-07-22 16:49:20 dfrankow Exp $ + +\set QUIET + + +--================================================================ +-- Prefix for table names. +-- +-- You should set this to the same value you specify for +-- $DBParams['prefix'] in index.php. + +\set prefix '' + +--================================================================ +-- Which postgres user gets access to the tables? +-- +-- You should set this to the name of the postgres +-- user who will be accessing the tables. +-- +-- Commonly, connections from php are made under +-- the user name of 'nobody', 'apache' or 'www'. + +\set httpd_user 'rurban' + +--================================================================ +-- +-- Don't modify below this point unless you know what you are doing. +-- +--================================================================ + +\set qprefix '\'' :prefix '\'' +\set qhttp_user '\'' :httpd_user '\'' +\echo Initializing PhpWiki tables with: +\echo ' prefix = ' :qprefix +\echo ' httpd_user = ' :qhttp_user +\echo +\echo 'Expect some \'Relation \'*\' does not exists\' errors unless you are' +\echo 'overwriting existing tables.' + +\set page_tbl :prefix 'page' +\set page_id :prefix 'page_id' +\set page_nm :prefix 'page_nm' + +\set version_tbl :prefix 'version' +\set vers_id :prefix 'vers_id' +\set vers_mtime :prefix 'vers_mtime' + +\set recent_tbl :prefix 'recent' +\set recent_id :prefix 'recent_id' + +\set nonempty_tbl :prefix 'nonempty' +\set nonmt_id :prefix 'nonmt_id' + +\set link_tbl :prefix 'link' +\set link_from :prefix 'link_from' +\set link_to :prefix 'link_to' + +\set session_tbl :prefix 'session' +\set sess_id :prefix 'sess_id' +\set sess_date :prefix 'sess_date' +\set sess_ip :prefix 'sess_ip' + +\set pref_tbl :prefix 'pref' +\set pref_id :prefix 'pref_id' + +\echo Dropping :page_tbl +DROP TABLE :page_tbl; + +\echo Dropping :version_tbl +DROP TABLE :version_tbl; + +\echo Dropping :recent_tbl +DROP TABLE :recent_tbl; + +\echo Dropping :nonempty_tbl +DROP TABLE :nonempty_tbl; + +\echo Dropping :link_tbl +DROP TABLE :link_tbl; + +\echo Dropping :session_tbl +DROP TABLE :session_tbl; + +-- Optional DB Auth and Prefs +-- For these tables below the default table prefix must be used +-- in the DBAuthParam SQL statements also. + +\echo Dropping :pref_tbl +DROP TABLE :pref_tbl; diff --git a/schemas/psql.sql b/schemas/psql-initialize.sql similarity index 90% rename from schemas/psql.sql rename to schemas/psql-initialize.sql index f504701c4..c1753297f 100644 --- a/schemas/psql.sql +++ b/schemas/psql-initialize.sql @@ -1,4 +1,4 @@ --- $Id: psql.sql,v 1.7 2004-04-15 16:42:07 rurban Exp $ +-- $Id: psql-initialize.sql,v 1.1 2004-07-22 16:49:20 dfrankow Exp $ \set QUIET @@ -63,8 +63,6 @@ \set pref_tbl :prefix 'pref' \set pref_id :prefix 'pref_id' -\echo Dropping :page_tbl -DROP TABLE :page_tbl; \echo Creating :page_tbl CREATE TABLE :page_tbl ( id INT NOT NULL, @@ -75,8 +73,6 @@ CREATE TABLE :page_tbl ( CREATE UNIQUE INDEX :page_id ON :page_tbl (id); CREATE UNIQUE INDEX :page_nm ON :page_tbl (pagename); -\echo Dropping :version_tbl -DROP TABLE :version_tbl; \echo Creating :version_tbl CREATE TABLE :version_tbl ( id INT NOT NULL, @@ -90,8 +86,6 @@ CREATE TABLE :version_tbl ( CREATE UNIQUE INDEX :vers_id ON :version_tbl (id,version); CREATE INDEX :vers_mtime ON :version_tbl (mtime); -\echo Dropping :recent_tbl -DROP TABLE :recent_tbl; \echo Creating :recent_tbl CREATE TABLE :recent_tbl ( id INT NOT NULL, @@ -102,8 +96,6 @@ CREATE TABLE :recent_tbl ( CREATE UNIQUE INDEX :recent_id ON :recent_tbl (id); -\echo Dropping :nonempty_tbl -DROP TABLE :nonempty_tbl; \echo Creating :nonempty_tbl CREATE TABLE :nonempty_tbl ( id INT NOT NULL @@ -111,8 +103,6 @@ CREATE TABLE :nonempty_tbl ( CREATE UNIQUE INDEX :nonmt_id ON :nonempty_tbl (id); -\echo Dropping :link_tbl -DROP TABLE :link_tbl; \echo Creating :link_tbl CREATE TABLE :link_tbl ( linkfrom INT NOT NULL, @@ -121,8 +111,6 @@ CREATE TABLE :link_tbl ( CREATE INDEX :link_from ON :link_tbl (linkfrom); CREATE INDEX :link_to ON :link_tbl (linkto); -\echo Dropping :session_tbl -DROP TABLE :session_tbl; \echo Creating :session_tbl CREATE TABLE :session_tbl ( sess_id CHAR(32) NOT NULL DEFAULT '', @@ -138,8 +126,6 @@ CREATE INDEX :sess_ip ON :session_tbl (sess_ip); -- For these tables below the default table prefix must be used -- in the DBAuthParam SQL statements also. -\echo Dropping :pref_tbl -DROP TABLE :pref_tbl; \echo Creating :pref_tbl CREATE TABLE :pref_tbl ( userid CHAR(48) NOT NULL, diff --git a/schemas/sqlite-destroy.sql b/schemas/sqlite-destroy.sql new file mode 100644 index 000000000..76d42760f --- /dev/null +++ b/schemas/sqlite-destroy.sql @@ -0,0 +1,5 @@ +-- http://www.hezmatt.org/~mpalmer/sqlite-phpwiki/sqlite.sql + +-- $Id: sqlite-destroy.sql,v 1.1 2004-07-22 16:49:20 dfrankow Exp $ + +-- Destroy not yet written ? diff --git a/schemas/sqlite.sql b/schemas/sqlite-initialize.sql similarity index 95% rename from schemas/sqlite.sql rename to schemas/sqlite-initialize.sql index 3fd1962fd..93655930f 100644 --- a/schemas/sqlite.sql +++ b/schemas/sqlite-initialize.sql @@ -1,6 +1,6 @@ -- http://www.hezmatt.org/~mpalmer/sqlite-phpwiki/sqlite.sql --- $Id: sqlite.sql,v 1.5 2004-07-05 14:12:59 rurban Exp $ +-- $Id: sqlite-initialize.sql,v 1.1 2004-07-22 16:49:20 dfrankow Exp $ CREATE TABLE page ( id INTEGER PRIMARY KEY, -- 2.45.0