function uc_order_install in Ubercart 5
Same name and namespace in other branches
- 6.2 uc_order/uc_order.install \uc_order_install()
- 7.3 uc_order/uc_order.install \uc_order_install()
Implementation of hook_install().
File
- uc_order/
uc_order.install, line 6
Code
function uc_order_install() {
$t = get_t();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {uc_orders} (\n order_id mediumint(9) NOT NULL,\n uid mediumint(9) NOT NULL,\n order_status varchar(32) NOT NULL,\n order_total decimal(10,2) NOT NULL,\n primary_email varchar(96) NOT NULL,\n delivery_first_name varchar(32) NOT NULL,\n delivery_last_name varchar(32) NOT NULL,\n delivery_phone varchar(32) NOT NULL,\n delivery_company varchar(64) NOT NULL,\n delivery_street1 varchar(64) NOT NULL,\n delivery_street2 varchar(64) NOT NULL,\n delivery_city varchar(32) NOT NULL,\n delivery_zone mediumint(9) NOT NULL,\n delivery_postal_code varchar(10) NOT NULL,\n delivery_country mediumint(9) NOT NULL,\n billing_first_name varchar(32) NOT NULL,\n billing_last_name varchar(32) NOT NULL,\n billing_phone varchar(32) NOT NULL,\n billing_company varchar(64) NOT NULL,\n billing_street1 varchar(64) NOT NULL,\n billing_street2 varchar(64) NOT NULL,\n billing_city varchar(32) NOT NULL,\n billing_zone mediumint(9) NOT NULL,\n billing_postal_code varchar(10) NOT NULL,\n billing_country mediumint(9) NOT NULL,\n payment_method varchar(32) NOT NULL,\n data text,\n host varchar(16) NOT NULL DEFAULT '',\n created int(11) NOT NULL,\n modified int(11) NOT NULL,\n PRIMARY KEY (order_id),\n KEY uid (uid),\n KEY order_status (order_status)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("CREATE TABLE {uc_order_admin_comments} (\n comment_id mediumint(9) NOT NULL auto_increment,\n order_id mediumint(9) NOT NULL,\n uid mediumint(9) NOT NULL,\n message text NOT NULL,\n created int(11) NOT NULL,\n PRIMARY KEY (comment_id),\n KEY order_id (order_id)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("CREATE TABLE {uc_order_comments} (\n comment_id mediumint(9) NOT NULL auto_increment,\n order_id mediumint(9) NOT NULL,\n uid mediumint(9) NOT NULL,\n order_status varchar(32) NOT NULL,\n notified tinyint(4) NOT NULL,\n message text NOT NULL,\n created int(11) NOT NULL,\n PRIMARY KEY (comment_id),\n KEY order_id (order_id)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("CREATE TABLE {uc_order_line_items} (\n line_item_id mediumint(9) NOT NULL auto_increment,\n order_id mediumint(9) NOT NULL,\n type varchar(32) NOT NULL,\n title varchar(128) NOT NULL,\n amount decimal(10,2) NOT NULL,\n weight smallint(6) NOT NULL,\n data text,\n PRIMARY KEY (line_item_id),\n KEY order_id (order_id)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("CREATE TABLE {uc_order_log} (\n order_log_id mediumint(9) NOT NULL auto_increment,\n order_id mediumint(9) NOT NULL,\n uid mediumint(9) NOT NULL,\n changes text NOT NULL,\n created int(11) NOT NULL,\n PRIMARY KEY (order_log_id),\n KEY order_id (order_id)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("CREATE TABLE {uc_order_products} (\n order_product_id int(9) NOT NULL auto_increment,\n order_id mediumint(9) NOT NULL,\n nid mediumint(9) NOT NULL,\n title varchar(128) NOT NULL,\n manufacturer varchar(32) NOT NULL,\n model varchar(255) NOT NULL,\n qty smallint(6) NOT NULL,\n cost decimal(10,2) NOT NULL,\n price decimal(10,2) NOT NULL,\n weight float NOT NULL,\n data text NOT NULL,\n PRIMARY KEY (order_product_id),\n KEY order_id (order_id)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("CREATE TABLE {uc_order_statuses} (\n order_status_id varchar(32) NOT NULL,\n title varchar(48) NOT NULL,\n state varchar(32) NOT NULL,\n weight smallint(9) NOT NULL,\n locked tinyint(4) NOT NULL,\n PRIMARY KEY (order_status_id)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("INSERT INTO {uc_order_statuses} (order_status_id, title, state, weight, locked) VALUES " . "('canceled', '" . $t('Canceled') . "', 'canceled', -20, 1), " . "('in_checkout', '" . $t('In checkout') . "', 'in_checkout', -10, 1), " . "('pending', '" . $t('Pending') . "', 'post_checkout', 0, 1), " . "('processing', '" . $t('Processing') . "', 'post_checkout', 10, 1), " . "('completed', '" . $t('Completed') . "', 'completed', 20, 1);");
break;
case 'pgsql':
db_query("CREATE TABLE {uc_orders} (\n order_id serial NOT NULL,\n uid integer NOT NULL default 0,\n order_status varchar(32) NOT NULL default 0,\n order_total decimal(10,2) NOT NULL default 0.00,\n primary_email varchar(96) NOT NULL default '',\n delivery_first_name varchar(32) NOT NULL default '',\n delivery_last_name varchar(32) NOT NULL default '',\n delivery_phone varchar(32) NOT NULL default '',\n delivery_company varchar(64) NOT NULL default '',\n delivery_street1 varchar(64) NOT NULL default '',\n delivery_street2 varchar(64) NOT NULL default '',\n delivery_city varchar(32) NOT NULL default '',\n delivery_zone integer NOT NULL default 0,\n delivery_postal_code varchar(10) NOT NULL default '',\n delivery_country integer NOT NULL default 0,\n billing_first_name varchar(32) NOT NULL default '',\n billing_last_name varchar(32) NOT NULL default '',\n billing_phone varchar(32) NOT NULL default '',\n billing_company varchar(64) NOT NULL default '',\n billing_street1 varchar(64) NOT NULL default '',\n billing_street2 varchar(64) NOT NULL default '',\n billing_city varchar(32) NOT NULL default '',\n billing_zone integer NOT NULL default 0,\n billing_postal_code varchar(10) NOT NULL default '',\n billing_country integer NOT NULL default 0,\n payment_method varchar(32) NOT NULL default 0,\n data text NOT NULL default '',\n host varchar(16) NOT NULL default '',\n created integer NOT NULL default 0,\n modified integer NOT NULL default 0,\n PRIMARY KEY (order_id)\n );");
db_query("CREATE INDEX {uc_orders}_uid ON {uc_orders} (uid)");
db_query("CREATE INDEX {uc_orders}_order_status ON {uc_orders} (order_status)");
db_query("CREATE TABLE {uc_order_admin_comments} (\n comment_id serial NOT NULL,\n order_id integer NOT NULL default 0,\n uid integer NOT NULL default 0,\n message text NOT NULL default '',\n created integer NOT NULL default 0,\n PRIMARY KEY (comment_id)\n );");
db_query("CREATE INDEX {uc_order_admin_comments}_order_id ON {uc_order_admin_comments} (order_id)");
db_query("CREATE TABLE {uc_order_comments} (\n comment_id serial NOT NULL,\n order_id integer NOT NULL default 0,\n uid integer NOT NULL default 0,\n order_status varchar(32) NOT NULL default 0,\n notified smallint NOT NULL default 0,\n message text NOT NULL default '',\n created integer NOT NULL default 0,\n PRIMARY KEY (comment_id)\n );");
db_query("CREATE INDEX {uc_order_comments}_order_id ON {uc_order_comments} (order_id)");
db_query("CREATE TABLE {uc_order_line_items} (\n line_item_id serial NOT NULL,\n order_id integer NOT NULL default 0,\n type varchar(32) NOT NULL default '',\n title varchar(128) NOT NULL default '',\n amount decimal(10,2) NOT NULL default 0.00,\n weight smallint NOT NULL default 0,\n PRIMARY KEY (line_item_id)\n );");
db_query("CREATE INDEX {uc_order_line_items}_order_id ON {uc_order_line_items} (order_id)");
db_query("CREATE TABLE {uc_order_log} (\n order_log_id serial NOT NULL,\n order_id integer NOT NULL default 0,\n uid integer NOT NULL default 0,\n changes text NOT NULL default '',\n created integer NOT NULL default 0,\n PRIMARY KEY (order_log_id)\n );");
db_query("CREATE INDEX {uc_order_log}_order_id ON {uc_order_log} (order_id)");
db_query("CREATE TABLE {uc_order_products} (\n order_product_id serial NOT NULL,\n order_id integer NOT NULL default 0,\n nid integer NOT NULL default 0,\n title varchar(128) NOT NULL default '',\n manufacturer varchar(32) NOT NULL default '',\n model varchar(255) NOT NULL default '',\n qty smallint NOT NULL default 0,\n cost decimal(10,2) NOT NULL default 0.00,\n price decimal(10,2) NOT NULL default 0.00,\n weight float NOT NULL default 0.0,\n data text NOT NULL default '',\n PRIMARY KEY (order_product_id)\n );");
db_query("CREATE INDEX {uc_order_products}_order_id ON {uc_order_products} (order_id)");
db_query("CREATE TABLE {uc_order_statuses} (\n order_status_id varchar(32) NOT NULL,\n title varchar(48) NOT NULL,\n state varchar(32) NOT NULL,\n weight smallint NOT NULL,\n locked smallint NOT NULL,\n PRIMARY KEY (order_status_id)\n );");
db_query("INSERT INTO {uc_order_statuses} (order_status_id, title, state, weight, locked) VALUES ('canceled', '" . $t('Canceled') . "', 'canceled', -20, 1);");
db_query("INSERT INTO {uc_order_statuses} (order_status_id, title, state, weight, locked) VALUES ('in_checkout', '" . $t('In checkout') . "', 'in_checkout', -10, 1);");
db_query("INSERT INTO {uc_order_statuses} (order_status_id, title, state, weight, locked) VALUES ('pending', '" . $t('Pending') . "', 'post_checkout', 0, 1);");
db_query("INSERT INTO {uc_order_statuses} (order_status_id, title, state, weight, locked) VALUES ('processing', '" . $t('Processing') . "', 'post_checkout', 5, 1);");
db_query("INSERT INTO {uc_order_statuses} (order_status_id, title, state, weight, locked) VALUES ('completed', '" . $t('Completed') . "', 'completed', 20, 1);");
break;
}
}