Create custom scheme for extending


#1

Hi for all!

I developed API for my CAD database with the following scheme for each type of component:

class CapacitorSchema extends Schema {
  up () {
    this.create('capacitors', (table) => {
      /*Non-variable part*/
      table.increments();
      table.string('part_number').unique().notNullable();

      /*Variable part*/
      table.decimal('value', null).comment('F');
      table.float('tolerance').comment('%');
      table.float('voltage').comment('V');
      table.string('dielectric');
      table.decimal('esr', null).comment('Ohms');

      /*Non-variable part*/
      table.decimal('dissipation_power_scheme', null).comment('W');
      table.integer('operating_temp_low').comment('°C');
      table.integer('operating_temp_high').comment('°C');
      table.integer('storage_temp_low').comment('°C');
      table.integer('storage_temp_high').comment('°C');
      ...

As you can see all of my models have non-variable part with more than 40 entries.

My question is - How I can create a custom scheme for components and inherit it for all types of components?