Forum OpenACS Q&A: loading new data model

Collapse
Posted by David Bell on
Hi,
  I have created a new .sql file in the sql/postgresql/ directory of my package. However I cannot get it to load. I have restarted the server and modified the info file. but it still wont load. What do i need to do to get the OACS to parse my sql files?

David

Collapse
2: Re: loading new data model (response to 1)
Posted by Ola Hansson on
One file must be named "yourpackagekey-create.sql" in order for the APM to react. Similarly, if you have drop scripts, one of them must be "yourpackagekey-drop.sql". The create file usually doesn't contain much of interest. What it usually does contain is stuff like:

/i yourpackagekey-tables-create.sql
/i yourpackagekey-packages-create.sql

on PostgreSQL ... or

@ yourpackagekey-tables-create.sql
@ yourpackagekey-packages-create.sql

on Oracle.

These lines will pull in the scripts that actually do something - but I'm sure you knew that part already.

After you have renamed the file, you should watch/reload the files of your package or restart the server.

BTW, Sometimes you see something like "@@ blah.sql", i.e., two @s instead of just one ... Can someone tell me what the difference is? I tried to Google but I couldn't find an answer.

/Ola

Collapse
3: Re: loading new data model (response to 1)
Posted by Jon Griffin on
IIRC, @ starts the path at the current directory and @@ is relative to /.

In most cases the file is in the same dir so @ is fine, but for example the reference package has common data in a ../ dir so @@ is used.

I am going from memory so I may be mistaken.

Collapse
4: Re: loading new data model (response to 1)
Posted by Don Baccus on
Just more info ... if you've added a .sql file and intend to drop and recreate your package instance (or entire OpenACS install) because you're in development, simply adding it to your <foo>-create.sql file is fine, as mentioned above.

If however recreating the package is inconvenient (it has live data, etc) you can either load the SQL file by hand or bump your package version number in the .info file, and add a file named "upgrade/upgrade-<old version>-<new version>.sql" under your sql/postgresql/ directory.  You'd then visit the APM, click on "install packages" and presto! you'll see your package offered labelled "upgrade" rather than "install".  This upgrade file would itself then reference your new .sql file.

Collapse
5: Re: loading new data model (response to 1)
Posted by David Bell on
Thanks Don, that update tip did the trick