Vote count:
0
I am trying to set up a module in drupal, an this is my temas.install:
<?php
function temas_schema () {
$schema['project_tema'] = array(
'description' => 'Esta tabla es para gestionar el ranking de temas',
'fields' => array(
'id' => array(
'description' => 'The primary identifier for my table.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'length' => 11,
),
'usuario' => array(
'description' => 'The foreign key users for my table.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'length' => 10,
),
'nombre' => array(
'description' => 'El título del tema.',
'type' => 'varchar',
'length' => 45,
'not null' => TRUE,
),
'descripcion' => array(
'description' => 'La descripción del tema.',
'type' => 'text'
),
'votos' => array(
'description' => 'Número de votaciones que tiene este tema.',
'type' => 'int',
'int' => 4,
'not null' => TRUE,
'default' => '0'
),
'fecha' => array(
'description' => 'Fecha en la que se insertó el tema.',
'type' => 'datetime:normal'
),
),
'indexes' => array(
'fk_tema_users_idx' => array('usuario'),
),
'foreign keys' => array(
'fk_tema_users' => array(
'table' => 'users',
'columns' => array('usuario' => 'uid'),
),
),
'primary key' => array('id'),
);
return $schema;
}
function temas_install() {
// Make real foreign keys.
db_query('
ALTER TABLE {project_tema}
ADD CONSTRAINT {fk_tema_users}
FOREIGN KEY (usuario) REFERENCES {users} (uid) ON DELETE CASCADE ON UPDATE CASCADE
');
}
/**
* Implements hook_uninstall().
*/
function temas_uninstall() {
// Make real foreign keys.
db_query('
ALTER TABLE {project_tema}
DROP CONSTRAINT IF EXISTS {fk_tema_users}
');
}
?>
The problem is that when I try to activate it, I get this mysql error:
Any idea what am I missing?
Thanks!
asked 39 secs ago
Drupal create module, mysql error
Aucun commentaire:
Enregistrer un commentaire