hasTable('company_functions')) { $table = $this->table('company_functions', [ 'id' => false, 'primary_key' => ['id'], 'signed' => false, 'collation' => 'utf8mb4_general_ci', 'encoding' => 'utf8mb4', ]); $table ->addColumn('id', 'integer', [ 'identity' => true, 'signed' => false, ]) ->addColumn('function_name', 'string', [ 'limit' => 150, 'null' => false, 'comment' => 'Function name, for example RSPP, Medico del lavoro, RLS', ]) ->addColumn('person_full_name', 'string', [ 'limit' => 200, 'null' => false, 'comment' => 'Full name and surname of the person assigned to the function', ]) ->addColumn('phone', 'string', [ 'limit' => 80, 'null' => true, ]) ->addColumn('email', 'string', [ 'limit' => 190, 'null' => true, ]) ->addColumn('notes', 'text', [ 'null' => true, ]) ->addColumn('sort_order', 'integer', [ 'signed' => false, 'null' => false, 'default' => 0, ]) ->addColumn('is_active', 'boolean', [ 'null' => false, 'default' => true, ]) ->addColumn('created_at', 'timestamp', [ 'null' => true, 'default' => 'CURRENT_TIMESTAMP', ]) ->addColumn('updated_at', 'timestamp', [ 'null' => true, 'default' => null, 'update' => 'CURRENT_TIMESTAMP', ]) ->addIndex(['function_name'], [ 'name' => 'idx_company_functions_function_name', ]) ->addIndex(['person_full_name'], [ 'name' => 'idx_company_functions_person_full_name', ]) ->addIndex(['email'], [ 'name' => 'idx_company_functions_email', ]) ->addIndex(['is_active', 'sort_order'], [ 'name' => 'idx_company_functions_active_sort', ]) ->create(); } $this->execute(" INSERT INTO company_functions (function_name, person_full_name, phone, email, notes, sort_order, is_active, created_at, updated_at) VALUES ('RSPP', '', NULL, NULL, NULL, 10, 1, NOW(), NOW()), ('Medico del lavoro', '', NULL, NULL, NULL, 20, 1, NOW(), NOW()), ('RLS', '', NULL, NULL, NULL, 30, 1, NOW(), NOW()) "); } public function down(): void { if ($this->hasTable('company_functions')) { $this->table('company_functions')->drop()->save(); } } }