How do I create a table when a module is installed?
I see two problems with your hook_schema implementation.

You are missing a return statement at the end of your function to return the schema.
primary_key needs to be outside the fields array on the same level as the fields and the description.


/**
 * Implements hook_schema().
 */
function MYMODULE_schema() {
  $schema['post'] = [
    'description' =&gt; 'description pour la table post',
    'fields' =&gt; [
      'pid' =&gt; [
        'description' =&gt; 'post id',
        'type' =&gt; 'int',
        'not null' =&gt; TRUE,
      ],
      'title' =&gt; [
        'description' =&gt; 'title',
        'type' =&gt; 'varchar',
        'not null' =&gt; TRUE,
      ],
      'body' =&gt; [
        'description' =&gt; 'body',
        'type' =&gt; 'varchar',
        'not null' =&gt; TRUE,
      ],
      'created' =&gt; [
        'description' =&gt; 'created',
        'not null' =&gt; TRUE,
        'mysql_type' =&gt; 'timestamp',
      ],
    ],
    // primary_key needs to be outside the fields array.
    'primary key' =&gt; ['pid'],
  ];
  // Don't forget to return the schema.
  return $schema;
}