You are here

function uc_recurring_schema in UC Recurring Payments and Subscriptions 7.2

Same name and namespace in other branches
  1. 6.2 uc_recurring.install \uc_recurring_schema()
  2. 6 uc_recurring.install \uc_recurring_schema()

Implements hook_schema().

File

./uc_recurring.install, line 11
Installs the Recurring Fee module.

Code

function uc_recurring_schema() {
  $schema['uc_recurring_users'] = array(
    'description' => 'Data for recurring fees attached to users/orders scheduled to be charged.',
    'fields' => array(
      'rfid' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'fee_handler' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'fee_title' => array(
        'description' => 'The text shown on invoices for this recurring fee.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'next_charge' => array(
        'description' => 'The timestamp when the next charge should be performed.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'fee_amount' => array(
        'description' => 'The amount of the recurring fee.',
        'type' => 'numeric',
        'precision' => 15,
        'scale' => 3,
        'not null' => TRUE,
        'default' => 0.0,
      ),
      'regular_interval' => array(
        'description' => 'The amount of time between charges.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '0',
      ),
      'remaining_intervals' => array(
        'description' => 'The remaining number of times the fee should be charged.',
        'type' => 'int',
        'size' => 'small',
        'unsigned' => FALSE,
        'not null' => TRUE,
        'default' => -1,
      ),
      'charged_intervals' => array(
        'description' => 'Counter for how many times the fee has been charged.',
        'type' => 'int',
        'size' => 'small',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 1,
      ),
      'order_id' => array(
        'description' => 'The order ID.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'data' => array(
        'description' => 'Serialized array of extra data.',
        'type' => 'text',
        'serialize' => TRUE,
      ),
      'created' => array(
        'description' => 'Timestamp for when the fee was first attached to the user.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'attempts' => array(
        'description' => 'How many times have we attempted to process this payment.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'pfid' => array(
        'description' => 'The product fee this recurring fee was created from.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'default' => 0,
      ),
      'order_product_id' => array(
        'description' => 'The product ID.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'default' => 0,
      ),
      'own_handler' => array(
        'description' => 'Indicate if recurring fee is done by own handler, such as Paypal.',
        'type' => 'int',
        'size' => 'small',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'default' => 0,
      ),
      'status' => array(
        'description' => 'The status of the recurring fee, e.g. "active" or "expired"',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'module' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'rfid',
    ),
  );
  $schema['uc_recurring_orders'] = array(
    'description' => 'Data for handling recurring relationships between orders.',
    'fields' => array(
      'original_order_id' => array(
        'description' => 'The original order ID.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'renewal_order_id' => array(
        'description' => 'The recurring order ID.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
  );
  $schema['uc_recurring_schedule'] = array(
    'description' => 'Data for handling more complex recurring schedules.',
    'fields' => array(
      'pfid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'interval_num' => array(
        'description' => 'The number in the recurring schedule to.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'fee_amount' => array(
        'description' => 'The amount of the schedule fee to charge.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'next_interval' => array(
        'description' => 'The amount of time before next charge.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '0',
      ),
      'rfid' => array(
        'description' => 'The specific id of the recurring fee to effect, NULL to effect all recurring fees.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'pfid',
      'interval_num',
    ),
  );
  $schema['uc_recurring_extensions'] = array(
    'description' => 'Data for handling extensions to recurring fees.',
    'fields' => array(
      'pfid' => array(
        'description' => 'The schedule ID that this extension relates to.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'default' => NULL,
      ),
      'rebill_attempt' => array(
        'description' => 'The rebill attempt number.',
        'type' => 'int',
        'size' => 'small',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'time_to_extend' => array(
        'description' => 'Time in seconds to extend a recurring fee before next charge.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 1,
      ),
    ),
  );
  return $schema;
}