DatabaseSchemaObjectExistsException: Table products already exists I try to install my module, and everything goes ok, without an error while enabling


  DatabaseSchemaObjectExistsException: Table products already exists. in
  DatabaseSchema->createTable()...


I checked it and there wasn't the products table.

My install function is:

function products_schema() {
    $schema['products'] = array(
        'description' =&gt; 'The base table for products.',
        'fields' =&gt; array(
            'pid' =&gt; array(
                'description' =&gt; 'The primary identifier for a product.',
                'type' =&gt; 'serial',
                'unsigned' =&gt; TRUE,
                'not null' =&gt; TRUE,
            ),
            'name' =&gt; array(
                'description' =&gt; 'The title of this product, always treated a non-markup plain text.',
                'type' =&gt; 'varchar',
                'length' =&gt; 255,
                'not null' =&gt; TRUE,
                'default' =&gt; '',
            ),
            'created' =&gt; array(
                'description' =&gt; 'The Unix timestamp when the product was created.',
                'type' =&gt; 'int',
                'not null' =&gt; TRUE,
                'default' =&gt; 0,
            ),
            'changed' =&gt; array(
                'description' =&gt; 'The Unix timestamp when the product was most recently saved.',
                'type' =&gt; 'int',
                'not null' =&gt; TRUE,
                'default' =&gt; 0,
            ),
            'description' =&gt; array(
                'description' =&gt; 'The product description.',
                'type' =&gt; 'text',
                'not null' =&gt; FALSE,
            ),
        ),
        'indexes' =&gt; array(
            'node_changed' =&gt; array('changed'),
            'node_created' =&gt; array('created'),
        ),
        'primary key' =&gt; array('pid'),
    );

    return $schema;
}

function products_install() {
    drupal_install_schema('products');

    cache_clear_all(NULL, NULL, '*');
}

function products_uninstall() {
    drupal_uninstall_schema('products');

    $result = db_select('file_usage', 'f')
            -&gt;fields('f')
            -&gt;condition('type', 'product')
            -&gt;condition('module', 'products')
            -&gt;execute()
            -&gt;fetchAll();

    foreach ($result as $row) {
        $file = file_load($row-&gt;fid);

        if ($file) {
            file_usage_delete($file, 'products', NULL, NULL, 0);
            file_delete($file);
        }
    }
}
From your previous questions it looks like you're using Drupal 7, but the above code is partly for Drupal 6.

You don't need to add/remove the schema manually any more in Drupal 7; implementing hook_schema() is enough. Drupal installs the schema for you, and then when you it hits your implementation hook_install(), the table does already exists so it throws an error.

Just remove the calls to drupal_install_schema() and drupal_uninstall_schema(), uninstall the module and try again - it should work fine.