SQL error when adding an other database table The Code:

In my module.install i am declaring my main database table. This works without any problems:

function my_module_install() {
  create_initial_roles();
  drupal_set_message("Installed module my_module.");
}

function my_module_schema() {
  $schema['my_module_foo'] = [
    'description' =&gt; 'Main table for my_module.',
    'fields' =&gt; [
      'id' =&gt; [
        'description' =&gt; 'The ID of the database entry of foo.',
        'type' =&gt; 'serial',
      ],
      // Many more fields ...
    ],
     'primary key' =&gt; ['id'],
  ];
  // Second table goes here (see code below).
  return $schema;
}


But as soon as i'm adding a second table, i am getting a SQL error:

// Inserted in shema function (see comment above).
$schema['my_module_bar'] = [
    'description' =&gt; 'Secondary table for my_module.',
    'fields' =&gt; [
      'id' =&gt; [
        'description' =&gt; 'The ID of the database entry of bar.',
        'type' =&gt; 'serial',
      ],
      // Possibly more fields.
      'primary key' =&gt; ['id'],
    ],
  ];


The Error: 

The error occurs when installing the module:

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'DEFAULT NULL ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COMMENT 'Main table fo' at line 3: CREATE TABLE {my_module_bar} ( id INT auto_increment DEFAULT NULL COMMENT 'The ID of the database entry of the bar.', primary key DEFAULT NULL ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COMMENT 'Main table for my_module.'; Array ( ) in db_create_table() (line 2776 of C:\xampp\htdocs\drupal\includes\database\database.inc).

It looks like it is a problem with the character set (utf8) but it is a bit weird, that this error does not occur with only my main database table.
You're including the primary key as a field, which won't work. It needs to be on the same level as fields:

'fields' =&gt; [
  'id' =&gt; [
    'description' =&gt; 'The ID of the database entry of bar.',
    'type' =&gt; 'serial',
  ],
],
'primary key' =&gt; ['id'],