Error in the install file of the module..
Hi,
The following schema definition in my module.install file runs into error
$schema['payment_mode'] = array(
'description' => 'This table stores various payment types for a particular user, based on uid',
'fields' =>
array (
'id' =>
array (
'type' => 'serial',
'size' => 'small',
'not null' => true,
'unsigned' => true,
'autoincrement' => true,
'description' => 'id for each row value.',
),
'uid' =>
array (
'type' => 'int',
'length' => 10,
'not null' => true,
'unsigned' => true,
'description' => 'The {users}.uid that owns this payment mode',
),
'Type' =>
array (
'type' => 'varchar',
'length' => 32,
'default' => '',
'description' => 'Card Type, either of visa, mastercard',
),
'Card_Name' =>
array (
'type' => 'varchar',
'length' => 80,
'not null' => false,
'description' => 'Card Holders name',
),
'Card_Number' =>
array (
'type' => 'int',
'length' => 16,
'not null' => false,
'description' => 'Card Number',
),
'Expiry_Month' =>
array (
'type' => 'int',
'length' => 2,
'not null' => false,
'description' => 'Expiry Month',
),
'Expiry_Year' =>
array (
'type' => 'int',
'length' => 2,
'not null' => false,
'description' => 'Expiry Year',
),
'CVV' =>
array (
'type' => 'int',
'length' => 3,
'not null' => false,
'description' => 'CVV',
),
'Email' =>
array (
'type' => 'varchar',
'length' => 50,
'not null' => false,
'description' => 'Email Address for paypal',
),
'Status' =>
array (
'type' => 'varchar',
'length' => 10,
'not null' => false,
'default' => 'ACTIVE',
'description' => 'Status for the payment mode',
),
'Category' =>
array (
'type' => 'varchar',
'length' => 20,
'not null' => false,
'description' => 'Category of the Card, for now all CC are marked VISA',
),
'primary key' =>
array ('id' ),
'unique key' =>
array ('uid' ),
),
-------------
The error reported is
# user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT NULL, `unique key` DEFAULT NULL ) /*!40100 DEFAULT CHARACTER SET UTF8 ' at line 13 query: CREATE TABLE payment_mode ( `id` SMALLINT unsigned NOT NULL auto_increment, `uid` INT(10) unsigned NOT NULL, `Type` VARCHAR(32) DEFAULT '', `Card_Name` VARCHAR(80) DEFAULT NULL, `Card_Number` INT(16) DEFAULT NULL, `Expiry_Month` INT(2) DEFAULT NULL, `Expiry_Year` INT(2) DEFAULT NULL, `CVV` INT(3) DEFAULT NULL, `Email` VARCHAR(50) DEFAULT NULL, `Status` VARCHAR(10) DEFAULT 'ACTIVE', `Category` VARCHAR(20) DEFAULT NULL, `primary key` DEFAULT NULL, `unique key` DEFAULT NULL ) /*!40100 DEFAULT CHARACTER SET UTF8 */ in /var/www/iguru/includes/database.inc on line 515.
Kindly suggest what needs to be changed in my install file.. The SQLfor the same which i want is --
CREATE TABLE IF NOT EXISTS `payment_mode` (
`id` int(11) NOT NULL auto_increment,
`uid` int(10) NOT NULL,
`Type` varchar(32) default NULL,
`Card_Name` varchar(80) default NULL,
`Card_Number` bigint(16) default NULL,
`Expiry_Month` int(2) default NULL,
`Expiry_Year` int(2) default NULL,
`CVV` int(3) default NULL,
`Email` varchar(50) default NULL,
`Status` varchar(10) NOT NULL default 'ACTIVE',
`Category` varchar(20) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uid` (`uid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
----
Thanks in Advance
-Srbhaska

Yes, the problem is in your
Yes, the problem is in your definition of the primary and unique keys.
There's an easier way to do this. Install the Schema module. With it, you can create your table in the database as you want it to appear (as in, you can use PHPMyAdmin), and then schema will tell you how this declaration for that table should be constructed.
-Corey
- Corey