primary key for areacode table
authormark <mark>
Tue, 29 Mar 2011 01:04:31 +0000 (01:04 +0000)
committermark <mark>
Tue, 29 Mar 2011 01:04:31 +0000 (01:04 +0000)
FS/FS/Schema.pm
FS/FS/areacode.pm
FS/bin/freeside-upgrade

index 6d4fb03..25eafa3 100644 (file)
@@ -3270,13 +3270,14 @@ sub tables_hashref {
 
     'areacode'  => {
       'columns' => [
 
     'areacode'  => {
       'columns' => [
+        'areanum',   'serial',        '',      '', '', '',
         'code',        'char',        '',       3, '', '', 
         'country',     'char',    'NULL',       2, '', '',
         'state',       'char',    'NULL',       2, '', '', 
         'description','varchar',  'NULL',     255, '', '',
       ], 
         'code',        'char',        '',       3, '', '', 
         'country',     'char',    'NULL',       2, '', '',
         'state',       'char',    'NULL',       2, '', '', 
         'description','varchar',  'NULL',     255, '', '',
       ], 
-      'primary_key' => 'code',
-      'unique' => [],
+      'primary_key' => 'areanum',
+      'unique' => [ [ 'areanum' ] ],
       'index'  => [],
     },
 
       'index'  => [],
     },
 
index 58b498c..b6defa2 100644 (file)
@@ -25,27 +25,20 @@ FS::areacode - Object methods for areacode records
 
 =head1 DESCRIPTION
 
 
 =head1 DESCRIPTION
 
-An FS::areacode object represents an example.  FS::areacode inherits from
+An FS::areacode object represents an area code.  FS::areacode inherits from
 FS::Record.  The following fields are currently supported:
 
 =over 4
 
 FS::Record.  The following fields are currently supported:
 
 =over 4
 
-=item code 
+=item areanum - primary key
 
 
-area code (primary key)
+=item code - area code
 
 
-=item country
+=item country - two-letter country code
 
 
-two-letter country code
-
-=item state
-
-two-letter state code, if appropriate
-
-=item description
-
-description (optional)
+=item state - two-letter state code, if appropriate
 
 
+=item description - description (optional)
 
 =back
 
 
 =back
 
@@ -92,7 +85,8 @@ sub check {
   my $self = shift;
 
   my $error = 
   my $self = shift;
 
   my $error = 
-    $self->ut_number('code')
+    $self->ut_numbern('areanum')
+    || $self->ut_number('code')
     || $self->ut_text('country')
     || $self->ut_textn('state')
     || $self->ut_textn('description')
     || $self->ut_text('country')
     || $self->ut_textn('state')
     || $self->ut_textn('description')
index aca545b..e11a0a7 100755 (executable)
@@ -71,6 +71,19 @@ if ( dbdef->table('cgp_rule_condition') &&
 
 }
 
 
 }
 
+if ( dbdef->table('areacode') and
+     dbdef->table('areacode')->primary_key eq 'code' )
+{
+  if ( driver_name =~ /^mysql/i ) {
+    push @bugfix, 
+      'ALTER TABLE areacode DROP PRIMARY KEY',
+      'ALTER TABLE areacode ADD COLUMN (areanum int auto_increment primary key)';
+  }
+  else {
+    push @bugfix, 'ALTER TABLE areacode DROP CONSTRAINT areacode_pkey';
+  }
+}
+
 # RT required field flag
 # for consistency with RT schema: mysql is in CamelCase,
 # pg is in lowercase, and they use different data types.
 # RT required field flag
 # for consistency with RT schema: mysql is in CamelCase,
 # pg is in lowercase, and they use different data types.