I've just started testing postgreSQL as a backend database for an
NT-based intranet application running on Cold Fusion.
The application will automatically create the database structure if it
does not already exist, by executing a series of CREATE TABLE statements
through the ODBC driver.
However, only the first table is being created.
Each statement is in a separate request, and any one statement will
execute, but only if it is the first. Even more puzzling is the fact
that subsequent calls do not throw an error. The first error I see is
when an attempt is made to insert data into a non-existent table.
The application has tested out fine on both MS Access and MS SQL Server.
The ODBC driver version is 6.40.0002
Code follows:
(For those not familiar with Cold Fusion, the <CFQUERY> tags specify a
distinct database call. #attributes.datasource# is a variable name
containing the DSN)
<CFQUERY DATASOURCE="#attributes.datasource#">
CREATE TABLE FMGroups
(
GroupID INTEGER NOT NULL,
GroupName VARCHAR(64) NOT NULL,
Description VARCHAR(100),
CONSTRAINT ID_pk PRIMARY KEY (GroupID),
CONSTRAINT check_directory UNIQUE (GroupName)
)
</CFQUERY>
<CFQUERY DATASOURCE="#attributes.datasource#">
CREATE TABLE FMDirectories
(
DirectoryID INTEGER NOT NULL,
DirectoryName VARCHAR(64) NOT NULL,
Description VARCHAR(100),
ParentID INTEGER NOT NULL,
CONSTRAINT ID_pk PRIMARY KEY (DirectoryID),
CONSTRAINT check_directory UNIQUE (DirectoryName)
)
</CFQUERY>
<CFQUERY DATASOURCE="#attributes.datasource#">
CREATE TABLE FMFiles
(
FileID INTEGER NOT NULL,
DirectoryID INTEGER,
FilePath VARCHAR(255) NOT NULL,
DisplayName VARCHAR(100) NOT NULL,
Description VARCHAR(100),
AddedBy VARCHAR(64) NOT NULL,
DateModified datetime NOT NULL,
CONSTRAINT ID_pk PRIMARY KEY (FileID),
CONSTRAINT check_path UNIQUE (FilePath),
CONSTRAINT check_directory FOREIGN KEY (DirectoryID) REFERENCES
FMDirectories (DirectoryID)
)
</CFQUERY>
<CFQUERY DATASOURCE="#attributes.datasource#">
CREATE TABLE FMPermissions
(
GroupID INTEGER NOT NULL,
DirectoryID INTEGER NOT NULL,
Permissions INTEGER NOT NULL,
CONSTRAINT ID_pk PRIMARY KEY (GroupID, DirectoryID),
CONSTRAINT check_group FOREIGN KEY (GroupID) REFERENCES FMGroups
(GroupID),
CONSTRAINT check_directoryID FOREIGN KEY (DirectoryID)
REFERENCES FMDirectories (DirectoryID)
)
</CFQUERY>
<CFQUERY DATASOURCE="#attributes.datasource#">
CREATE TABLE FMUserGroups
(
USERNAME VARCHAR(64) NOT NULL,
GroupID INTEGER NOT NULL,
CONSTRAINT check_groupID FOREIGN KEY (GroupID) REFERENCES
FMGroups (GroupID),
CONSTRAINT ID_pk PRIMARY KEY (USERNAME)
)
</CFQUERY>
Michael J. Sheldon
CBR Communications
Graphic design and Internet services.
A division of Commercial Blueprint Co., Inc.
http://www.cbrcomm.com
(602)707-1545
PGP Key available on request