From b03df92e48df653460cb8b6034a06dd1de6f4095 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 28 Jan 2002 05:15:29 +0000 Subject: [PATCH] part_export schema changes --- FS/FS/part_export.pm | 138 ++++++++++++++++++++++++++++++++++++++++++ FS/FS/part_export_option.pm | 134 ++++++++++++++++++++++++++++++++++++++++ README.1.4.0pre4567-8 | 31 +++++++++- bin/fs-setup | 28 ++++++++- httemplate/docs/schema.html | 15 +++++ httemplate/docs/upgrade8.html | 19 ++++++ 6 files changed, 362 insertions(+), 3 deletions(-) create mode 100644 FS/FS/part_export.pm create mode 100644 FS/FS/part_export_option.pm diff --git a/FS/FS/part_export.pm b/FS/FS/part_export.pm new file mode 100644 index 000000000..67371bc3b --- /dev/null +++ b/FS/FS/part_export.pm @@ -0,0 +1,138 @@ +package FS::part_export; + +use strict; +use vars qw( @ISA ); +use FS::Record qw( qsearch qsearchs ); +use FS::part_svc; + +@ISA = qw(FS::Record); + +=head1 NAME + +FS::part_export - Object methods for part_export records + +=head1 SYNOPSIS + + use FS::part_export; + + $record = new FS::part_export \%hash; + $record = new FS::part_export { 'column' => 'value' }; + + $error = $record->insert; + + $error = $new_record->replace($old_record); + + $error = $record->delete; + + $error = $record->check; + +=head1 DESCRIPTION + +An FS::part_export object represents an export of Freeside data to an external +provisioning system. FS::part_export inherits from FS::Record. The following +fields are currently supported: + +=over 4 + +=item eventpart - primary key + +=item svcpart - Service definition (see L) to which this export applies + +=item machine - Machine name + +=item exporttype - Export type + +=item nodomain - blank or "Y" : usernames are exported to this service with no domain + +=back + +=head1 METHODS + +=over 4 + +=item new HASHREF + +Creates a new export. To add the export to the database, see L<"insert">. + +Note that this stores the hash reference, not a distinct copy of the hash it +points to. You can ask the object for a copy with the I method. + +=cut + +# the new method can be inherited from FS::Record, if a table method is defined + +sub table { 'part_export'; } + +=item insert + +Adds this record to the database. If there is an error, returns the error, +otherwise returns false. + +=cut + +# the insert method can be inherited from FS::Record + +=item delete + +Delete this record from the database. + +=cut + +# the delete method can be inherited from FS::Record + +=item replace OLD_RECORD + +Replaces the OLD_RECORD with this one in the database. If there is an error, +returns the error, otherwise returns false. + +=cut + +# the replace method can be inherited from FS::Record + +=item check + +Checks all fields to make sure this is a valid export. If there is +an error, returns the error, otherwise returns false. Called by the insert +and replace methods. + +=cut + +sub check { + my $self = shift; + my $error = + $self->ut_numbern('exportnum') + || $self->ut_number('svcpart') + || $self->ut_alpha('exporttype') + ; + return $error if $error; + + return "Unknown svcpart: ". $self->svcpart + unless qsearchs( 'part_svc', { 'svcpart' => $self->svcpart } ); + + $self->machine =~ /^([\w\-\.]*)$/ + or return "Illegal machine: ". $self->machine; + $self->machine($1); + + $self->nodomain =~ /^(Y?)$/ or return "Illegal nodomain: ". $self->nodomain; + $self->nodomain($1); + + #check exporttype? + + ''; #no error +} + +=back + +=head1 BUGS + +Probably. + +=head1 SEE ALSO + +L, L, L, L, +L, L, schema.html from the base documentation. + +=cut + +1; + diff --git a/FS/FS/part_export_option.pm b/FS/FS/part_export_option.pm new file mode 100644 index 000000000..4ce70b4cd --- /dev/null +++ b/FS/FS/part_export_option.pm @@ -0,0 +1,134 @@ +package FS::part_export_option; + +use strict; +use vars qw( @ISA ); +use FS::Record qw( qsearch qsearchs ); +use FS::part_export; + +@ISA = qw(FS::Record); + +=head1 NAME + +FS::part_export_option - Object methods for part_export_option records + +=head1 SYNOPSIS + + use FS::part_export_option; + + $record = new FS::part_export_option \%hash; + $record = new FS::part_export_option { 'column' => 'value' }; + + $error = $record->insert; + + $error = $new_record->replace($old_record); + + $error = $record->delete; + + $error = $record->check; + +=head1 DESCRIPTION + +An FS::part_export_option object represents an export option. +FS::part_export_option inherits from FS::Record. The following fields are +currently supported: + +=over 4 + +=item optionnum - primary key + +=item exportnum - export (see L) + +=item option - option name + +=item opeionvalue - option value + +=back + +=head1 METHODS + +=over 4 + +=item new HASHREF + +Creates a new export option. To add the export option to the database, see +L<"insert">. + +Note that this stores the hash reference, not a distinct copy of the hash it +points to. You can ask the object for a copy with the I method. + +=cut + +# the new method can be inherited from FS::Record, if a table method is defined + +sub table { 'part_export_option'; } + +=item insert + +Adds this record to the database. If there is an error, returns the error, +otherwise returns false. + +=cut + +# the insert method can be inherited from FS::Record + +=item delete + +Delete this record from the database. + +=cut + +# the delete method can be inherited from FS::Record + +=item replace OLD_RECORD + +Replaces the OLD_RECORD with this one in the database. If there is an error, +returns the error, otherwise returns false. + +=cut + +# the replace method can be inherited from FS::Record + +=item check + +Checks all fields to make sure this is a valid export option. If there is +an error, returns the error, otherwise returns false. Called by the insert +and replace methods. + +=cut + +# the check method should currently be supplied - FS::Record contains some +# data checking routines + +sub check { + my $self = shift; + + my $error = + $self->ut_numbern('optionnum') + || $self->ut_number('exportnum') + || $self->ut_alpha('option') + || $self->ut_textn('optionvalue') + ; + return $error if $error; + + return "Unknown exportnum: ". $self->exportnum + unless qsearchs('part_export', { 'exportnum' => $self->exportnum } ); + + #check options & values? + + ''; #no error +} + +=back + +=head1 BUGS + +Possibly. + +=head1 SEE ALSO + +L, L, schema.html from the base documentation. + +=cut + +1; + diff --git a/README.1.4.0pre4567-8 b/README.1.4.0pre4567-8 index e567120a9..57474fed0 100644 --- a/README.1.4.0pre4567-8 +++ b/README.1.4.0pre4567-8 @@ -1,11 +1,19 @@ the following is necessary to upgrade from 1.4.0pre (4 thru 7) to 1.4.0pre8 +if you're upgrading from 1.3.1 follow the instructions in +httemplate/docs/upgrade8.html instead + +if you're upgradeing from before 1.4.0pre4, see +http://cleanwhisker.420.am/cgi-bin/cvsweb/freeside/Attic/ + +----- + install the perl modules and httemplate as per install.html or upgrade8.html ALTER TABLE part_pkg ADD disabled char(1) NULL; ALTER TABLE part_svc ADD disabled char(1) NULL; -CREATE TABLE cust_bill_events ( +CREATE TABLE cust_bill_event ( eventnum int primary key, invnum int not null, eventpart int not null, @@ -14,7 +22,7 @@ CREATE TABLE cust_bill_events ( CREATE UNIQUE INDEX cust_bill_events1 ON cust_bill_events ( eventpart, invnum ); CREATE INDEX cust_bill_events2 ON cust_bill_events ( invnum ); -CREATE TABLE part_bill_events ( +CREATE TABLE part_bill_event ( eventpart int primary key, payby char(4) not null, event varchar(80) not null, @@ -24,6 +32,25 @@ CREATE TABLE part_bill_events ( ); CREATE INDEX part_bill_events1 ON part_bill_events ( payby ); +CREATE TABLE part_export ( + exportnum int primary key, + svcpart int not null, + machine varchar(80) not null, + exporttype varchar(80) not null, + nodomain char(1) NULL +); +CREATE INDEX part_export1 ON part_export ( machine ); +CREATE INDEX part_export2 ON part_export ( exporttype ); + +CREATE INDEX part_export_option ( + optionnum int primary key, + exportnum int not null, + option varchar(80) not null, + optionvalue text NULL +); +CREATE INDEX part_export_option1 ON part_export ( exportnum ); +CREATE INDEX part_export_option2 ON part_export ( option ); + Run bin/dbdef-create Restart Apache and freeside-queued diff --git a/bin/fs-setup b/bin/fs-setup index c7335a8fb..5b82eaf86 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.69 2002-01-03 17:40:26 ivan Exp $ +# $Id: fs-setup,v 1.70 2002-01-28 05:15:28 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -842,6 +842,32 @@ sub tables_hash_hack { 'unique' => [], 'index' => [ [ 'jobnum' ] ], }, + + 'part_export' => { + 'columns' => [ + 'exportnum', 'int', '', '', + 'svcpart', 'int', '', '', + 'machine', 'varchar', '', $char_d, + 'exporttype', 'varchar', '', $char_d, + 'nodomain', 'char', 'NULL', 1, + ], + 'primary_key' => 'exportnum', + 'unique' => [], + 'index' => [ [ 'machine' ], [ 'exporttype' ] ], + }, + + 'part_export_option' => { + 'columns' => [ + 'optionnum', 'int', '', '', + 'exportnum', 'int', '', '', + 'option', 'varchar', '', $char_d, + 'optionvalue', 'text', 'NULL', '', + ], + 'primary_key' => 'optionnum', + 'unique' => [], + 'index' => [ [ 'exportnum' ], [ 'option' ] ], + }, + ); %tables; diff --git a/httemplate/docs/schema.html b/httemplate/docs/schema.html index a51bf6e68..3e9189b30 100644 --- a/httemplate/docs/schema.html +++ b/httemplate/docs/schema.html @@ -247,6 +247,21 @@
  • svcpart - Service definition
  • quantity - quantity of this service that this package includes +
  • part_export - Export to external provisioning +
      +
    • exportnum - primary key +
    • svcpart - Service definition +
    • machine - Machine name +
    • exporttype - Export type +
    • nodomain - blank or Y: usernames are exported to this service with no domain +
    +
  • part_export_option - provisioning options +
      +
    • optionnum - primary key +
    • exportnum - Export +
    • option - option name +
    • optionvalue - option value +
  • port - individual port on a nas
    • portnum - primary key diff --git a/httemplate/docs/upgrade8.html b/httemplate/docs/upgrade8.html index 904694879..144242b6a 100644 --- a/httemplate/docs/upgrade8.html +++ b/httemplate/docs/upgrade8.html @@ -143,6 +143,25 @@ CREATE TABLE part_bill_event ( ); CREATE INDEX part_bill_event1 ON part_bill_event ( payby ); +CREATE TABLE part_export ( + exportnum int primary key, + svcpart int not null, + machine varchar(80) not null, + exporttype varchar(80) not null, + nodomain char(1) NULL +); +CREATE INDEX part_export1 ON part_export ( machine ); +CREATE INDEX part_export2 ON part_export ( exporttype ); + +CREATE INDEX part_export_option ( + optionnum int primary key, + exportnum int not null, + option varchar(80) not null, + optionvalue text NULL +); +CREATE INDEX part_export_option1 ON part_export ( exportnum ); +CREATE INDEX part_export_option2 ON part_export ( option ); + ALTER TABLE svc_acct ADD domsvc integer NOT NULL; ALTER TABLE svc_domain ADD catchall integer NULL; ALTER TABLE cust_main ADD referral_custnum integer NULL; -- 2.11.0