Index: openacs-4/packages/acs-core-docs/www/xml/developers-guide/tutorial-db.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-core-docs/www/xml/developers-guide/tutorial-db.xml,v diff -u -r1.7.2.3 -r1.7.2.4 --- openacs-4/packages/acs-core-docs/www/xml/developers-guide/tutorial-db.xml 15 Dec 2003 14:18:48 -0000 1.7.2.3 +++ openacs-4/packages/acs-core-docs/www/xml/developers-guide/tutorial-db.xml 18 Jan 2004 17:07:16 -0000 1.7.2.4 @@ -1,5 +1,5 @@ - %myvars; @@ -55,77 +55,59 @@ by the API browser. The string $Id:$ will automatically be expanded when the file is checked in to cvs. -[service0 postgresql]$ emacs myfirstpackage-create.sql +[service0 ~]$ cd /var/lib/aolserver/service0/packages/myfirstpackage/sql/postgresql +[service0 postgresql]$ emacs myfirstpackage-create.sql Paste this into the file and save and close.
Database Creation Script - master create file - -- --- @author rhs@mit.edu --- @cvs-id $Id:$ --- - -select content_type__create_type( - 'mfp_note', -- content_type - 'content_revision', -- supertype - 'MFP Note', -- pretty_name, - 'MFP Notes', -- pretty_plural - 'mfp_notes', -- table_name - 'note_id', -- id_column - null -- name_method -); - --- necessary to work around limitation of content repository: -select content_folder__register_content_type(-100,'mfp_note','t'); - - + example missing
The creation script calls a function, - content_type__create_type, which + content_type__create_type, which in turn creates the necessary database changes to support our data object. Notice the use of "mfp." This token, derived from "My First Package," ensures that our object is unlikely to conflict with objects from other packages. Create a database file to drop everything if the package is uninstalled. - [service0 postgresql]$ emacs myfirstpackage-drop.sql + +[service0 postgresql]$ emacs myfirstpackage-drop.sql
Database deletion script - -- packages/myfirstpackage/sql/myfirstpackage-drop.sql --- drop script --- --- @author joel@aufrecht.org --- @cvs-id $Id:$ --- -select content_folder__unregister_content_type(-100,'mfp_note','t'); - -select content_type__drop_type( - 'mfp_note', - 't', - 't' - ); - + example missing
Run the create script manually to add your tables and functions. [service0 postgresql]$ psql -f myfirstpackage-create.sql -psql:myfirstpackage-create.sql:14: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'mfp_notes_pkey' for table 'mfp_notes' -psql:myfirstpackage-create.sql:14: NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s) +psql:myfirstpackage-create.sql:15: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'mfp_notes_pkey' for table 'mfp_notes' +psql:myfirstpackage-create.sql:15: NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s) content_type__create_type --------------------------- 0 (1 row) + content_folder__register_content_type +--------------------------------------- + 0 +(1 row) + [service0 postgresql]$ If there are errors, use them to debug the sql file and try again. If there are errors in the database table creation, you may need to run the drop script to drop the table so that you can recreate it. The drop script will probably have errors since some of the things it's trying to drop may be missing. They can be ignored. Once you get the same output as shown above, test the drop script: [service0 postgresql]$ psql -f myfirstpackage-drop.sql + content_folder__unregister_content_type +----------------------------------------- + 0 +(1 row) + content_type__drop_type ------------------------- 0 (1 row) [service0 postgresql]$ Once both scripts are working without errors, run the create script one last time and proceed. + [service0 postgresql]$ psql -f myfirstpackage-create.sql \ No newline at end of file