postgresql and ERAttachmentMigrations

if I understand correctly, 

//from the tutorial file.

@Override
        public void upgrade(EOEditingContext editingContext, 
ERXMigrationDatabase database) throws Throwable {
                ERXMigrationTable personTable = 
database.newTableNamed("person");
                personTable.newIntegerColumn("erattachmentid", true);
                personTable.newLargeStringColumn("firstname", true);
                personTable.newIntegerColumn("id", false);
                personTable.newLargeStringColumn("lastname", true);
                personTable.create();
                personTable.setPrimaryKey("id");

                personTable.addForeignKey("erattachmentid", "ERAttachment", 
"id");
        }

Because of the correct setup of the Properties file, this should create both 
the "Person" and ERAttachment tables? Either I don't get this part or something 
is left out.

I had to factor out the:

personTable.newIntegerColumn("erattachmentid", true);
personTable.addForeignKey("erattachmentid", "ERAttachment", "id");

then create a second migration "Tutorial1" with:

package your.app.model.migrations;

import er.attachment.migrations.ERAttachmentMigration;


public class Tutorial1dontuse extends ERAttachmentMigration {
  public Tutorial1dontuse() {
                super("person", "erattachmentid", true);        
        }
}

Is this my problem with an incorrect setup? Or a setup problem with postgresql?

Obviously, I got it to work, but the implication of the tutorial is that I 
shouldn't have needed to do the second step.

Ted





--- On Sat, 10/16/10, Mike Schrag <msch...@pobox.com> wrote:

From: Mike Schrag <msch...@pobox.com>
Subject: Re: help with ERAttachments
To: "David Holt" <programming...@mac.com>
Cc: webobjects-dev@lists.apple.com, "Theodore Petrosky" <tedp...@yahoo.com>
Date: Saturday, October 16, 2010, 10:46 AM

re: "/attachments" appending to your path:
    if (!filesystemPath.contains("${")) {      filesystemPath = filesystemPath 
+ "/attachments/${hash}/${pk}${ext}";    }
if you don't specify any variables in your path, it appends them for you ... if 
you were to set your filesystem path to 
"/tmp/erattachments/${hash}/${pk}${ext}, it wouldn't.
ms
On Oct 15, 2010, at 5:05 PM, David Holt wrote:
The screencast is now live thanks to Pascal.
http://wocommunity.org/podcasts/ERAttachment-Tutorial.mov
David
On 2010-10-15, at 9:15 AM, David Holt wrote:
Hello Theodore,
On 2010-10-15, at 5:13 AM, Theodore Petrosky wrote:
Thank you. this is perfect. (almost) of course I use only postgresql and there 
are differences. like I had to factor out of the migration0 anything dealing 
with the erattachment table and create a second migration with:

Just swap in the database plugin you need for your database and get rid of the 
FrontBase plugin from the classpath. 
Rerun the creation of Migration0 from EntityModeler and replace the version 
that is in the project. That should get you the tables you need in the format 
your database uses.

public class Tutorial1 extends ERAttachmentMigration {
  public Tutorial1() {
                super("person", "erattachmentid", true);        
        }
}

and of course postgresql wants to fold all table/entities to lowercase.

now I can work backwards and understand what is happening.

Questions:

I see you set in the properties:

Watch the screen cast :-) which should be available pretty soon. I am just 
making it available for Pascal to post now.Also read the package overview as 
Kieran and Amedeo suggested. It explains all the settings that are used 
below.http://webobjects.mdimension.com/hudson/job/Wonder53/javadoc/er/attachment/package-summary.html

er.attachment.Person.photo.tempFolder = /tmp
er.attachment.Person.photo.maxSize = 2097152

Max file size allowed for upload
er.attachment.Person.photo.storageType = file

file, db or S3
er.attachment.Person.photo.file.overwrite = false

If true, a file with the same name overwrites, if false it adds a value to make 
the filename unique
er.attachment.Person.photo.file.filesystemPath = /tmp/erattachment

path to root folder for attachments
In the development mode, where is this location. (I can not find the attachment 
folder)

It will create any folders it needs in the system path. The only caveat is that 
it needs to be writeable by the application (in development OR deployment)
In deployment, where is webobjects expecting this to live?

Doesn't matter. I think I am using 
/Library/WebServer/Documents/ApplicationName/AttachmentIf you use the 
filesystem you'll likely need to make the folder writeable for your 
application.You can also use Amazon S3 or your database. It is all completely 
configurable.

Thank you for this wonderful example.

You are most welcome.
David





 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to