Database migration

Hello everyone,

I’ve been working with Strapi recently. Everything works fine, but Strapi database migration seems not to work well. I want to delete a collection type and then migrate my migration file to recreate the deleted collection type.

Is there a way that i can create a collection type in Strapi automatically based on my migration file?

This is my migration file:

module.exports = {
  async up(knex) {

    const tableExists = await knex.schema.hasTable('tenant_types');
    if (!tableExists) {
      await knex.schema.createTable('tenant_types', (table) => {

      console.log('Table "tenant_types" was created.');
    } else {
      console.log('Table "tenant_types" already exists, no action needed.');


This is the error message:

 error: Migration create-default-data-tenant-type.js (up) failed: Original error: insert into `tenant_types` (`name`, `slug`) values ('Enterprise', 'enterprise') - ER_NO_SUCH_TABLE: Table 'strapi
.tenant_types' doesn't exist