DROP TABLE IF EXISTS now available in mozStorage

This commit is contained in:
Dan Stillman 2006-03-22 16:42:22 +00:00
parent 6cad409813
commit 93c2b8c2ee
2 changed files with 13 additions and 31 deletions

View file

@ -375,21 +375,6 @@ Scholar.DB = new function(){
* Create new DB schema
*/
function _initializeSchema(){
// Until DROP TABLE IF EXISTS works with the mozStorage extension
try { query('DROP TABLE version'); } catch(e){}
try { query('DROP TABLE objects'); } catch(e){}
try { query('DROP TABLE objectTypes'); } catch(e){}
try { query('DROP TABLE fieldFormats'); } catch(e){}
try { query('DROP TABLE fields'); } catch(e){}
try { query('DROP TABLE objectTypeFields'); } catch(e){}
try { query('DROP TABLE objectData'); } catch(e){}
try { query('DROP TABLE keywords'); } catch(e){}
try { query('DROP TABLE objectKeywords'); } catch(e){}
try { query('DROP TABLE creators'); } catch(e){}
try { query('DROP TABLE creatorTypes'); } catch(e){}
try { query('DROP TABLE objectCreators'); } catch(e){}
try { query('DROP TABLE folders'); } catch(e){}
try {
beginTransaction();
var sql = _getSchemaSQL();

View file

@ -1,14 +1,11 @@
-- 2
-- IF EXISTS not yet available in available mozStorage binaries,
-- so we fake it with a bunch of try/catches in the _initializeSchema()
-- DROP TABLE IF EXISTS version;
DROP TABLE IF EXISTS version;
CREATE TABLE version (
version INTEGER PRIMARY KEY
);
-- DROP TABLE IF EXISTS objects;
DROP TABLE IF EXISTS objects;
CREATE TABLE objects (
objectID INTEGER PRIMARY KEY,
objectTypeID INT,
@ -23,20 +20,20 @@
);
CREATE INDEX folderID ON objects(folderID);
-- DROP TABLE IF EXISTS objectTypes;
DROP TABLE IF EXISTS objectTypes;
CREATE TABLE objectTypes (
objectTypeID INTEGER PRIMARY KEY,
typeName TEXT
);
-- DROP TABLE IF EXISTS fieldFormats;
DROP TABLE IF EXISTS fieldFormats;
CREATE TABLE fieldFormats (
fieldFormatID INTEGER PRIMARY KEY,
regex TEXT,
isInteger INT
);
-- DROP TABLE IF EXISTS fields;
DROP TABLE IF EXISTS fields;
CREATE TABLE fields (
fieldID INTEGER PRIMARY KEY,
fieldName TEXT,
@ -44,7 +41,7 @@
FOREIGN KEY (fieldFormatID) REFERENCES fieldFormat(fieldFormatID)
);
-- DROP TABLE IF EXISTS objectTypeFields;
DROP TABLE IF EXISTS objectTypeFields;
CREATE TABLE objectTypeFields (
objectTypeID INT,
fieldID INT,
@ -54,7 +51,7 @@
FOREIGN KEY (fieldID) REFERENCES objectTypes(objectTypeID)
);
-- DROP TABLE IF EXISTS objectData;
DROP TABLE IF EXISTS objectData;
CREATE TABLE objectData (
objectID INT,
fieldID INT,
@ -65,13 +62,13 @@
);
CREATE INDEX value ON objectData (value);
-- DROP TABLE IF EXISTS keywords;
DROP TABLE IF EXISTS keywords;
CREATE TABLE keywords (
keywordID INTEGER PRIMARY KEY,
keyword TEXT
);
-- DROP TABLE IF EXISTS objectKeywords;
DROP TABLE IF EXISTS objectKeywords;
CREATE TABLE objectKeywords (
objectID INT,
keywordID INT,
@ -80,7 +77,7 @@
FOREIGN KEY (keywordID) REFERENCES keywords(keywordID)
);
-- DROP TABLE IF EXISTS creators;
DROP TABLE IF EXISTS creators;
CREATE TABLE creators (
creatorID INT,
creatorTypeID INT DEFAULT 1,
@ -90,13 +87,13 @@
FOREIGN KEY (creatorTypeID) REFERENCES creatorTypes(creatorTypeID)
);
-- DROP TABLE IF EXISTS creatorTypes;
DROP TABLE IF EXISTS creatorTypes;
CREATE TABLE creatorTypes (
creatorTypeID INTEGER PRIMARY KEY,
creatorType TEXT
);
-- DROP TABLE IF EXISTS objectCreators;
DROP TABLE IF EXISTS objectCreators;
CREATE TABLE objectCreators (
objectID INT,
creatorID INT,
@ -106,7 +103,7 @@
FOREIGN KEY (creatorID) REFERENCES creators(creatorID)
);
-- DROP TABLE IF EXISTS folders;
DROP TABLE IF EXISTS folders;
CREATE TABLE folders (
folderID INTEGER PRIMARY KEY,
folderName TEXT,