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 -N -r1.10 -r1.10.2.1 --- openacs-4/packages/acs-core-docs/www/xml/developers-guide/tutorial-db.xml 4 Feb 2004 16:47:34 -0000 1.10 +++ openacs-4/packages/acs-core-docs/www/xml/developers-guide/tutorial-db.xml 5 Jul 2004 19:47:36 -0000 1.10.2.1 @@ -17,9 +17,9 @@ myfirstpackage/sql/ directory. All database scripts are database-specific and are thus in either the myfirstpackage/sql/oracle or - myfirstpackage/sql/postgresql. + myfirstpackage/sql/postgresql directory. Packages can support Oracle, PostgreSQL, or both. In this - tutorial, we'll work only with PostgreSQL + tutorial, we will be working with PostgreSQL The first file will be myfirstpackage-create.sql. The package manager requires a file with the name @@ -33,16 +33,17 @@ integrate our table with the OpenACS system. By making each record in our table an OpenACS object, we gain access to the permissions system and to services that integrate with OpenACS - objects, such as general-comments and notification. The cost - that our table creation code must include several functions and - stored procedures and is fairly complicated even for a simple - table. + objects, such as general-comments and + notification. The cost is + that our table creation code must include several functions, + stored procedures, and is complicated (even for simple tables). + There are many kinds of OpenACS objects in the system. (You - can see them with select object_type from + can see them with the psql code: select object_type from acs_object_types;.) One such object is the content_item, which is part of the content repository system. - We will make our data objects children of the content_item - object. Not only will we gain the benefits of both OpenACS + To use it, we will make our data objects children of the content_revision object, + which is a child of content_item. Not only will we gain the benefits of both OpenACS Objects and content objects, we can also use some content repository functions to simplify our database creation. (More information about ACS Objects. Tutorial Data Model - + @@ -63,58 +64,48 @@ by the API browser. The string $Id:$ will automatically be expanded when the file is checked in to cvs. -[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. +[$OPENACS_SERVICE_NAME ~]$ cd /var/lib/aolserver/$OPENACS_SERVICE_NAME/packages/myfirstpackage/sql/postgresql +[$OPENACS_SERVICE_NAME postgresql]$ emacs myfirstpackage-create.sql + Paste the text below into the file, save, and close.
- Database Creation Script - master create file + The Database Creation Script example missing
- The creation script calls a function, + The creation script calls a function in PL/pgSQL (PL/pgSQL is a procedural language extention to sql), 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 + object. Notice the use of "mfp." This is derived from "My + First Package" and 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. + Create a database file to drop everything if the package is uninstalled. -[service0 postgresql]$ emacs myfirstpackage-drop.sql +[$OPENACS_SERVICE_NAME postgresql]$ emacs myfirstpackage-drop.sql
- Database deletion script + Database Deletion Script example missing
+ (like the creation script the drop script calls a PL/pgSQL function: content_type__drop_type Run the create script manually to add your tables and functions. - [service0 postgresql]$ psql -f myfirstpackage-create.sql + [$OPENACS_SERVICE_NAME postgresql]$ psql -f myfirstpackage-create.sql 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]$ +[$OPENACS_SERVICE_NAME 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) + [$OPENACS_SERVICE_NAME postgresql]$ psql -f myfirstpackage-drop.sql content_type__drop_type ------------------------- 0 (1 row) -[service0 postgresql]$ +[$OPENACS_SERVICE_NAME postgresql]$ Once both scripts are working without errors, run the create script one last time and proceed. - [service0 postgresql]$ psql -f myfirstpackage-create.sql + [$OPENACS_SERVICE_NAME postgresql]$ psql -f myfirstpackage-create.sql - - \ No newline at end of file + \ No newline at end of file