Index: openacs-4/packages/t-account/sql/postgresql/accounts-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/t-account/sql/postgresql/accounts-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/t-account/sql/postgresql/accounts-create.sql 11 May 2005 17:22:46 -0000 1.1 @@ -0,0 +1,41 @@ +-- -- make accounts table +-- +-- create table accounts +-- ( +-- account_id integer +-- constraint accounts__acct_id__cr_revs__fk +-- references cr_revisions +-- constraint accounts__acct_id__pk +-- primary key +-- ); + +-- make accounts object type + +select content_type__create_type +( + 'account', -- content_type + 'content_revision', -- supertype + 'Account', -- pretty_name, + 'Accounts', -- pretty_plural + 'accounts', -- table_name + 'account_id', -- id_column + null -- name_method +); + +-- necessary to work around limitation of content repository: +select content_folder__register_content_type(-100,'account','t'); + +-- create content type attributes + +select content_type__create_attribute +( + 'account', + 'account_name', + 'text', + 'Name of Account', + 'Names of Accounts', + null, + null, + 'varchar' +); + Index: openacs-4/packages/t-account/sql/postgresql/accounts-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/t-account/sql/postgresql/accounts-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/t-account/sql/postgresql/accounts-drop.sql 11 May 2005 17:22:46 -0000 1.1 @@ -0,0 +1,32 @@ +-- -- drop accounts in accounts table +-- +-- create function drop_accounts() returns int4 as +-- ' +-- ' +-- language 'plpgsql'; +-- +-- select drop_accounts(); +-- +-- drop function drop_accounts(); + +-- drop attributes + +select content_type__drop_attribute +( + 'account', + 'account_name', + 't' +); + +-- necessary to work around limitation of content repository: + +select content_folder__unregister_content_type(-100,'account','t'); + +-- drop accounts object type + +select content_type__drop_type('account', 't', 't'); + +-- -- drop accounts table +-- +-- drop table accounts; + Index: openacs-4/packages/t-account/sql/postgresql/accounts-funcs-createorreplace.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/t-account/sql/postgresql/accounts-funcs-createorreplace.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/t-account/sql/postgresql/accounts-funcs-createorreplace.sql 11 May 2005 17:22:46 -0000 1.1 @@ -0,0 +1,65 @@ +-- account__create +-- @param account_name text of name of account +-- @param parent_id id of cr_item to be parent +-- (note! must accept account type) +-- +-- returns the id of the item + +create or replace function account__create +( + varchar, -- account_name + int4 -- parent_id +) +returns int4 as +' +declare + account_name alias for $1; + parent_id alias for $2; + new_item_id int4; + new_rev_id int4; + +begin + new_item_id := content_item__new('an account', parent_id); + + insert into accountsi (item_id, account_name) + values (new_item_id, account_name); + + return new_item_id; +end; +' +language 'plpgsql'; + +-- account__delete +-- @param account_item_id id of cr_item of type 'account' to delete + +create or replace function account__delete +( + int4 -- delete_item_id +) +returns int4 as +' +declare + delete_item_id alias for $1; + revision_cursor record; + +begin + for + revision_cursor + in + select + r.revision_id + from + cr_revisions r + where + r.item_id = delete_item_id + loop + delete from accounts where account_id = revision_cursor.revision_id; + end loop; + + perform content_item__delete(delete_item_id); + + return 0; +end; +' +language 'plpgsql'; + Index: openacs-4/packages/t-account/sql/postgresql/accounts-funcs-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/t-account/sql/postgresql/accounts-funcs-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/t-account/sql/postgresql/accounts-funcs-drop.sql 11 May 2005 17:22:46 -0000 1.1 @@ -0,0 +1,4 @@ +-- drop account functions + +drop function account__delete(int4); +drop function account__create(varchar, int4); \ No newline at end of file Index: openacs-4/packages/t-account/sql/postgresql/t-account-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/t-account/sql/postgresql/t-account-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/t-account/sql/postgresql/t-account-create.sql 11 May 2005 17:22:46 -0000 1.1 @@ -0,0 +1,4 @@ +-- create the data model by passing the buck to sub files + +\i accounts-create.sql +\i accounts-funcs-createorreplace.sql Index: openacs-4/packages/t-account/sql/postgresql/t-account-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/t-account/sql/postgresql/t-account-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/t-account/sql/postgresql/t-account-drop.sql 11 May 2005 17:22:46 -0000 1.1 @@ -0,0 +1,4 @@ +-- drop the data model by passing the buck to sub files + +\i accounts-funcs-drop.sql +\i accounts-drop.sql \ No newline at end of file