Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Installing SilverStripe /

Getting SilverStripe up and running on your computer and on your web server.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Installing 3.0 on Postgres fails on database creation


Reply


2 Posts   473 Views

Avatar
rturja

Community Member, 4 Posts

10 July 2012 at 7:06am

When installing a fresh SS on my server, the installation process stops after database is created on population stage - no tables are set up. My Postgres is version 8.4, Apache 2.2 with php 5.3.14 module running on top of FreeBSD. The exact same error happens with both trunk and stable versions of SS postgres connector.

The failure occurs at

•pg_query(Resource id #3646,CREATE TABLE "Email_BounceRecord" ( "ID" serial8 not null, "ClassName" varchar(255) default 'Email_BounceRecord' check ("ClassName" in ('Email_BounceRecord')), "Created" timestamp, "LastEdited" timestamp, "BounceEmail" varchar(50), "BounceTime" timestamp, "BounceMessage" varchar(50), "MemberID" integer default 0, primary key ("ID") ); create index ix_Email_BounceRecord_MemberID ON "Email_BounceRecord" (""MemberID""); create index ix_Email_BounceRecord_ClassName ON "Email_BounceRecord" (""ClassName""); )
PostgreSQLDatabase.php:209
•PostgreSQLDatabase->query(CREATE TABLE "Email_BounceRecord" ( "ID" serial8 not null, "ClassName" varchar(255) default 'Email_BounceRecord' check ("ClassName" in ('Email_BounceRecord')), "Created" timestamp, "LastEdited" timestamp, "BounceEmail" varchar(50), "BounceTime" timestamp, "BounceMessage" varchar(50), "MemberID" integer default 0, primary key ("ID") ); create index ix_Email_BounceRecord_MemberID ON "Email_BounceRecord" (""MemberID""); create index ix_Email_BounceRecord_ClassName ON "Email_BounceRecord" (""ClassName""); )
PostgreSQLDatabase.php:360
•PostgreSQLDatabase->createTable(Email_BounceRecord,Array,Array,Array,) Database.php:210
•SS_Database->endSchemaUpdate() DatabaseAdmin.php:213
•DatabaseAdmin->doBuild(,1) DatabaseAdmin.php:102

The actual error seems to be double "s inserted in the query somewhere in the builder resulting in double delimetering the text. As I'm more of a server than php guy, any idea where and how to correct the seemingly malformed query?

Avatar
rturja

Community Member, 4 Posts

10 July 2012 at 8:01am

Edited: 10/07/2012 8:02am

Okay... this is probably not the most stylish way to correct the issue, but...

substituting line 459 of PostgreSQLDatabase.php

$this->createOrReplacePartition($tableName, $extensions['partitions'],$indexes, $extensions);


with this

$this->createOrReplacePartition($tableName, $extensions['partitions'], str_replace("\"\"","\"",$indexes), $extensions);

and modifying this block starting at line 447:

$this->query("CREATE TABLE \"$tableName\" (
$fieldSchemas
$fulltexts
primary key (\"ID\")
)$tableSpace; $indexSchemas; $addOptions");


with this

$fixindex=str_replace("\"\"","\"",$indexSchemas);
$this->query("CREATE TABLE \"$tableName\" (
$fieldSchemas
$fulltexts
primary key (\"ID\")
)$tableSpace; $fixindex; $addOptions");

made the install complete without errors for me :)